一、安装 Hector 算法
安装 Hector 算法的指令如下
sudo apt-get install ros-melodic-hector-slam
二、编写 Hector 算法的 launch 启动文件
在建图工作空间下建立 hector_slam.launch 的 launch 启动文件,launch文件配置如下
<launch>
<!-- 启动镭神01激光雷达 -->
<include file="$(find ls01d_lidar)/launch/ls01d_lidar.launch" />
<!-- 配置 hector 算法 -->
<node pkg="hector_mapping" type="hector_mapping" name="hector_mapping" output="screen">
<!-- Frame names -->
<param name="pub_map_odom_transform" value="true"/>
<param name="map_frame" value="map" />
<param name="base_frame" value="base_footprint" />
<param name="odom_frame" value="odom" />
<!-- Tf use -->
<param name="use_tf_scan_transformation" value="true"/>
<param name="use_tf_pose_start_estimate" value="false"/>
<!-- Map size / start point -->
<param name="map_resolution" value="0.05"/>
<param name="map_size" value="2048"/>
<param name="map_start_x" value="0.5"/>
<param name="map_start_y" value="0.5" />
<param name="laser_z_min_value" value = "-1.0" />
<param name="laser_z_max_value" value = "1.0" />
<param name="map_multi_res_levels" value="2" />
<param name="map_pub_period" value="2" />
<param name="laser_min_dist" value="0.4" />
<param name="laser_max_dist" value="5.5" />
<param name="output_timing" value="false" />
<param name="pub_map_scanmatch_transform" value="true" />
<!--<param name="tf_map_scanmatch_transform_frame_name" value="scanmatcher_frame" />-->
<!-- Map update parameters -->
<param name="update_factor_free" value="0.4"/>
<param name="update_factor_occupied" value="0.7" />
<param name="map_update_distance_thresh" value="0.2"/>
<param name="map_update_angle_thresh" value="0.06" />
<!-- Advertising config -->
<param name="advertise_map_service" value="true"/>
<param name="scan_subscriber_queue_size" value="5"/>
<param name="scan_topic" value="scan"/>
</node>
<node pkg="tf" type="static_transform_publisher" name="base_to_laser_broadcaster" args="0 0 0 0 0 0 /base_link /laser 100"/>
<node pkg="rviz" type="rviz" name="rviz"
args="-d $(find hector_slam_launch)/rviz_cfg/mapping_demo.rviz"/>
</launch>
三、启动 Hector 算法
在 catkin_ws 工作空间下,启动刚刚配置的 launch 文件以启动 hector 建图算法
souce ./devel/setep.bash
roslaunch navigation hecto_slam.launch
建图效果如下:
到此,使用 Hector 算法建图构建完成!!!
参考链接: 激光雷达初体验 - Ubuntu 18.04 + 思岚科技 RPLIDAR A1M8 + hector_slam 建图_rpilidar a1m8手册_银时大魔王的博客-CSDN博客