Ask Your Question
0

Saving geotiff map in hector_slam

asked 2018-08-22 03:04:17 -0500

TintinQuarantino gravatar image

updated 2018-08-22 03:25:42 -0500

Hey everyone

I'm currently working on a project that involves using hector slam with a lidar to map its surroundings. At the moment I have hector slam building maps really well so now I'm trying to save these maps every few seconds during the mapping process as geotiff files.

I'm running ROS Kinetic on a Raspberry Pi with Ubuntu Mate. I have created a directory called "hector_geotiff/maps" in my home directory in which to save these images. This directory is being referenced in the launch files below. While the mapping process is running I am using the command

 rostopic pub syscommand std_msgs/String "savegeotiff"

Doing this yields no error messages and gives the output "publishing and latching message. Press ctrl-C to terminate" This gives me the impression that its working and trying to save the files however there are no images appearing in the given directory.

I have attached my launch files for tutorial.launch, mapping_default.launch & geotiff_mapper.launch below as well as the output for rostopic list and rosnode list.

Tutorial.launch

<launch>

  <arg name="geotiff_map_file_path" default="~hector_geotiff/maps"/>

  <param name="/use_sim_time" value="false"/>

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

Geotiff_mapper.launch

<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="~hector_geotiff/maps"/>
  <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_path)" />
    <param name="geotiff_save_period" type="double" value="2" />
    <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>

Mapping_default.launch

<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 ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-08-23 01:06:09 -0500

TintinQuarantino gravatar image

Had a win today! To figure out my issue I downloaded the original hector slam package and ran it with a bag file to ensure that I was able to save geotiffs that way. I then compared the launch files for any discrepancies between the two. One other point is that I made a maps file in the hector_geotiff file within the actual catkin filepath (should have done that in the first place).

I think in the end my problem was that in my geotiff_mapper.launch file somehow I had the following line

<param name="map_file_base_name" type="string" value="$(arg map_file_path)" />

This meant that the geotiff node was trying to use the filepath as the filename for example ~/xxx/xxx/hector_geotiff/maps/xxx/xxx/hector_geotiff/maps

It worked exactly as expected after I changed the map_file_base_name parameter to the following

<param name="map_file_base_name" type="string" value="$(arg map_file_base_name)" />

Hope this helps anyone that may have made a similar silly mistake.

edit flag offensive delete link more

Comments

+1 for reporting back. Much appreciated.

gvdhoorn gravatar imagegvdhoorn ( 2018-08-23 01:26:20 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-08-22 03:04:17 -0500

Seen: 246 times

Last updated: Aug 23 '18