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

How to publish tf topic for slam_gmapping?

asked 2019-10-03 04:36:56 -0500

wallybeam gravatar image

updated 2022-01-22 16:10:05 -0500

Evgeny gravatar image

System Ubuntu 18.04 ROS Melodic

I am trying to create a 2D map by using Hokuyo LIDAR. I managed to record LIDAR data by following urg_node tutorial then I followed slam_gmapping tutorial. I created my own bag file but I couldn't make a map. I saw "waiting for the map" error and it keeps waiting.

While searching for possible solutions I saw that in the slam_gmapping tutorial rosbag tries to record tf topic but I am not publishing it. So how can I publish it?

Here are the steps I followed:

  1. roscore
  2. rosrun urg_node urg_node _ip_address:=
  3. rosbag record -O mylaserdata /scan /tf

After I record completed I close all terminals then I follow these steps:

  1. rosmake gmapping
  2. roscore
  3. rosparam set use_sim_time true
  4. rosrun gmapping slam_gmapping scan:=scan
  5. rosbag play --clock mylaserdata.bag
  6. rosrun map_server map_saver

Here is result when I use rosbag info mylaserdata.bag:

path:        mylaserdata.bag
version:     2.0
duration:    53.2s
start:       Oct 03 2019 10:15:58.93 (1570086958.93)
end:         Oct 03 2019 10:16:52.13 (1570087012.13)
size:        15.3 MB
messages:    1827
compression: none [21/21 chunks]
types:       sensor_msgs/LaserScan [90c7ef2dc6895d81024acba2ac42f369]
topics:      /scan   1827 msgs    : sensor_msgs/LaserScan

I downloaded a bag file from tutorial and here is the info of it:

path:        basic_localization_stage.bag
version:     2.0
duration:    35.5s
start:       Jan 01 1970 02:02:04.63 (124.63)
end:         Jan 01 1970 02:02:40.10 (160.10)
size:        462.6 KB
messages:    3617
compression: none [1/1 chunks]
types:       rosgraph_msgs/Clock   [a9c97c1d230cfc112e270351a944ee47]
             rosgraph_msgs/Log     [acffd30cd6b6de30f120938c17c593fb]
             sensor_msgs/LaserScan [90c7ef2dc6895d81024acba2ac42f369]
             tf/tfMessage          [94810edda583a504dfda3829e70d7eec]
topics:      /base_scan      24 msgs    : sensor_msgs/LaserScan
             /clock        3515 msgs    : rosgraph_msgs/Clock  
             /rosout          2 msgs    : rosgraph_msgs/Log    
             /rosout_agg      2 msgs    : rosgraph_msgs/Log    
             /tf             74 msgs    : tf/tfMessage
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-10-04 02:36:04 -0500

Delb gravatar image

From the tutorial Making your own bag where you found the rosbag record command, you might have overlooked this :

  1. Bring up your robot, with laser scans and transform data published

You are only using urg_node so you only initialize the laser scans, you have ommited the transform and you have to use other nodes to create them. That would be robot_state_publisher using the URDF of the lidar.

edit flag offensive delete link more

Question Tools


Asked: 2019-10-03 04:36:56 -0500

Seen: 354 times

Last updated: Oct 04 '19