ROS2与3D-SLAM入门教程-LIO-SAM算法建图
ROS2与3D-SLAM入门教程-LIO-SAM算法建图
说明:
- 介绍如何利用LIO-SAM算法实现3D建图
- 测试环境:ubuntu20.04 + ros2 galactic
步骤:
- 安装ros2相关包
sudo apt install ros-galactic-perception-pcl \
ros-galactic-pcl-msgs \
ros-galactic-vision-opencv \
ros-galactic-xacro
- 安装GTSAM
# Add GTSAM-PPA
sudo add-apt-repository ppa:borglab/gtsam-release-4.0
sudo apt install libgtsam-dev libgtsam-unstable-dev
- 下载源码
mkdir -p ~/ros2_slam_3d_ws/src
cd ~/ros2_slam_3d_ws/src
git clone -b ros2 https://github.com/TixiaoShan/LIO-SAM.git
- 编译
cd ~/ros2_slam_3d_ws
colcon build --symlink-install --packages-select LIO-SAM
测试:
- 如果使用ros1录制的包来测试,可以下载ros1bag hdl_400.bag
- 这个包需要安装ros2 bag的插件rosbag2_bag_v2进行转换, 参考方法ros2入门教程-rosbag和ros2 bag 转换
- 新终端,启动lio_sam
source /opt/ros/galactic/setup.bash
cd ~/ros2_slam_3d_ws/
ros2 launch lio_sam run.launch.py
- 新终端,播放包
$ source /opt/ros/noetic/setup.bash
$ source /opt/ros/galactic/setup.bash
$ ros2 bag info -s rosbag_v2 dataset/hdl_400.bag
- 效果图
- 保存map.pcd和pose_graph.g2o, 保存的目录为运行lidarslam.launch.py的目录
- 目前是在~/ros2_slam_3d_ws/目录下运行
cd ~/ros2_slam_3d_ws/
ros2 service call /lio_sam/save_map lio_sam/srv/SaveMap
或者
ros2 service call /lio_sam/save_map lio_sam/srv/SaveMap "{resolution: 0.2, destination: /Downloads/service_LOAM}"
- 打开pcd
- 如果没pcl_viewer,既需安装
sudo apt install libpcl-dev pcl-tools
- 打开
cd ~/ros2_slam_3d_ws2/
pcl_viewer map.pcd
- 效果图
参考:
- https://github.com/TixiaoShan/LIO-SAM/tree/ros2
获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号