1、创建工作空间及安装编译rplidar包
参考[ROS学习笔记]ROS中使用激光雷达(RPLIDAR)步骤1,链接为:
http://blog.csdn.net/sdhjqhjq1/article/details/79143498
2、hector_mapping包安装
sudo apt-get install ros-indigo-hector-slam
3、创建launch文件
在rplidar_ros/launch/目录下添加hector_mapping_demo.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>
4、运行测试
运行前查看端口号、给予端口权限
lsusb
sudo chmod a+rw /dev/ttyUSB0
运行下列两个launch文件
roslaunch rplidar_ros hector_mapping_demo.launch
roslaunch rplidar_ros rplidar.launch即可得出雷达在扫描周围环境
参考:https://github.com/robopeak/rplidar_ros/wiki
下一笔记篇写移动机器人自主导航