(sudo apt install ros-noetic-gmapping)
即可。
Cartographer并不在ROS packages列表中,安装起来比较麻烦,总体来说,按照官方的编译步骤即可编译成功,官方地址。
操作系统:ubuntu20.04,ros版本:noetic
sudo apt-get update
sudo apt-get install -y python3-wstool python3-rosdep ninja-build stow
mkdir catkin_ws_carto
cd catkin_ws
wstool init src
wstool merge -t src https://raw.githubusercontent.com/cartographer-project/cartographer_ros/master/cartographer_ros.rosinstall
wstool update -t src
这里的意图是把cartographer_ros.rosinstall中的内容追加到src目录下的rosinstall文件中,我们来手动操作,解决上面的问题。
(1)首先,在github上找到cartographer_ros.rosinstall文件,打开后内容如下:
- git: {local-name: cartographer, uri: 'https://github.com/cartographer-project/cartographer.git', version: 'master'}
- git: {local-name: cartographer_ros, uri: 'https://github.com/cartographer-project/cartographer_ros.git', version: 'master'}
我们手动的将cartographer_ros.rosinstall中的内容复制到src目录下的.rosinstall
文件中,默认此文件会被隐藏,可以勾选显示选项显示此文件:
如果github访问也有问题的话,也可以用其他资源,如下面的gitee资源也可以:
- git: {local-name: cartographer, uri: 'https://gitee.com/xfbug/cartographer.git', version: 'master'}
- git: {local-name: cartographer_ros, uri: 'https://gitee.com/xfbug/cartographer_ros.git', version: 'master'}
(2)修改完成.rosinstall
完成后,无需再执行wstool merge命令,直接执行下面的update命令:
wstool update -t src
sudo rosdep init
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro=${noetic} -y
install_abseil.sh
脚本进行安装:src/cartographer/scripts/install_abseil.sh
catkin_make_isolated --install --use-ninja
我们可以通过在演示包上运行Cartographer ROS来测试环境是否搭建成功。
下载、启动2D演示包:
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_2d/cartographer_paper_deutsches_museum.bag
roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=${HOME}/Downloads/cartographer_paper_deutsches_museum.bag
启动前记得先source一下,source ~/catkin_ws_carto/devel_isolated/setup.bash
,演示包展示的是一个2D环境建图的过程:
下载、启动3D演示包:
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_3d/with_intensities/b3-2016-04-05-14-14-00.bag
roslaunch cartographer_ros demo_backpack_3d.launch bag_filename:=${HOME}/Downloads/b3-2016-04-05-14-14-00.bag
更多的bag可以在官方地址上下载体验。
☝ ★★★ — 返回 《ROS机器人开发笔记汇总》总目录 — ★★★ ☝