ubuntu18.04中ROS版本为melodic环境安装cartographer

1.安装环境

本文是在ubuntu18.04下重新安装了melodic,然后成功安装并运行了cartographer

2.依赖安装

按照cartographer的官网提供的依赖安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 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 \
libcurl4-openssl-dev \
libeigen3-dev \
libgflags-dev \
libgoogle-glog-dev \
liblua5.2-dev \
libsuitesparse-dev \
lsb-release \
ninja-build \
stow

1
2
3
4
5
6
7
8
9
10
11
12
# Install Ceres Solver and Protocol Buffers support if available.
# No need to build it ourselves.
if [[ "$(lsb_release -sc)" = "focal" || "$(lsb_release -sc)" = "buster" ]]
then
sudo apt-get install -y python3-sphinx libgmock-dev libceres-dev protobuf-compiler
else
sudo apt-get install -y python-sphinx
if [[ "$(lsb_release -sc)" = "bionic" ]]
then
sudo apt-get install -y libceres-dev
fi
fi

3.安装abseil-cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
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

4.安装ceres-solver

在ceres-solver官网下载1.13.0版本

解压ceres-solver,然后执行以下命令

1
2
3
4
5
6
7
cd ceres-solver
mkdir build
cd build
cmake .. -G Ninja -DCXX11=ON
ninja
CTEST_OUTPUT_ON_FAILURE=1 ninja test
sudo ninja install

这里之所以和官网安装方式不一样是因为,作者在执行git clone https://ceres-solver.googlesource.com/ceres-solver 这个安装命令时一直不成功,可能是网络原因

5.安装protobuf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
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

6.安装cartographer

1
2
3
4
5
6
7
8
9
10
11
ROS_DISTRO="melodic"
sudo apt-get update
sudo apt-get install -y python-wstool python-rosdep ninja-build stow
mkdir catkin_google_ws
cd catkin_google_ws
wstool init src
wstool merge -t src https://ghproxy.com/https://raw.githubusercontent.com/cartographer-project/cartographer_ros/master/cartographer_ros.rosinstall
wstool update -t src
src/cartographer/scripts/install_abseil.sh
sudo apt-get remove ros-${ROS_DISTRO}-abseil-cpp
catkin_make_isolated --install --use-ninja

7.测试demo

下载官方数据

1
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_2d/cartographer_paper_deutsches_museum.bag

8.运行

1
2
3
cd ~/catkin_google_ws
source install_isolated/setup.sh
roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=${HOME}/Downloads/cartographer_paper_deutsches_museum.bag

9.结果

10.Cartographer ROS Documentation


ubuntu18.04中ROS版本为melodic环境安装cartographer
https://qiangsun89.github.io/2023/02/17/ubuntu18-04中ROS版本为melodic环境安装cartographer/
作者
Qiang Sun
发布于
2023年2月17日
许可协议