Robotics StackExchange | Archived questions

Trouble With Saving A Map With Hector SLAM

I am using ROS Hydro and Ubuntu 12.04. I am using the urgnode for my Hokuyo and trying to generate a map and then save. Below is the mappingdefault.launch file that I use to see the map being generated in rviz:

<launch>
  <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>

    <!--<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" />
</launch>

When I launch this file, I am able to watch the map in rviz while it is being generated. I want to be able to save the map as a geotiff file, so I started trying to get the tutorial.launch file to work, which is shown below:

<launch>
    <arg name="geotiff_map_file_path" default="~/Documents/robot"/>
    <param name="/use_sim_time" value="true"/>

    <node pkg="rviz" type="rviz" name="rviz" args="-d $(find hector_slam_launch)/rviz_cfg/mapping_demo.rviz"/>

    <include file="$(find hector_mapping)/launch/mapping_default.launch"/>

    <include file="$(find hector_geotiff)/launch/geotiff_mapper.launch">
    <arg name="trajectory_source_frame_name" value="scanmatcher_frame"/>
    <arg name="map_file_path" value="$(arg geotiff_map_file_path)"/> 
    </include>

</launch>

Below is the geotiff_mapper.launch file:

<launch>
    <arg name="trajectory_source_frame_name" default="scanmatcher_frame"/>
    <arg name="trajectory_update_rate" default="4"/>
    <arg name="trajectory_publish_rate" default="0.25"/>
    <arg name="map_file_path" default="~/Documents/robot"/>
    <arg name="map_file_base_name" default="hector_slam_map"/>

    <node pkg="hector_trajectory_server" type="hector_trajectory_server" name="hector_trajectory_server" output="screen">
    <param name="target_frame_name" type="string" value="/map" />
    <param name="source_frame_name" type="string" value="$(arg trajectory_source_frame_name)" />
    <param name="trajectory_update_rate" type="double" value="$(arg trajectory_update_rate)" />
    <param name="trajectory_publish_rate" type="double" value="$(arg trajectory_publish_rate)" />
    </node> 

    <node pkg="hector_geotiff" type="geotiff_node" name="hector_geotiff_node" output="screen" launch-prefix="nice -n 15">
    <remap from="map" to="/dynamic_map" />
    <param name="map_file_path" type="string" value="$(arg map_file_path)" />
    <param name="map_file_base_name" type="string" value="$(arg map_file_base_name)" />
    <param name="geotiff_save_period" type="double" value="45" />
    <param name="draw_background_checkerboard" type="bool" value="true" />
    <param name="draw_free_space_grid" type="bool" value="true" />
    <param name="plugins" type="string" value="hector_geotiff_plugins/TrajectoryMapWriter" />
    </node>

</launch>

Now when I run the tutorial.launch file I get the following error:

[ INFO] [1410373945.642160928]: HectorSM p_base_frame_: base_link
[ INFO] [1410373945.642310786]: HectorSM p_map_frame_: map
[ INFO] [1410373945.642385481]: HectorSM p_odom_frame_: base_link
[ INFO] [1410373945.642455767]: HectorSM p_scan_topic_: scan
[ INFO] [1410373945.642523916]: HectorSM p_use_tf_scan_transformation_: true
[ INFO] [1410373945.642591494]: HectorSM p_pub_map_odom_transform_: true
[ INFO] [1410373945.642658196]: HectorSM p_scan_subscriber_queue_size_: 5
[ INFO] [1410373945.642726362]: HectorSM p_map_pub_period_: 2.000000
[ INFO] [1410373945.643165592]: HectorSM p_update_factor_free_: 0.400000
[ INFO] [1410373945.643237005]: HectorSM p_update_factor_occupied_: 0.900000
[ INFO] [1410373945.643302828]: HectorSM p_map_update_distance_threshold_: 0.400000 
[ INFO] [1410373945.643369833]: HectorSM p_map_update_angle_threshold_: 0.060000
[ INFO] [1410373945.645806793]: HectorSM p_laser_z_min_value_: -1.000000
[ INFO] [1410373945.645884373]: HectorSM p_laser_z_max_value_: 1.000000
process[hector_trajectory_server-4]: started with pid [16995]
[ INFO] [1410373945.709468433]: Waiting for tf transform data between frames /map and scanmatcher_frame to become available
process[hector_geotiff_node-5]: started with pid [17018]
[ INFO] [1410373945.952153724]: Successfully initialized hector_geotiff MapWriter plugin TrajectoryMapWriter.
[ INFO] [1410373945.952283235]: Geotiff node started
[ WARN] [1410373965.711501839]: No transform between frames /map and scanmatcher_frame available after 20.002065 seconds of waiting. This warning only prints once.

