衡水网站建费用软件推广赚佣金渠道
1.概述
Cartographer是一个支持多平台和传感器配置的SLAM的系统。
本文主要讲述在ros2 humble系统上cartographer的安装方法,以及如何配置参数实现自己的ros2 bag包的离线建图。
官方cartographer的github地址:https://github.com/ros2/cartographer
官方cartographer_ros的github地址:https://github.com/ros2/cartographer_ros
官方cartographer说明文档(非ROS2版本)地址:https://google-cartographer.readthedocs.io/en/latest/
官方cartographer_ros说明文档(非ROS2版本)地址:https://google-cartographer-ros.readthedocs.io/en/latest/
2.安装cartographer
2.1 apt安装
sudo apt install ros-humble-cartographer ros-humble-cartographer-ros
# 等待安装完成,输入如下指令查看是否安装完成;先source一下环境
ros2 pkg list | grep cartographer
# 正常可看到返回如下pkg
cartographer_ros
cartographer_ros_msgs
cartographer_rviz
2.2 源码安装
sudo apt-get update
sudo apt-get install -y python3-wstool python3-rosdep ninja-build stow
# 根据个人意愿,建立新的工作空间
mkdir cartogrpaher_ws
cd cartogrpaher_ws
wstool init src
cd src
git clone https://ghproxy.com/https://github.com/ros2/cartographer.git
git clone https://ghproxy.com/https://github.com/ros2/cartographer_ros.git
wstool update -t src
sudo rosdep init
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro=humble -y
colcon build
# 如果提示缺少依赖,命令行安装一下即可
# 同上述apt安装,安装完成,source一下环境,检查是否成功
3.cartographer参数配置
因为是用纯激光的bag数据仿真运行,一般只需要.launch.py+.lua+(urdf)即可;没有用到imu和odom数据;
3.1 .launch.py文件
这里参考的demo_backpack_2d.launch.py和backpack_2d.launch.py;(参考demo_revo_lds.launch.py更好,只用一个文件即可)
# demo_my_robot_2d.launch.py
def generate_launch_description():# 未配置默认bag包的打开位置,启动时需要加指令: bag_filename:= bag包的位置bag_filename_arg = DeclareLaunchArgument('bag_filename')## ***** Nodes ***** 修改参数为my_robot_2d.launch.pymy_robot_2d_launch = IncludeLaunchDescription(PythonLaunchDescriptionSource(FindPackageShare('cartographer_ros').find('cartographer_ros') + '/launch/my_robot_2d.launch.py'),launch_arguments = {'use_sim_time': 'True'}.items())# 以下均未调整rviz_node = Node(package = 'rviz2',executable = 'rviz2',on_exit