8#include <gtsam_points/types/point_cloud.hpp>
10namespace gtsam_points {
32 bool free(
const Eigen::Vector3i& coord)
const {
return !
occupied(coord); }
53 using Ptr = std::shared_ptr<FastOccupancyGrid>;
54 using ConstPtr = std::shared_ptr<const FastOccupancyGrid>;
64 template <
typename Po
intCloud>
65 void insert(
const PointCloud& points,
const Eigen::Isometry3d& pose = Eigen::Isometry3d::Identity());
71 template <
typename Po
intCloud>
72 int calc_overlap(
const PointCloud& points,
const Eigen::Isometry3d& pose = Eigen::Isometry3d::Identity())
const;
78 template <
typename Po
intCloud>
85 template <
typename Po
intCloud>
86 std::vector<unsigned char>
get_overlaps(
const PointCloud& points,
const Eigen::Isometry3d& pose = Eigen::Isometry3d::Identity())
const;
92 std::uint64_t calc_index(
const Eigen::Vector4i& coord)
const;
94 Eigen::Vector3i calc_coord(std::uint64_t index)
const;
96 std::uint64_t calc_hash(std::uint64_t index)
const;
98 std::uint64_t find_block(std::uint64_t block_index)
const;
100 std::uint64_t find_or_insert_block(std::uint64_t block_index);
102 void rehash(
size_t hash_size);
105 static constexpr std::uint64_t INVALID_INDEX = std::numeric_limits<std::uint64_t>::max();
106 static constexpr int coord_bit_size = 21;
107 static constexpr std::uint64_t coord_bit_mask = (1ull << 21) - 1;
108 static constexpr std::uint64_t coord_offset = 1ull << (coord_bit_size - 1);
110 double inv_resolution;
112 std::vector<std::pair<std::uint64_t, FastOccupancyBlock>> blocks;
Fast occupancy grid with occupancy blocks and flat hashing for efficient point cloud overlap evaluati...
Definition fast_occupancy_grid.hpp:51
FastOccupancyGrid(double resolution)
Constructor.
void insert(const PointCloud &points, const Eigen::Isometry3d &pose=Eigen::Isometry3d::Identity())
Insert points into the grid.
Definition fast_occupancy_grid_impl.hpp:15
int num_occupied_cells() const
Get the number of occupied cells in the grid.
int calc_overlap(const PointCloud &points, const Eigen::Isometry3d &pose=Eigen::Isometry3d::Identity()) const
Calculate the number of points overlapping with the grid.
Definition fast_occupancy_grid_impl.hpp:29
std::vector< unsigned char > get_overlaps(const PointCloud &points, const Eigen::Isometry3d &pose=Eigen::Isometry3d::Identity()) const
Get the overlap status of each point in the point cloud.
Definition fast_occupancy_grid_impl.hpp:55
double calc_overlap_rate(const PointCloud &points, const Eigen::Isometry3d &pose=Eigen::Isometry3d::Identity()) const
Calculate the overlap ratio of the points with the grid.
Definition fast_occupancy_grid_impl.hpp:50
Fast occupancy grid block.
Definition fast_occupancy_grid.hpp:13
static constexpr int num_cells
Number of cells in the block.
Definition fast_occupancy_grid.hpp:18
std::bitset< num_cells > cells
Occupancy status of each cell in the block.
Definition fast_occupancy_grid.hpp:47
void set_free(const Eigen::Vector3i &coord)
Set the cell as free.
Definition fast_occupancy_grid.hpp:40
static constexpr int stride
Size of the block in each dimension.
Definition fast_occupancy_grid.hpp:17
void set_occupied(const Eigen::Vector3i &coord)
Set the cell as occupied.
Definition fast_occupancy_grid.hpp:36
int count() const
Count the number of occupied cells.
Definition fast_occupancy_grid.hpp:44
int cell_index(const Eigen::Vector3i &coord) const
Calculate the index of the cell in the block.
Definition fast_occupancy_grid.hpp:22
bool free(const Eigen::Vector3i &coord) const
Check if the cell is free.
Definition fast_occupancy_grid.hpp:32
bool occupied(const Eigen::Vector3i &coord) const
Check if the cell is occupied.
Definition fast_occupancy_grid.hpp:27
Standard point cloud class that holds only pointers to point attributes.
Definition point_cloud.hpp:19