思岚 rplidarA2 ROS 安装编译
环境:ubuntu16.04 , ROS kinetic
1.在 github 中下载关于 ros 的 SDK ,下载到工作空间中的 /src 文件夹中
git clone https://github.com/Slamtec/rplidar_ros.git
2.catkin_make编译
catkin_make
3.在工作空间目录下添加环境变量
source devel/setup.bash
4.为USB接口添加可执行权限
sudo chmod 777 /dev/ttyUSB0
5.启动launch文件,即可在rviz中看到激光雷达扫描点的数据
roslaunch rplidar_ros view_rplidar.launch
注:运行时可以通过服务关闭开启雷达,即:
rosservice call stop_motor
rosservice call start_motor
hector下载编译
本文是通过下载源码编译,并没有使用 ros 自带的命令行,因为考虑想看里面的源码。
1.下载源码到工作空间中的 /src 文件夹下
git clone https://github.com/tu-darmstadt-ros-pkg/hector_slam.git
2.catkin_make编译
catkin_make
rplidar与hector_slam结合建图
在hectot_slam/hector_slam_launch 文件夹下新建 launch 文件,我命名为 start_slam.launch,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>
测试
打开终端输入
source devel/setup.bash
roslaunch rplidar_ros rplidar.launch
新建另一终端
source devel/setup.bash
roslaunch hector_slam_launch start_slam.launch
成功运行即可看到建立的地图