ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Can I use costmap_2d as a standalone node, without using the navigation stack?

asked 2019-04-04 17:09:39 -0500

updated 2019-04-04 20:57:47 -0500


I have some point cloud data and would like to construct a costmap for navigation purposes. I couldn't find any tutorial on costmaps specifically, most tutorials are often about using costmap with the navigation stack. Here is my attempt to run the costmap node as a standalone node.

My .yaml file

global_frame: map
robot_base_frame: zed_camera_center
transform_tolerance: 0.2
robot_radius: 0.6

update_frequency: 5.0
publish_frequency: 2.0
rolling_window: true
static_map: false

width: 100
height: 100
resolution: 0.05

obstacle_range: 5.5
raytrace_range: 8.0

footprint: [[ 0.6096,  1.1684], [-0.6096,  1.1684], [-0.6096, -1.1684], [ 0.6096, -1.1684]]
footprint_padding: 0.10

observation_sources: point_cloud_sensor

point_cloud_sensor: {sensor_frame: zed_camera_center, data_type: PointCloud2, topic: 
/zed/point_cloud/cloud_registered, marking: true, clearing: true}

And here is my launch file.

<node name="costmap_node" pkg="costmap_2d" type="costmap_2d_node" >
    <rosparam file="$(find path_planning)/params/costmap_params.yaml" command="load" ns="local_costmap" />

Here is the terminal output when I run the launch file

