Robotics StackExchange | Archived questions

Hector_slam not working with my bag file

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 http://wiki.ros.org/sicktoolbox_wrapper/Tutorials/UsingTheSicklms:

$ sudo chmod a+rw /dev/ttyUSB0

$ ls -l /dev/ttyUSB0

$roscore

$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 http://wiki.ros.org/hector_slam/Tutorials/SettingUpForYourRobot

To do this, I copy pasted the following from the tutorial into the /home/akashan/catkinws/src/hectorslam/hectormapping/launch/mappingdefault.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 http://wiki.ros.org/hector_slam/Tutorials/MappingUsingLoggedData

1) $ rosrun tf statictransformpublisher 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 statictransformpublisher 0 0 0 0 0 0 base_footprint laser 10 (I did this becuase I was getting the error "lookupTransform basefootprint to laser timed out. Could not transform laser scan into baseframe." ). Please note that the error is not getting removed after doing this.

3) $ roslaunch hectorslamlaunch 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 hectorslam package (TeamHectorMappingBoxRoboCup2011Rescue_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 statictransformpublisher nodes in my mapping_default.launch. The following transforms were added.

node pkg="tf" type="statictransformpublisher" name="mapnavbroadcaster" args="0 0 0 0 0 0 map nav 20"

node pkg="tf" type="statictransformpublisher" name="mapscanmatcherbroadcaster" args="0 0 0 0 0 0 map scanmatcher_frame 25"

node pkg="tf" type="statictransformpublisher" name="navbaselinkbroadcaster" args="0 0 0 0 0 0 nav base_link 13"

node pkg="tf" type="statictransformpublisher" name="navbaseframebroadcaster" args="0 0 0 0 0 0 nav base_frame 13"

node pkg="tf" type="statictransformpublisher" name="navbasefootprintbroadcaster" args="0 0 0 0 0 0 nav base_footprint 13"

node pkg="tf" type="statictransformpublisher" name="baselinklaserbroadcaster" args="0 0 0 0 0 0 base_frame laser 100"

(Please note that the last transform that is baseframe to laser will be different for every person. For some people it will be baselink to laser, or it could be basefootprint to laser, depending upon your mappingdefault and tutorial launch files.

4) Added following to my mappingdefault inside hectormapping node: (apologies that the start and square brackets are missing because whenever I put them, my code becomes invisible)

param name="pubmapodom_transform" value="true"

param name="map_frame" value="map"

param name="baseframe" value="baseframe"

param name="odomframe" value="baseframe"

5) After doing the above steps I had expected to get the map, but it was not. Apparently, the static publishing nodes that I added to me launch file were not publishing any tf. After reading various forums I found that this problem can be resolved by doing source devel/setup.bash before calling roslaunch hectorslamlaunch tutorial.launch. Finally, please note that the map will be shown only when you play your bag file. Before that the error No TF data found will continue to come in RViz.

Regards,

Shantnu Kakkar

Asked by Shantnu on 2016-05-14 20:30:40 UTC

Comments

Answers

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: http://wiki.ros.org/hector_mapping) 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.

Asked by spmaniato on 2016-05-15 03:53:04 UTC

Comments

Hi,

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:

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

Asked by Shantnu on 2016-05-15 19:19:01 UTC

Comments

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

Asked by spmaniato on 2016-05-16 08:08:31 UTC

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?).

Asked by Shantnu on 2016-05-17 19:20:50 UTC

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". http://wiki.ros.org/hector_slam/Tutorials/SettingUpForYourRobot

Asked by Shantnu on 2016-05-17 19:22:55 UTC

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.

Asked by spmaniato on 2016-05-18 09:08:11 UTC

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.

Asked by Shantnu on 2016-05-18 20:08:01 UTC

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.

Asked by spmaniato on 2016-05-19 07:22:29 UTC

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

Asked by Shantnu on 2016-05-22 02:16:14 UTC

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]

topics:
/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

TF VIEW FRAMES

(https://drive.google.com/file/d/0BzXKYVn7g4oibElIT05VV0dmQmc/view)

I'm using a turtlebot with kinect

Asked by Rodrigo Sarmento on 2017-04-28 00:33:49 UTC

Comments