本文旨在记录一下使用VLP16运行hdl_graph_slam实时建图的过程。
(1)按照官方教程安装hdl_graph_slam,附官方地址:https://github.com/koide3/hdl_graph_slam
(2)按照教程安装VLP16驱动,推荐教程:https://blog.csdn.net/Burannnn/article/details/125744682
(3)运行命令,发布雷达话题
roslaunch velodyne_pointcloud VLP16_points.launch
(4)运行 rostopic list 查看雷达话题是否发布成功。
(5)更改 hdl_graph_slam中的launch文件。hdl_graph_slam.launch
<?xml version="1.0"?>
<launch>
<!-- arguments -->
<arg name="nodelet_manager" default="velodyne_nodelet_manager" />
<arg name="enable_floor_detection" default="false" />
<arg name="enable_gps" default="false" />
<arg name="enable_imu_acc" default="false" />
<arg name="enable_imu_ori" default="false" />
<!-- hdl_graph_slam will publish its estimated pose from odom to base_link within the following structure -->
<!-- ***** map -> odom -> base_link -> velodyne ***** -->
<!-- these can be named in the following -->
<!-- topic for hdl to find velodyne points -->
<arg name="points_topic" default="/velodyne_points" />
<!-- what should the map frame be called -->
<arg name="map_frame_id" default="map" />
<!-- what should the base link frame be called -->
<arg name="base_link_frame_id" default="base_link" />
<!-- what should the odom frame be called -->
<arg name="lidar_odom_frame_id" default="odom" />
<!-- hdl_graph_slam will also publish an odom message -->
<!-- what should the topic be for odom messages published by hdl-graph-slam -->
<arg name="published_odom_topic" default="/odom" />
<!-- optional arguments -->
<arg name="enable_robot_odometry_init_guess" default="false" />
<arg name="robot_odom_frame_id" default="robot_odom" />
<!-- transformation between lidar and base_link -->
<node pkg="tf" type="static_transform_publisher" name="lidar2base_publisher" args="0 0 0 0 0 0 $(arg base_link_frame_id) velodyne 10" />
<!-- in case you use velodyne_driver, comment out the following line -->
<node pkg="nodelet" type="nodelet" name="$(arg nodelet_manager)" args="manager" output="screen"/>
<!-- prefiltering_nodelet -->
<node pkg="nodelet" type="nodelet" name="prefiltering_nodelet" args="load hdl_graph_slam/PrefilteringNodelet $(arg nodelet_manager)">
<remap from="/velodyne_points" to="$(arg points_topic)" />
<!-- in case base_link_frame is blank, mapping will be performed in the lidar frame -->
<param name="base_link_frame" value="$(arg base_link_frame_id)" />
<!-- distance filter -->
<param name="use_distance_filter" value="false" />
<param name="distance_near_thresh" value="0.1" />
<param name="distance_far_thresh" value="1000.0" />
<!-- NONE, VOXELGRID, or APPROX_VOXELGRID -->
<param name="downsample_method" value="VOXELGRID" />
将这里面的<node pkg="nodelet" type="nodelet" name="$(arg nodelet_manager)" args="manager" output="screen"/>这一行注释掉。
(6)终端运行 roslaunch hdl_graph_slam.launch
(7) 另外打开一个新终端运行 roscore
(8)再打开一个终端运行
roscd hdl_graph_slam/rviz
rviz -d hdl_graph_slam.rviz
OK,可以在rviz中看到雷达点云信息和地图了。