neil@neil:~/Workspace/self-driving-golf-cart/ros$ roslaunch path_planning navigation.launch 
... logging to /home/neil/.ros/log/2e1eac9e-5744-11e9-8f6a-bcec23c374bf/roslaunch-neil-15292.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://neil:33545/


 * /costmap_node/local_costmap/footprint: [[0.6096, 1.1684]...
 * /costmap_node/local_costmap/footprint_padding: 0.1
 * /costmap_node/local_costmap/global_frame: map
 * /costmap_node/local_costmap/height: 100
 * /costmap_node/local_costmap/observation_sources: point_cloud_sensor
 * /costmap_node/local_costmap/obstacle_range: 5.5
 * /costmap_node/local_costmap/point_cloud_sensor/clearing: True
 * /costmap_node/local_costmap/point_cloud_sensor/data_type: PointCloud2
 * /costmap_node/local_costmap/point_cloud_sensor/marking: True
 * /costmap_node/local_costmap/point_cloud_sensor/sensor_frame: zed_camera_center
 * /costmap_node/local_costmap/point_cloud_sensor/topic: /zed/point_cloud/...
 * /costmap_node/local_costmap/publish_frequency: 2.0
 * /costmap_node/local_costmap/raytrace_range: 8.0
 * /costmap_node/local_costmap/resolution: 0.05
 * /costmap_node/local_costmap/robot_base_frame: zed_camera_center
 * /costmap_node/local_costmap/robot_radius: 0.6
 * /costmap_node/local_costmap/rolling_window: True
 * /costmap_node/local_costmap/static_map: False
 * /costmap_node/local_costmap/transform_tolerance: 0.2
 * /costmap_node/local_costmap/update_frequency: 5.0
 * /costmap_node/local_costmap/width: 100
 * /rosdistro: melodic
 * /rosversion: 1.14.3

    costmap_node (costmap_2d/costmap_2d_node)

auto-starting new master
process[master]: started with pid [15303]

setting /run_id to 2e1eac9e-5744-11e9-8f6a-bcec23c374bf
process[rosout-1]: started with pid [15317]
started core service [/rosout]
process[costmap_node-2]: started with pid [15324]

When I run rostopic list, none of the costmap topics shows up. I am wondering what I am doing wrong. Thank you very much! Sorry that I am very new to navigation with ROS.



edit retag flag offensive close merge delete


"static_map: false"

Also, can you add output from terminal.

billy gravatar image billy  ( 2019-04-04 19:22:02 -0500 )edit

I added that line to the yaml file. Unfortunately, it didn't work. Nothing changed. I added the terminal output. ROS didn't throw me any warnings or errors.

NNie2019 gravatar image NNie2019  ( 2019-04-04 20:45:30 -0500 )edit

I tried adding that to the yaml file. Unfortunately, it didn't work.

What do you mean? You couldn't copy and paste it?

jayess gravatar image jayess  ( 2019-04-04 20:51:10 -0500 )edit

"When I run rostopic list, none of the costmap topics show up". What's the output you get for rosnode info costmap_node ?

janindu gravatar image janindu  ( 2019-04-04 22:01:00 -0500 )edit

This is the output when I ran rosnode info costmap_node

Node [/costmap_node]
 * /rosout [rosgraph_msgs/Log]

 * /tf [tf2_msgs/TFMessage]
 * /tf_static [tf2_msgs/TFMessage]

 * /costmap_node/get_loggers
 * /costmap_node/set_logger_level

contacting node http://neil:43633/ ...
Pid: 24123
 * topic: /rosout
    * to: /rosout
    * direction: outbound
    * transport: TCPROS
 * topic: /tf
    * to: /play_1554464258893539779 (http://neil:38919/)
    * direction: inbound
    * transport: TCPROS
 * topic: /tf_static
    * to: /play_1554464258893539779 (http://neil:38919/)
    * direction: inbound
    * transport: TCPROS
NNie2019 gravatar image NNie2019  ( 2019-04-05 06:38:47 -0500 )edit

Hello @NNie2019: Were you able to figure out how to run the costmap_2d node standalone? Executing $ rosnode info costmap_node yields the same for me as for you - i.e., no costmap topics being published.

sgarciav gravatar image sgarciav  ( 2021-04-05 09:11:20 -0500 )edit

You are not publishing the transform between the global_frame and robot_base_frame.

skpro19 gravatar image skpro19  ( 2021-04-07 15:53:00 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2021-04-07 07:42:39 -0500

sgarciav gravatar image

updated 2021-04-07 16:30:22 -0500


I know you asked your question back in 2019, but I recently ran into the same problem and may have an answer for those who might run into it as well.

First, your launch file is correct for loading the costmap_2d node in standalone mode. I'd recommend you make sure that the messages are printed to the terminal for easier debugging by adding the ... output="screen" /> tag in the node call.

Now, since you're not specifying any plugins in your params yaml file, you should see a message printed out to your terminal stating that no plugins were specified and that some pre-Hydro parameters will be loaded. Something similar to this:

[ WARN] [1617798485.487554072, 1613598132.219868821]: costmap: Parameter "plugins" not provided, loading pre-Hydro parameters

[ INFO] [1617798485.493183425, 1613598132.219868821]: costmap: Using plugin "obstacle_layer"

[ INFO] [1617798485.515048394, 1613598132.240097096]:     Subscribed to Topics: 

[ INFO] [1617798485.523665166, 1613598132.250172045]: costmap: Using plugin "inflation_layer"

Since you're not seeing this message, it probably means that the node is waiting for the tf transform between your global frame and your robot base frame - map and zed_camera_center, respectively according to your parameter yaml file.

Make sure that the \tf topic is being published with this transform and you should see the costmap node start doing things. Namely, the first thing you should see is that plugin message like I mentioned above.

If it turns out that you're having a different issue, I recommend that you build the navigation stack from source and add print statements to the costmap node files to see where it might be failing you.

Good luck!

edit flag offensive delete link more

answered 2021-09-10 11:38:01 -0500

SIRB_Yan gravatar image

Hi,friend. l meet this problem, too. accidently l tried this and it worked. Firstly, l written a launch file (just contain the map_server and <rosparm> group [!!!without costmap_node])

<node name="static_tf0" pkg="tf" type="static_transform_publisher" args="2 0 0 0 0 0 /map_static /robot0 100"/>
<node name="map_server" pkg="map_server" type="map_server" args="$(find turtle_lab)/map/testmap.yaml"/>
<rosparam file="$(find my_costmap)/launch/minimal.yaml" command="load" ns="/costmap_node/costmap" />

Then, roslaunch the xxx.launch l created.

roslaunch my_costmap cost2d.launch

Finally, The key is that then l just continue rosrun the "costmap_node" in other terminal. the screen output the map loading, and rviz show the costmap choose.

rosrun costmap_2d costmap_2d_node

l think it's caused by the "namespace". l find may be it's hard to correctly apply the params into the costmap_node

edit flag offensive delete link more

Question Tools



Asked: 2019-04-04 17:09:39 -0500

Seen: 861 times

Last updated: Sep 10 '21