cartographer
按官网教程安装
HTTPs://Google-cartographer-ros.readthedocs.io/en/latest/
# Install wstool and rosdep.
sudo apt-get update
sudo apt-get install -y Python-wstool python-rosdep ninja-build
# Create a new workspace in 'catkin_ws'.
mkdir catkin_ws
cd catkin_ws
wstool init src
# Merge the cartographer_ros.rosinstall file and fetch code for dependencies.
wstool merge -t src https://raw.githubusercontent.com/googlecartographer/cartographer_ros/master/cartographer_ros.rosinstall
wstool update -t src
# Install proto3.
#src/cartographer/scripts/install_proto3.sh
# Install deb dependencies.
# The command 'sudo rosdep init' will print an ERROR if you have already
# executed it since installing ROS. This error can be ignored.
sudo rosdep init
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y
# Build and install.
catkin_make_isolated --install --use-ninja
source install_isolated/setup.bash
catkin_make_isolated --install --use-ninja
运行到这一步时出现以下错误
Running C++ protocol buffer compiler on /home/ares/cg_ws/src/cartographer/cartographer/mAPPing/proto/trajectory.proto
FaiLED: cd /home/ares/cg_ws/build_isolated/cartographer/install && /home/ares/maplab_ws/devel/bin/protoc --cpp_out /home/ares/cg_ws/build_isolated/cartographer/install -I /home/ares/cg_ws/src/cartographer /home/ares/cg_ws/src/cartographer/cartographer/mapping/proto/trajectory.proto
cartographer/mapping/proto/trajectory.proto:15:10: Unrecognized syntax identifier "proto3". This parser only recognizes "proto2".
[8/338] cd /home/ares/cg_ws/build_isolated/cartographer/install.../ares/cg_ws/build_isolated/cartographer/install/AllFiles.cmake"
ninja: build stopped: subcommand failed.
<== Failed to process package 'cartographer':
Command '['/home/ares/cg_ws/install_isolated/env.sh', 'ninja', '-j8', '-l8']' returned non-zero exit status 1
Reproduce this error by running:
==> cd /home/ares/cg_ws/build_isolated/cartographer && /home/ares/cg_ws/install_isolated/env.sh ninja -j8 -l8
发现是Protobuf 版本问题,在终端输入protoc --version
显示为2.6.1,输入which protoc
输出为/home/ares/maplab_ws/devel/bin/protoc
,这是因为以前装map_lab的时候安装了protoc,只能暂时先删掉了。sudo rm -rf protoc
,删掉后下载安装对应的版本VERSION="v3.4.1"。
cd protobuf
mkdir build
cmake -G Ninja \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DCMAKE_BUILD_TYPE=Release \
-Dprotobuf_BUILD_TESTS=OFF \
../cmake
ninja
sudo ninja install
删掉编译的文件再次运行没有错误。
参考链接:https://blog.csdn.net/QQ_42145185/article/details/80955894
https://google-cartographer-ros.readthedocs.io/en/latest/