Skip to content

Commit

Permalink
Fix voxel visualization (#213)
Browse files Browse the repository at this point in the history
* fix voxel viz

* generalize to any voxel  size

* Update src/spatio_temporal_voxel_grid.cpp

Co-authored-by: Steve Macenski <stevenmacenski@gmail.com>

Co-authored-by: Steve Macenski <stevenmacenski@gmail.com>
  • Loading branch information
doisyg and SteveMacenski authored Oct 1, 2021
1 parent be3a2d3 commit 7bf1e12
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/spatio_temporal_voxel_grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,14 @@ void SpatioTemporalVoxelGrid::GetOccupancyPointCloud(
sensor_msgs::PointCloud2Iterator<float> iter_y(*pc2, "y");
sensor_msgs::PointCloud2Iterator<float> iter_z(*pc2, "z");

const double & center_offset = _voxel_size / 2.0;
for (std::vector<geometry_msgs::msg::Point32>::iterator it =
_grid_points->begin();
it != _grid_points->end(); ++it)
{
const geometry_msgs::msg::Point32 & pt = *it;
*iter_x = pt.x;
*iter_y = pt.y;
*iter_x = pt.x + center_offset;
*iter_y = pt.y + center_offset;
*iter_z = pt.z;
++iter_x; ++iter_y; ++iter_z;
}
Expand Down

0 comments on commit 7bf1e12

Please sign in to comment.