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

Hector_slam not working with my bag file

asked 2016-05-14 20:30:40 -0500

Shantnu gravatar image

updated 2016-05-22 02:17:38 -0500

I am trying to do hector slam using lidar SICK LMS291-s05 , but I am unable to get map with the bag file generated by me. I can get the map with the bag file that comes with the hector slam library. Please note that I don't have any odometry data, but only LIDAR scan data. This is the procedure that I followed:

A) Generating the bag file containing laser scan data using tutorial

$ sudo chmod a+rw /dev/ttyUSB0

$ ls -l /dev/ttyUSB0


$rosrun sicktoolbox_wrapper sicklms _port:=/dev/ttyUSB0 _baud:=38400

$ rosbag record scan

(The bag file gets generated by the name 2016-05-10-05-20-45.bag)

B) Setting parameters for hector slam as explained in the tutorial

To do this, I copy pasted the following from the tutorial into the /home/akashan/catkin_ws/src/hector_slam/hector_mapping/launch/mapping_default.launch file.

<param name="pub_map_odom_transform" value="true"/>
<param name="map_frame" value="map" />
<param name="base_frame" value="base_frame" />
<param name="odom_frame" value="base_frame" />

(I am not sure whether I did the part B correctly. Please someone verify this whether I have copy pasted in the right launch file or not)

C) Running Hector SLAM in RVIZ as explained in the tutorial hector SLAM tutorial

1) $ rosrun tf static_transform_publisher 0 0 0 0 0 0 map scanmatcher_frame 10 (I did this becuase I was getting the warning "No transform between frames /map and scanmatcher_frame available after 20.002338 seconds of waiting. This warning only prints once."). Please note that the warning got removed.

2) rosrun tf static_transform_publisher 0 0 0 0 0 0 base_footprint laser 10 (I did this becuase I was getting the error "lookupTransform base_footprint to laser timed out. Could not transform laser scan into base_frame." ). Please note that the error is not getting removed after doing this.

3) $ roslaunch hector_slam_launch tutorial.launch

4) $ rosbag play 2016-05-10-05-20-45.bag --clock

Please someone help me.

========================================================================================= Edit: The above was my question. Now, I have been able to run hector slam properly. This is what I did to get my hector slam working:

1) Played the bag file that comes with the hector_slam package (Team_Hector_MappingBox_RoboCup_2011_Rescue_Arena.bag). My hector slam used to work with this file, but not with my own bag file since the bag file I was generating didn't have any tf.

2) called view_frames to view what frames does this file publish. (sorry I can't post this pdf since it always give error that 5 points are required).

3) Based on the generated frames.pdf file, I added 6 static_transform_publisher nodes in my mapping_default.launch. The following transforms were added.

node pkg="tf" type="static_transform_publisher" name="map_nav_broadcaster" args="0 0 0 0 0 0 map nav 20"

node pkg="tf" type="static_transform_publisher" name="map_scanmatcher_broadcaster" args="0 0 0 0 0 0 map scanmatcher_frame 25"

node pkg="tf" type="static_transform_publisher" name="nav_baselink_broadcaster" args="0 0 0 0 0 0 nav base_link 13"

node pkg="tf ... (more)

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2016-05-15 03:53:04 -0500

spmaniato gravatar image

updated 2016-05-15 03:55:59 -0500

My guess is that your bagfile is missing the tf messages that describe the transform between the robot's frame (base_frame ) and the LiDAR's frame (see "Required tf transforms" here: ) It sounds like this transform is not only static but also the identity in your case. So just have a static_transform_publisher handle this base_frame to LiDAR frame identity transform.

You most definitely DON'T need that map-to-my_frame static_transform_publisher. The SLAM node is responsible for publishing the map to odom transform.

edit flag offensive delete link more

answered 2016-05-15 19:19:01 -0500

Shantnu gravatar image


Thank you for your response. I tried getting the map with the update you suggested but still I am not getting the map.

You are correct that my bagfile does not have any tf messages (its because I am only using LIDAR). So, to overcome this, I tried using static_transform_publisher identity as follows in my mapping_default.launch file:

