1. Hector Slam的下载安装:
cd catkin_ws2/src/
git clone https://github.com/tu-darmstadt-ros-pkg/hector_slam.git
cd ..
catkin_make
2.下载测试数据(bag 数据)可能需要VPN
wget http://tu-darmstadt-ros-pkg.googlecode.com/files/Team_Hector_MappingBox_RoboCup_2011_Rescue_Arena.bag
3. 使用rosbag 重放bag 数据,并启用hector mapping 建图
rosbag play Team_Hector_MappingBox_RoboCup_2011_Rescue_Arena.bag --clock
roslaunch hector_slam_launch tutorial.launch
4. 对bag数据进行处理,因为我们将来的小车上没有里程计信息,只有laser, 因此假设只有/scan 这个topic 的数据。因此需要把当前这个bag 数据进行过滤,过滤出/scan 这个topic 的数据。
rosbag filter Team_Hector_MappingBox_RoboCup_2011_Rescue_Arena.bag Team_Hector_MappingBox_RoboCup_2011_Rescue_Arena_scan.bag 'topic== "/scan"'
5. 只用 /scan 数据, 就不能提供/tf 信息, 因此我们需要把启动hector mapping 这个node 的参数改一改。
要修改的文件:hector_slam/mapping_default.launch
<param name="odom_frame" value="$(arg odom_frame)" /> --------original
<param name="odom_frame" value="$(arg base_frame)" /> ---------modifed
<param name="use_tf_scan_transformation" value="true"/> ------original
<param name="use_tf_scan_transformation" value="false"/> ------modifed
6. 然后再运hector_mapping 建图
rosbag play Team_Hector_MappingBox_RoboCup_2011_Rescue_Arena_scan.bag --clock
Team_Hector_MappingBox_RoboCup_2011_Rescue_Arena_scan.bag
观察所建的map 与有tf 的差不多,没有多少误差。
7. rqt_graph 查看topic 之间的关系: