0.准备工作:
操作系统:ubuntu20.04
ros系统:noetic
官方依赖文档说明:
https://google-cartographer.readthedocs.io/en/latest/
官方cartographer安装与编译说明:
https://google-cartographer-ros.readthedocs.io/en/latest/compilation.html#building-installation
1.安装依赖
# Install the required libraries that are available as debs.
sudo apt-get update
sudo apt-get install -y \
clang \
cmake \
g++ \
git \
google-mock \
libboost-all-dev \
libcairo2-dev \
libceres-dev \
libcurl4-openssl-dev \
libeigen3-dev \
libgflags-dev \
libgoogle-glog-dev \
liblua5.2-dev \
libsuitesparse-dev \
lsb-release \
ninja-build \
python3-sphinx \
stow
# Install Protocol Buffers and Abseil if available.
# No need to build it ourselves.
case "$(lsb_release -sc)" in
jammy|bullseye)
sudo apt-get install -y libgmock-dev protobuf-compiler libabsl-dev ;;
focal|buster)
sudo apt-get install -y libgmock-dev protobuf-compiler ;;
bionic)
;;
esac
git clone https://github.com/abseil/abseil-cpp.git
cd abseil-cpp
git checkout 215105818dfde3174fe799600bb0f3cae233d0bf # 20211102.0
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
VERSION="v3.4.1"
# Build and install proto3.
git clone https://github.com/google/protobuf.git
cd protobuf
git checkout tags/${VERSION}
mkdir build
cd build
cmake -G Ninja \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DCMAKE_BUILD_TYPE=Release \
-Dprotobuf_BUILD_TESTS=OFF \
../cmake
ninja
sudo ninja install
# Build and install Cartographer.
cd cartographer
mkdir build
cd build
cmake .. -G Ninja
ninja
CTEST_OUTPUT_ON_FAILURE=1 ninja test
sudo ninja install
2.安装cartographer
sudo apt-get update
sudo apt-get install -y python3-wstool python3-rosdep ninja-build stow
mkdir catkin_google_ws
cd catkin_google_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=${ROS_DISTRO} -y
src/cartographer/scripts/install_abseil.sh
sudo apt-get remove ros-${ROS_DISTRO}-abseil-cpp
catkin_make_isolated --install --use-ninja
3.验证
3.1 下载官方数据包
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_2d/cartographer_paper_deutsches_museum.bag
3.2 刷新环境变量
cd ~/catkin_google_ws
source install_isolated/setup.sh
3.3 运行数据包
roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=${HOME}/Downloads/cartographer_paper_deutsches_museum.bag
结语 :
这里先记录下整个cartographer算法包的安装流程,中间下载时肯定会出现各种各样的问题,这些问题以后再去做更新,完毕。