用catrographer跑自己的数据集

用catrographer跑自己的数据集

1、更改demo_revo_lds.launch和revo_lds.lua

1.1 修改demo_revo_lds.launch

原本的demo_revo_lds.launch为

<launch>
  <param name="/use_sim_time" value="true" />

  <node name="cartographer_node" pkg="cartographer_ros"
      type="cartographer_node" args="
          -configuration_directory $(find cartographer_ros)/configuration_files
          -configuration_basename revo_lds.lua"
      output="screen">
    <remap from="scan" to="scan" />
  </node>

  <node name="cartographer_occupancy_grid_node" pkg="cartographer_ros"
      type="cartographer_occupancy_grid_node" args="-resolution 0.05" />

  <node name="rviz" pkg="rviz" type="rviz" required="true"
      args="-d $(find cartographer_ros)/configuration_files/demo_2d.rviz" />
  <node name="playbag" pkg="rosbag" type="play"
      args="--clock $(arg bag_filename)" />
</launch>

其中我们要修改的是

<remap from="scan" to="scan" />

将其改成我们自己的激光数据集里面的激光雷达发布的topic,我的为/sick_scan,因为我把这里改成

<remap from="scan" to="sick_scan" />

其他的都不动

1.1 修改revo_lds.lua

原来的代码有有一段代码为

  map_frame = "map",
  tracking_frame = "laser",
  published_frame = "laser",
  odom_frame = "odom",

将其进行修改,针对tracking_frame和published_frame,将他们改成自己的数据集里面的激光slam中激光topic的坐标名称
注意这里的坐标名称可以通过

rosrun rqt_tree rqt_tree

来进行查看,注意了必须和rqt_tree里面的一样才行,这里不是topic,还是topic的坐标名称

2、运行代码

运行代码

roslaunch cartographer_ros demo_revo_lds.launch

可以看到地图

3、保存地图

序列化保存其当前状态

rosservice call /write_state "{filename: '${HOME}/Downloads/mymap.pbstream'}"

将pbstream转换为pgm和yaml

rosrun cartographer_ros cartographer_pbstream_to_ros_map -map_filestem=${
     HOME}/Downloads/mymap -pbstream_filename=${
     HOME}/Downloads/mymap.pbstream -resolution=0.05

你可能感兴趣的:(cartographer)