Call clear costmap service periodically

asked 2020-03-25 05:59:02 -0500

Alessandro Melino gravatar image


I have the ROS navigation package on Kinetic with a Realsense camera. I am transforming the depth image of the camera to laser scan, and then with that laser scan generate obstacles with the costmap_2d package. The problem arrives when the obstacle gets closer to my robot and it generates lots of marks of obstacles and it does not clear the old ones. I have the marking and clearing parameters set to true as you can see in the following code snippet:

laser_layer: #Laser
  #track_unknown_space: false
  #footprint_clearing_enabled: true
  #combination_method: 1
  observation_sources:  laser
    topic: /scan
    sensor_frame: camera_depth_frame
    #observation_persistance: 0.0
    expected_update_rate: 0
    data_type: LaserScan
    clearing: true
    marking: true
    #max_obstacle_height: 2.0
    #min_obstacle_height: 0.0
    obstacle_range: 3.0
    raytrace_range: 3.5
    #inf_is_invalid: false

I want to call the clear costmap service periodically (for example each 500ms) to clean the obstacles and solve the problem, but I don't the way to call it in order to make it works.

I know I must call something like this:

std_srvs::Empty srv;

But i don't know in which script or .cpp file (move_base.cpp or obstacle_layer.cpp maybe?).

Thanks in advance.

Best regards. Alessandro

edit retag flag offensive close merge delete


I tried this on terminal and it worked:

rosservice call /move_base/clear_costmaps "{}"

Now I want to execute it periodically or in the begining of each measure.

Alessandro Melino gravatar image Alessandro Melino  ( 2020-03-27 05:45:46 -0500 )edit