编译cartographer-slam

官网链接:https://google-cartographer-ros.readthedocs.io/en/latest/compilation.html

环境:16.04 kinetic
第一步:下载一些工具

sudo apt-get update
sudo apt-get install -y python-wstool python-rosdep ninja-build stow

下面几步都是访问GitHub,需要保证网络顺畅,所出现的问题几步是网络造成。
第二步:下载源码

mkdir catkin_ws
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

第三步:下载依赖

sudo rosdep init
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro=Kinetic -y

第四步:安装abseil-cpp

cd src/cartographer/scripts/
sudo chmod +x ./install_abseil.sh

第五步: 编译源码

cd catkin_ws
catkin_make_isolated --install --use-ninja

出现的问题:
C++11 ‘constexpr’ only available with -std=c++11 or -std=gnu++11
/opt/ros/kinetic/include/absl/strings/string_view.h:475:3: error: ‘size_type’ does not name a type
等类似的。
解决:这个问题的本质是gcc和g++的版本低,需要指定编译支持C++11。在src中cartographer和cartographer_ros中每个CMakeLists.txt文件中添加支持C++11

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/yyl80/article/details/118208700