【ros】rplidar Hector Slam
想用rplidar跑一下hector slam,在网上发现了几个教程写的都不错,但是亲测发现都有点不足,综合了一下,进行补充。
1. 安装ros 和 创建工作空间
http://blog.csdn.net/u013453604/article/details/49386953
2. rplidar :
插上rplidar,看看在哪个usb口
ls /dev/ttyUSB*
更改usb权限
sudo chmod 666 /dev/ttyUSB0
看看rplidar 能否正常工作
cd catkin_ws souce devel/setup.bash roslaunch rplidar_ros view_rplidar.launch //开启另一个终端 cd catkin_ws souce devel/setup.bash roslaunch rplidar_ros rplidar.launch
3. hector slam
cd ~/catkin_ws/src git clone https://github.com/tu-darmstadt-ros-pkg/hector_slam cd ~/catkin_ws catkin_make
4. 测试 这步很重要啊,launch文件http://www.aichengxu.com/view/9857089
catkin_ws/rplidar_ros_master/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>
//运行下面两个launch
roslaunch rplidar_ros hector_mapping_demo.launch
roslaunch rplidar_ros rplidar.launch
拿着rplidar走走 就能看到 图出来了!
刚开启ros时候, 如果报错:roslaunch 不是命令,
$ cd catkin_ws
$ source devel/setup.bash