<node pkg="tf" type="static_transform_publisher" name="baseFrame_to_laser_broadcaster" args="0 0 0 0 0 0 base_frame laser 10"/>

However, I am getting the error: "lookupTransform base_footprint to laser timed out. Could not transform laser scan into base_frame." in the terminal in which I am running roslaunch hector_slam_launch tutorial.launch.

Also, in my RViz I am getting the error: "No tf data. Actual error: Fixed Frame [map] does not exist."

I have removed the "rosrun tf static_transform_publisher 0.0 0.0 0.0 0 0 0 1 map my_frame 100" as suggested by you.

Please direct me what else is needed to be changed?

Regards, Shantnu Kakkar

edit flag offensive delete link more



First of all, please don't use an answer to continue the conversation. Instead, comment below my answer and/or edit the original question. Second, where did base_footprint come from? (It shows up in your error message.) Please run everything and then do rosrun tf view_frames Then post the output

spmaniato gravatar image spmaniato  ( 2016-05-16 08:08:31 -0500 )edit

I will take care next time. I have added two new steps in the question now (they are step 1 and step 2 in step C and I have bold them). Please tell me how should I upload the screen shot of frames.pdf. When I try to upload, it gives me the error that I need 5 points to upload. (May I mail you?).

Shantnu gravatar image Shantnu  ( 2016-05-17 19:20:50 -0500 )edit

The base_footprint is coming because of step B that I am doing (seee my question). The tutorial asks us to do that. See tutorial option set up 2 "Use without odom frame".

Shantnu gravatar image Shantnu  ( 2016-05-17 19:22:55 -0500 )edit

Hmm, still not sure why there's a base_footprint. Maybe step B didn't work properly. Or maybe you just need a static transform between base_footprint and base_frame. Remove C1 and C2. I gave you some points. Please upload the tf tree.

spmaniato gravatar image spmaniato  ( 2016-05-18 09:08:11 -0500 )edit

If I omit points C1 and C2 and do view_frames, then I get only one message in the pdf: No TF data recieved. Could you please tell me procedure that you would follow if you do hector mapping with a bag file that has only /scan messages taken from a laser, and the laser frame and robot frame are same.

Shantnu gravatar image Shantnu  ( 2016-05-18 20:08:01 -0500 )edit

As I said in my original answer below, you do need to run (at least) one static_transform_publisher, the transform from base_frame to laser_frame (these may not be the correct names for your setup). That's similar to C2, but for the correct base frame. Not sure I'm getting the names right.

spmaniato gravatar image spmaniato  ( 2016-05-19 07:22:29 -0500 )edit

I have been able to resolve my problems. See my edit in question above. Thank you for your help.

Shantnu gravatar image Shantnu  ( 2016-05-22 02:16:14 -0500 )edit

answered 2017-04-28 00:33:49 -0500

Please Shantnu, could you help me?

When I try to generate a map with my bag using hector_slam i get this message "[ INFO] [1493355975.573671943, 1492808791.921291071]:LookupTransform base_link to /camera_depth_frame timed out. Could not transform laser scan into base_frame." And I don't know if thats the reason why i have this problem "SearchDir angle change too large".

Here is the info of my bag

path: 20170421turtle1.bag

version: 2.0

duration: 4:21s (261s)

start: Apr 21 2017 18:06:31.10 (1492808791.10)

end: Apr 21 2017 18:10:52.82 (1492809052.82)

size: 1.3 GB

messages: 24699

compression: none [1254/1254 chunks]

types: sensor_msgs/Image [060021388200f6f0f447d0fcd9c64743]

sensor_msgs/LaserScan [90c7ef2dc6895d81024acba2ac42f369]

tf2_msgs/TFMessage [94810edda583a504dfda3829e70d7eec]

/camera/depth_registered/image 536 msgs : sensor_msgs/Image

/scan 7822 msgs : sensor_msgs/LaserScan

/tf 15624 msgs : tf2_msgs/TFMessage
(2 connections)

camera/rgb/image_color 717 msgs : sensor_msgs/Image


( )

I'm using a turtlebot with kinect

edit flag offensive delete link more

Question Tools



Asked: 2016-05-14 20:30:40 -0500

Seen: 6,730 times

Last updated: May 22 '16