参考网址:
思岚A1激光雷达hector_mapping建图与定位_欧俊岑的博客-CSDN博客
tx2+r2000激光雷达 hector建图_大家安静啊的博客-CSDN博客
hectorslam之EAI雷达(ydlidar_x2l)配置过程_sunshine-CSDN博客
NickL77/RPLidar_Hector_SLAM: Hector SLAM without odometry data on ROS with the RPLidar A1 (github.com)
简介
hector是纯粹基于laserscan数据的算法,只需要提供scan数据即可,这里使用r2000做实验.因此第一步应该发布scan数据.
Scan激光数据发布
r2000提供了ros发布的驱动文件,因此只需要修改些配置即可.
驱动网址:
dillenberger/pepperl_fuchs: Pepperl+Fuchs R2000 Driver (github.com)
修改一下配置:
1 2 3 4 5 6 7 8 9 10 11 12
| <?xml version="1.0"?> <launch> <node pkg="pepperl_fuchs_r2000" type="r2000_node" name="r2000_driver_node" output="screen"> <param name="scanner_ip" value="192.168.1.19"/> <param name="frame_id" value="laser_link"/> <param name="scan_frequency" value="35"/> <param name="samples_per_scan" value="3600"/> </node>
</launch>
|
1 2 3 4 5 6 7
| scanner_ip r2000的配置激光ip地址 frame_id 发布出去的框架id(用于tf转换) scan_frequency 扫描频率 samples_per_scan 每圈的扫描数 # 值得注意的是这里r2000发不出去的scan节点为/r2000_driver_node/scan # 可以通过remap重定义为/scan 最后通过rviz显示
|
ros执行命令:
1
| roslaunch pepperl_fuchs_r2000 gui_example.launch
|
使用hector_mapping建图并定位
这里可以直接在系统中安装hector,并新建hector_mapping.launch
文件,指令如下:
1 2 3 4 5
| sudo apt-get install ros-melodic-hector-slam cd catkin_ws/src catkin_create_pkg run_launch # 因为内部都是launch文件并不需要依赖包 cd run_launch && sudo mkdir launch && cd launch sudo nano hector_mapping.launch
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| <launch>
<node pkg="hector_mapping" type="hector_mapping" name="hector_mapping" output="screen"> <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" />
<param name="use_tf_scan_transformation" value="true"/> <param name="use_tf_pose_start_estimate" value="false"/>
<param name="map_resolution" value="0.05"/> <param name="map_size" value="512"/> <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="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" />
<param name="advertise_map_service" value="true"/> <param name="scan_subscriber_queue_size" value="5"/> <param name="scan_topic" value="/r2000_driver_node/scan"/> </node>
<node pkg="tf" type="static_transform_publisher" name="base_to_laser_broadcaster" args="0 0 0.105 0 0 0 /base_link /laser_link 100"/>_ <node pkg="rviz" type="rviz" name="rviz" args="-d $(find hector_slam_launch)/rviz_cfg/mapping_demo.rviz"/> </launch>
|
执行步骤:
1 2 3 4
| # 发布scan数据 roslaunch pepperl_fuchs_r2000 gui_example.launch # 启动hector_mapping roslaunch run_launch hector_mapping.launch
|
一些图片
总结
1.订阅/scan不要出错
2.tf转换尤为需要注意,map->base_link->laser_link
3.激光距离与地图大小需要注意一下,这里设不好容易崩