二维激光SLAM(Cartographer)
Cartographer安装
ROS自带有cartographer,因此可以apt安装
sudo apt install ros-melodic-cartographer-ros
sudo apt install ros-melodic-cartographer-rviz
安装map server用于保存地图
sudo apt install ros-melodic-map-server
复制相关文件
roscd cartographer_ros
sudo cp -r ~/XTDrone/sensing/slam/laser_slam/cartographer/* ./
启动仿真
启动仿真环境(记得把indoor3.launch里的sdf设为iris_2d_lidar)这里也是要在新终端运行
roslaunch px4 indoor3.launch
启动Cartographer
cd /opt/ros/melodic/share/cartographer_ros
roslaunch cartographer_ros xtdrone_2d.launch
启动通信脚本
cd ~/XTDrone/communication/
python multirotor_communication.py iris 0
将cartographer输出的2D位姿和高度值(由1D激光测距仪获得),转换为mavros话题
cd ~/XTDrone/sensing/slam/laser_slam/script/
python laser_transfer.py iris 0 cartographer
启动键盘控制脚本,控制无人机飞行,注意不能飞太高,导致激光雷达扫不到围墙。
cd ~/XTDrone/control/keyboard/
python multirotor_keyboard_control.py iris 1 vel
绕场地飞一圈,建立完整的地图,而后保存地图,用于后需要运动规划使用。
与“二维激光SLAM(HectorSLAM)”一样,因为无人机失去控制,没有画出完整的地图。
rosrun map_server map_saver -f ~/XTDrone/motion_planning/2d/map/indoor3
完整的地图如下图所示