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

Hector SLAM and Hokuyo

asked 2014-08-25 15:26:36 -0500

Scout gravatar image

updated 2014-08-26 14:04:47 -0500

First, I am running Hydro and Ubuntu 12.04. I am trying to use Hector_SLAM with a Hokuyo to map a room and am having trouble. I start up the hokuyo_node first, and can view the details in rviz and can see the output using rostopic echo scan, so I know that the laser is working correctly.

My problem occurs when I try to use Hector_SLAM. I use the following launch file:

  <arg name="tf_map_scanmatch_transform_frame_name" default="scanmatcher_frame"/>
  <arg name="base_frame" default="base_link"/>
  <arg name="odom_frame" default="base_link"/>
  <arg name="pub_map_odom_transform" default="true"/>
  <arg name="scan_subscriber_queue_size" default="5"/>
  <arg name="scan_topic" default="scan"/>
  <arg name="map_size" default="2048"/>

  <node pkg="hector_mapping" type="hector_mapping" name="hector_mapping" output="screen">

    <!-- Frame names -->
    <param name="map_frame" value="map" />
    <param name="base_frame" value="$(arg base_frame)" />
    <param name="odom_frame" value="$(arg odom_frame)" />

    <!-- Tf use -->
    <param name="use_tf_scan_transformation" value="true"/>
    <param name="use_tf_pose_start_estimate" value="false"/>
    <param name="pub_map_odom_transform" value="$(arg pub_map_odom_transform)"/>

    <!-- Map size / start point -->
    <param name="map_resolution" value="0.050"/>
    <param name="map_size" value="$(arg map_size)"/>
    <param name="map_start_x" value="0.5"/>
    <param name="map_start_y" value="0.5" />
    <param name="map_multi_res_levels" value="2" />

    <!-- Map update parameters -->
    <param name="update_factor_free" value="0.4"/>
    <param name="update_factor_occupied" value="0.9" />    
    <param name="map_update_distance_thresh" value="0.4"/>
    <param name="map_update_angle_thresh" value="0.06" />
    <param name="laser_z_min_value" value = "-1.0" />
    <param name="laser_z_max_value" value = "1.0" />

    <!-- Advertising config --> 
    <param name="advertise_map_service" value="true"/>

    <param name="scan_subscriber_queue_size" value="$(arg scan_subscriber_queue_size)"/>
    <param name="scan_topic" value="$(arg scan_topic)"/>

    <!-- Debug parameters -->
      <param name="output_timing" value="false"/>
      <param name="pub_drawings" value="true"/>
      <param name="pub_debug_output" value="true"/>
    <param name="tf_map_scanmatch_transform_frame_name" value="$(arg tf_map_scanmatch_transform_frame_name)" />

    <!--<node pkg="tf" type="static_transform_publisher" name="map_nav_broadcaster" args="0 0 0 0 0 0 map nav 100"/>-->
    <node pkg="tf" type="static_transform_publisher" name="base_to_laser_broadcaster" args="0 0 0 0 0 0 base_link laser 50" />

I get the following:

[ INFO] [1408997382.797794953]: HectorSM p_base_frame_: base_link
[ INFO] [1408997382.797853226]: HectorSM p_map_frame_: map
[ INFO] [1408997382.797887666]: HectorSM p_odom_frame_: base_link
[ INFO] [1408997382.797907952]: HectorSM p_scan_topic_: scan
[ INFO] [1408997382.797930132]: HectorSM p_use_tf_scan_transformation_: true
[ INFO] [1408997382.797946615]: HectorSM p_pub_map_odom_transform_: true
[ INFO] [1408997382.797965530]: HectorSM p_scan_subscriber_queue_size_: 5
[ INFO] [1408997382.797989917]: HectorSM p_map_pub_period_: 1.000000
[ INFO] [1408997382.798009175]: HectorSM p_update_factor_free_: 0.400000
[ INFO] [1408997382.798025604]: HectorSM p_update_factor_occupied_: 0.900000
[ INFO] [1408997382.798042072]: HectorSM p_map_update_distance_threshold_: 0.400000 
[ INFO] [1408997382.798058143]: HectorSM p_map_update_angle_threshold_: 0.060000
[ INFO] [1408997382.798074831]: HectorSM p_laser_z_min_value_: -1.000000
[ INFO] [1408997382.798090826]: HectorSM p_laser_z_max_value_: 1.000000
[ INFO] [1408997383.622206911]: lookupTransform base_link to laser timed out. Could not transform laser scan into base_frame.

Thanks in advance for the assistance.


I ran rosrun tf tf_echo base_link laser and received the following:

At time 1409079191.956

  • Translation: [0.000, 0.000, 0.000]

  • Rotation: in Quaternion [0.000, 0.000, 0.000, 1.000] in RPY [0.000, -0.000, 0.000]

edit retag flag offensive close merge delete


Scout, I hope you got your code working. Could you possibly elaborate on how you got it working if thats the case? I am new to ROS and C++, so a little step by step turotial would be very much appreciated. Thank you!

kost9 gravatar image kost9  ( 2014-10-02 01:04:51 -0500 )edit

I changed the rate of the static transform from 50ms to 1ms. That seemed to correct my issue. I think that Stefan was actually working on a tutorial, but I don't know how far he has gotten on that.

Scout gravatar image Scout  ( 2014-10-02 09:23:48 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2014-08-26 02:32:38 -0500

This appears to be an issue with your tf tree, specifically no connection existing between the "base_link" and "laser" frames. The static transform publisher you appear to be starting should provide that transform, though.


rosrun tf tf_echo base_link laser

answer with a valid transform? (Please edit your original post with any additional info and do not post it as an answer)

edit flag offensive delete link more


Thanks for the response. I edited my initial post with the output.

Scout gravatar image Scout  ( 2014-08-26 14:05:26 -0500 )edit

Ok, so the transform appears to be there. The timestamp of the LaserScan is used in hector_mapping, so if that one is (far) off, this could explain things, too.

Stefan Kohlbrecher gravatar image Stefan Kohlbrecher  ( 2014-08-26 16:18:51 -0500 )edit

So I changed the rate from 50ms to 1ms and I get the same error about the transform, but now I can generate a map in rviz. The only issue now is that I can't save the map as a geotiff. I think that this may be a separate issue, but I wonder if it is related to the error I am getting.

Scout gravatar image Scout  ( 2014-08-29 11:05:54 -0500 )edit

Saw your post after coming across this one)

Have you tried:

<param name="/use_sim_time" value="true" />
nitekrawler gravatar image nitekrawler  ( 2014-10-21 18:47:00 -0500 )edit

Question Tools



Asked: 2014-08-25 15:26:36 -0500

Seen: 1,477 times

Last updated: Aug 26 '14