ROS2与3D-SLAM入门教程-li_slam_ros2算法建图
ROS2与3D-SLAM入门教程-li_slam_ros2算法建图
说明:
- 介绍如何利用li_slam_ros2算法实现3D建图
- 测试环境:ubuntu20.04 + ros2 galactic
步骤:
- 安装依赖
sudo add-apt-repository ppa:borglab/gtsam-release-4.0
sudo apt update
sudo apt install libgtsam-dev libgtsam-unstable-dev
- 下载源码
mkdir -p ~/ros2_slam_3d_ws2/src
cd ~/ros2_slam_3d_ws2/src
git clone --recursive https://github.com/rsasaki0109/li_slam_ros2
- 编译
cd ~/ros2_slam_3d_ws2
export MAKEFLAGS="-j2"
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release
测试:
- 如果使用ros1录制的包来测试,可以下载ros1bag hdl_400.bag
- 这个包需要安装ros2 bag的插件rosbag2_bag_v2进行转换, 参考方法ros2入门教程-rosbag和ros2 bag 转换
- 新终端, 打开rviz
source /opt/ros/galactic/setup.bash
cd ~/ros2_slam_3d_ws2/
rviz2 -d src/li_slam_ros2/scanmatcher/rviz/lio.rviz
- 新终端,启动li_slam_ros2
source /opt/ros/galactic/setup.bash
cd ~/ros2_slam_3d_ws2/
ros2 launch scanmatcher lio.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_ws2/目录下运行
cd ~/ros2_slam_3d_ws2/
ros2 service call /map_save std_srvs/Empty
- 打开pcd
- 如果没pcl_viewer,既需安装
sudo apt install libpcl-dev pcl-tools
- 打开
cd ~/ros2_slam_3d_ws2/
pcl_viewer map.pcd
- 效果图
参考:
- https://github.com/rsasaki0109/li_slam_ros2
获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号