Unstable map on conversion of Turtlebot2 from gmapping to hector_slam

asked 2019-11-20 15:16:39 -0600

teddybouch gravatar image

I have the basic Turtlebot tutorials (http://learn.turtlebot.com) running successfully on my Turtlebot2, but now I'm trying to move from the default gmapping solution to hector_slam for mapping. The documentation at http://wiki.ros.org/hector_slam/Tutor... made it seem like the only thing that was needed to move from gmapping to hector_mapping was to make sure that the four parameters listed matched the values that they had in gmapping; this was a little bit of a challenge in my case because the gmapping configuration didn't have a map_frame parameter, but the default of "map" seems right. I switched my launch file to call the default launch file for hector_mapping rather than the one for gmapping, made sure that the other parameters were set as specified, and ran it.

The solution runs and appears to have the correct tf tree and connections, but as soon as I try to teleoperate the vehicle to build a map the estimate of the robot's position starts jumping all over the place. The problem seems to be with the calculation of the transform from map to odom and I'm assuming has something to do with an incomplete configuration on my part, but after searching through documentation and help forums I can't seem to figure out where this might have happened in the changes I made or how to set it right. For now, I'm including the two launch files in this post because I'm not sure whether anything else is relevant, but I can happily provide other files if needed. Can anyone point me in the direction of a solution?

Both of the launch files are run in the context of already running the bringup script of the turtlebot, which starts the mobile_base, diagnostic_aggregator, robot_state_publisher, and other nodes necessary for interacting with the kobuki base. This second script is responsible for running the camera control nodes, safety controller, move_base, and the mapping. I've confirmed that the list of active ROS nodes after running both scripts is the same excepting that the first runs slam_gmapping and the second runs hector_mapping. This is the gmapping version of the launch file:

  <!-- 3D sensor -->
  <arg name="3d_sensor" default="$(env TURTLEBOT_3D_SENSOR)"/>  <!-- r200, kinect, asus_xtion_pro -->
  <include file="$(find turtlebot_bringup)/launch/3dsensor.launch">
    <arg name="rgb_processing" value="false" />
    <arg name="depth_registration" value="false" />
    <arg name="depth_processing" value="false" />

    <!-- We must specify an absolute topic name because if not it will be prefixed by "$(arg camera)".
          Probably is a bug in the nodelet manager: https://github.com/ros/nodelet_core/issues/7 --> 
    <arg name="scan_topic" value="/scan" />

  <!-- Gmapping -->
  <arg name="custom_gmapping_launch_file" default="$(find turtlebot_navigation)/launch/includes/gmapping/$(arg 3d_sensor)_gmapping.launch.xml"/>
  <include file="$(arg custom_gmapping_launch_file)"/>

  <!-- Move base -->
  <include file="$(find turtlebot_navigation)/launch/includes/move_base.launch.xml"/>


And this is the hector_mapping version of the launch file:

  < ...
edit retag flag offensive close merge delete


After poking around some more, the issue seems to be the map->odom transformation being posted by hector_mapping. As soon as the robot moves the values start going all over the place. I'm assuming that this is some kind of configuration error, but since I'm using the default launch script that comes with hector_mapping and gmapping worked just fine, I'm having trouble identifying where the issue might be...

teddybouch gravatar image teddybouch  ( 2019-11-21 09:15:47 -0600 )edit

Okay - making progress. I ran another test just to see whether I could notice anything, and I realized that the local map seems to be building just fine, but is moving around on top of the global map seemingly totally independent of it. This is only an issue when I'm using hector, not with gmapping - is there some difference between the two in how they handle those two maps?

teddybouch gravatar image teddybouch  ( 2019-11-21 09:31:49 -0600 )edit

Any updates on this?

rezenders gravatar image rezenders  ( 2021-05-10 11:14:47 -0600 )edit