cartographer_ros官方参考链接:https://google-cartographer-ros.readthedocs.io/en/latest/compilation.html#system-requirements cartographer官方参考链接:https://google-cartographer.readthedocs.io/en/latest/ 本文参考链接: https://blog.csdn.net/weixin_51157015/article/details/118553687 https://blog.csdn.net/lianxindong/article/details/122395589
工作环境
Ubuntu 18.04.6 ROS Melodic cartographer 1.0.0 cartographer_ros 1.0.0 ceres-solver 1.13.0
下载安装工具
首先,按照cartographer_ros官方参考链接步骤,进行下载后续所需要的工具:(针对ros melodic版本)
sudo apt-get update
sudo apt-get install -y python-wstool python-rosdep ninja-build stow
创建一个工作空间
mkdir carto_ws
cd carto_ws
wstool init src
可以看到carto_ws/src文件路径下存在一个“.rosinstall”文件。
在“.rosinstall”文件中加入下述内容:
- git:
local-name: cartographer
uri: https://github.com/googlecartographer/cartographer.git
version: 1.0.0
- git:
local-name: cartographer_ros
uri: https://github.com/googlecartographer/cartographer_ros.git
version: 1.0.0
- git:
local-name: ceres-solver
uri: https://github.com/ceres-solver/ceres-solver.git
version: 1.13.0
下载cartographer、cartographer_ros、ceres-solver
wstool update -t src
安装所需依赖
rosdep初始化:
sudo rosdep init
rosdep update
当然,我们在安装ros的过程中(Ubuntu 18.04.05 LTS配置ROS Melodic各种问题详细解决(填坑))可能已经执行过上述内容,所以如果出现“已经存在20-default.list文件”类似的错误,则可以忽略。 安装依赖: rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y
安装 abseil-cpp
使用install_abseil.sh文件安装abseil-cpp。 首先,在“src/cartographer/scripts/”路径中,创建一个“install_abseil.sh”文件,添加下述内容:
git clone https://github.com/abseil/abseil-cpp.git
cd abseil-cpp
git checkout d902eb869bcfacc1bad14933ed9af4bed006d481
mkdir build
cd build
cmake -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DCMAKE_INSTALL_PREFIX=/usr/local/stow/absl \
..
ninja
sudo ninja install
cd /usr/local/stow
sudo stow absl
然后,增加此文件的执行权限。
sudo chmod +x install_abseil.sh
接着,执行此脚本:
sudo ./src/cartographer/scripts/install_abseil.sh
ninja编译
catkin_make_isolated --install --use-ninja
运行Demo
激活当前工作空间
source ~/carto_ws/install_isolated/setup.bash
下载数据,并运行Demo
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
运行如下:
|