tsengapola/costmap_depth_camera

Obstacles are not marked correctly when `min_obstacle_height` and `max_obstacle_height` are not integers

NaleRaphael opened this issue · 0 comments

Hi, thanks for this nice plugin.

However, we noticed that obstacles might not be marked correctly according to min_obstacle_height and max_obstacle_height in configuration. Said we set max_obstacle_height to 1.2 (unit: meter) and setup a D435i facing to a cubicle partition (height = 1.2m), there would be only part of the partition marked as obstacle. While measuring it with a tape measure and through RViz, it seems everything above 1m height is ignored.

After checking with the code, it seems the problem might be resulted from L488 and L504 in plugins/depth_camera_obstacle_layer.cpp.
Consider this part: h_ind > (int)marking_height_above_ground_/voxel_resolution_, the parentheses are missing to prioritize the calculation of marking_height_above_ground_/voxel_resolution_ before casting it to int.
So that given max_obstacle_height = 1.2 would be cast to 1 before being divided by voxel_resolution, and that's should be the cause of missing obstacle markers for objects above 1 meter height.

Therefore, those 2 lines should be revised as below:

- if(mx<0 || my<0 || h_ind>(int)marking_height_above_ground_/voxel_resolution_ || h_ind<(int)marking_height_under_ground_/voxel_resolution_)
+ if(mx<0 || my<0 || h_ind>(int)(marking_height_above_ground_/voxel_resolution_) || h_ind<(int)(marking_height_under_ground_/voxel_resolution_))