SLAM学习----使用rplidar运行Hector算法
前言
雷达运行成功,便可跑算法了,于是我就从基本的Hector算法开始,通过参考各位大神的博客,经过多次报错终于成功了。(菜是原罪)
Basic Support:
- Linux Ubuntu 16.04操作系统
- ROS Kinetic
- 安装了rplidar的驱动
理论简介:
Hector:
Hector整体算法很直接,就是将激光点与已有的地图“对齐”,即扫描匹配。扫描匹配就是使用当前帧与已经有的地图数据构建误差函数,使用高斯牛顿法得到最优解和偏差量。其工作是实现激光点到栅格地图的转换,t时刻所有的激光点都能变换到栅格地图中,也就意味着匹配成功。
优点:
对硬件要求低,相反 cartographer高 不需要里程计信息(不需要将雷达的坐标绑定到某个固定坐标系比如base_link) 可以结合IMU数据使用
没有闭环检测部分,精确度高。
可以适应空中或者地面不平坦的情况
缺点:
不需要里程计,但对于雷达帧率要求很高40Hz,估计6自由度位姿。初值的选择对结果影响很大,所以要求雷达帧率较高。
Hector_SLAM包
整个包包含的节点有
hector_pose_estimation 将sensor的值转换成imu咨询丟給tf处理。
hector_mapping 不断地即時更新map,並publish, slam node
hector_map_server 储存并画出map形状,提供查詢位置(pose)服务。
hector_trajectory_server 存储 tf based trajectories.
hector_geotiff 以geotiff images files 存储 map 和 robot trajectory
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-RDeHY36J-1644065587767)(C:\Users\SKYWALKER\Pictures\20180523141902317.png)]
Subscribed topics
scan (sensor_msgs/LaserScan)
#The laser scan used by the SLAM system.
syscommand (std_msgs/String)
#System command. If the string equals "reset" the map and robot pose are reset to their inital state.
Published Topics
map_metadata (nav_msgs/MapMetaData)
#Get the map data from this topic, which is latched, and updated periodically.
map (nav_msgs/OccupancyGrid)
#Get the map data from this topic, which is latched, and updated periodically
slam_out_pose (geometry_msgs/PoseStamped)
#The estimated robot pose without covariance
poseupdate (geometry_msgs/PoseWithCovarianceStamped)
#The estimated robot pose with an gaussian estimate of uncertainty
Service
dynamic_map (nav_msgs/GetMap)
#Call this service to get the map data
dynamic_map (nav_msgs/GetMap)
#Call this service to get the map data
上手实践:
一 .安装hector_slam库
sudo apt-get install ros-kinetic-hector-slam
二.在原先的rplidar_ros/launch文件加中创建slam_launch文件
文件内容如下:
<launch>
<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_link" />
<param name="odom_frame" value="base_link" />
<!-- 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>
保存并退出
三.连接雷达
i.记得勾选
ii.设置端口权限
sudo chmod 666 /dev/ttyUSB0
四.编译环境变量
在rplidar_ros的工作文件夹中打开终端(如图为/dev/catkin_ws文件夹中)输入:
source devel/setup.bash
五运行雷达并查看建图
i启动雷达
在原先终端输入
roslaunch rplidar_ros rplidar.launch
ii.通过reviz查看
另起终端先编译环境变量再输入
roslaunch rplidar_ros rplidar.launch
ii.通过reviz查看
另起终端先编译环境变量在输入
roslaunch rplidar_ros slam.launch
如图所示
大功告成(估计是没有imu加手持拿着走会位置飘来飘去)
|