I then tried adding a static transform publisher to my mapping_default.launch file so that the end looks like this:

<node pkg="tf" type="static_transform_publisher" name="base_to_laser_broadcaster" args="0 0 0 0 0 0 base_link laser 50" />

<node pkg="tf" type="static_transform_publisher" name="map_to_scanmatcher_frame_broadcaster" args="0 0 0 0 0 0 map scanmatcher_frame 50" />

And I get the same output, with the exception that the new static transform publisher is now running:

[ INFO] [1410374402.196002948]: HectorSM p_base_frame_: base_link
[ INFO] [1410374402.199598729]: HectorSM p_map_frame_: map
[ INFO] [1410374402.199680198]: HectorSM p_odom_frame_: base_link
[ INFO] [1410374402.199749295]: HectorSM p_scan_topic_: scan
[ INFO] [1410374402.199822257]: HectorSM p_use_tf_scan_transformation_: true
[ INFO] [1410374402.199889342]: HectorSM p_pub_map_odom_transform_: true
[ INFO] [1410374402.199954944]: HectorSM p_scan_subscriber_queue_size_: 5
[ INFO] [1410374402.200022965]: HectorSM p_map_pub_period_: 2.000000
[ INFO] [1410374402.200089510]: HectorSM p_update_factor_free_: 0.400000
[ INFO] [1410374402.200154072]: HectorSM p_update_factor_occupied_: 0.900000
[ INFO] [1410374402.200220502]: HectorSM p_map_update_distance_threshold_: 0.400000 
[ INFO] [1410374402.200286026]: HectorSM p_map_update_angle_threshold_: 0.060000
[ INFO] [1410374402.200350446]: HectorSM p_laser_z_min_value_: -1.000000
[ INFO] [1410374402.200413883]: HectorSM p_laser_z_max_value_: 1.000000
process[map_to_scanmatcher_frame_broadcaster-4]: started with pid [17830]
process[hector_trajectory_server-5]: started with pid [17843]
[ INFO] [1410374402.395814934]: Waiting for tf transform data between frames /map and scanmatcher_frame to become available process[hector_geotiff_node-6]: started with pid [17866]
[ INFO] [1410374402.626690285]: Successfully initialized hector_geotiff MapWriter plugin TrajectoryMapWriter.
[ INFO] [1410374402.626830806]: Geotiff node started
[ WARN] [1410374422.398711648]: No transform between frames /map and scanmatcher_frame available after 20.002872 seconds of waiting. This warning only prints once.

Any assistance would be greatly appreciated. Thank you.

Asked by Scout on 2014-09-10 13:45:18 UTC

Comments

What is you laserscan header frame_id ?

Asked by bvbdort on 2014-09-10 14:21:52 UTC

The frame_id for the topic scan is laser.

Asked by Scout on 2014-09-11 14:14:36 UTC

Hey! Did you get this to work? I would really appreciate if you could share your experience if you got this working Thanks

Asked by kost9 on 2014-10-03 06:57:57 UTC

There is no resolution posted here, so that would mean no, I did not get this to work.

Asked by Scout on 2014-10-03 10:23:25 UTC

Answers