diff --git a/perception/compare_map_segmentation/src/voxel_grid_map_loader.cpp b/perception/compare_map_segmentation/src/voxel_grid_map_loader.cpp index 06bd89af38259..0cf75d5aa4664 100644 --- a/perception/compare_map_segmentation/src/voxel_grid_map_loader.cpp +++ b/perception/compare_map_segmentation/src/voxel_grid_map_loader.cpp @@ -240,9 +240,9 @@ bool VoxelGridMapLoader::is_in_voxel( if (voxel_index != -1) { // not empty voxel const double dist_x = map->points.at(voxel_index).x - target_point.x; const double dist_y = map->points.at(voxel_index).y - target_point.y; - const double dist_z = map->points.at(voxel_index).z - target_point.z; - const double sqr_distance = dist_x * dist_x + dist_y * dist_y + dist_z * dist_z; - if (sqr_distance < distance_threshold * distance_threshold * downsize_ratio_z_axis_) { + const double dist_z = map->points.at(voxel_index).z - target_point.z - 0.1; + // check if the point is inside the distance threshold voxel + if(std::abs(dist_x) < distance_threshold && std::abs(dist_y) < distance_threshold && std::abs(dist_z) < distance_threshold * downsize_ratio_z_axis_){ return true; } }