How to instantiate the costmap [closed]
I do have a problem to instantiate the costmap in my c++ code. I want to instantiate it to work with the resulting costmap object to obtain FREESPACE, UNKNOWN and OBSTACLE. But all I get is a costmap returning no obstacle, no inflated_obstacles, no freespace, just unknown.
This is what I preveiously start:
- turtlebot_minimal.launch
- gmapping.launch
My gmapping works fine and also the configuration of some parameter had succeeded.
THIS IS EXACTLY THE COSTMAP I WANT TO HAVE AS INSTANTIATED COSTMAP IN MY CODE !!!!
Here is my code:
costmap2d = new costmap_2d::Costmap2DROS("costmap", tf);
costmap2d->start();
This creates a costmap under /costmap which is not even close to the costmap created by /move_base.
Launchfile:
<launch>
<node pkg="simple_navigation" type="simple_navigation" name="simple_navigation" output="screen">
<rosparam file="$(find simple_navigation)/param/turtlebot_local_costmap.yaml" command="load" ns="costmap" />
</node>
</launch>
turtlebot_local_costmap.yaml:
local_costmap:
global_frame: /odom
robot_base_frame: /base_footprint
map_topic: map
map_type: costmap
height: 4
width: 4
max_obstacle_height: 0.6
max_obstacle_range: 2.5
obstacle_range: 4.0
publish_frequency: 2.0
update_frequency: 2.0
publish_voxel_map: false
raytrace_range: 4.0
resolution: 0.01
static_map: false
rolling_window: true
track_unknown_space: true
unknown_cost_value: 255
transform_tolerance: 2.0
robot_radius: 0.18
inflation_radius: 0.50
observation_sources: scan
scan: {data_type: LaserScan, topic: /scan, marking: true, clearing: true}
bump: {data_type: PointCloud2, topic: mobile_base/sensors/bumper_pointcloud, marking: true, clearing: false}
So this configuration is the same as I use for tuning the parameters for gmapping.
UPDATE
Ok I just found my mistake ... I entered a namespace in my launch file which was not correlating with my .yaml file! So now I just removed the namespace and entered the costmap's name (local_costmap:)at the beginning of the .yaml file before I set all parameters!
Now the costmap is correct and published. I use two yaml files for the local_costmap (as above) but also for the global_costmap. Here is the configuration for the global_costmap:
global_costmap:
global_frame: /map
robot_base_frame: /base_footprint
map_topic: map
map_type: costmap
height: 10
width: 10
max_obstacle_height: 0.6
max_obstacle_range: 2.5
obstacle_range: 4.0
publish_frequency: 1.0
update_frequency: 1.0
publish_voxel_map: false
raytrace_range: 4.0
resolution: 0.01
static_map: true
rolling_window: false
track_unknown_space: true
unknown_cost_value: 255
transform_tolerance: 2.0
robot_radius: 0.18
inflation_radius: 0.50
observation_sources: scan
scan: {data_type: LaserScan, topic: /scan, marking: true, clearing: true}
bump: {data_type: PointCloud2, topic: mobile_base/sensors/bumper_pointcloud, marking: true, clearing: false}
But now the map from gmapping is changing but the overlying costmap does not change, corresponding to changes in laserscan or map!?
I really appreciate every hint. Thanks
Daniel