前言
其实网上很多教程的,前两次安装都没记录自己是怎么安装的,导致我这一次已经是第三次安装了,还是到处出错,所以还是记录一下自己是怎么安装的。方便自己以后用的话只需要自己这一个博客就可以了,不需要到处开网页了。
前提环境:我能上油管(都懂得
安装cartographer
18.04支持直接安装了
#根目录下
sudo apt-get update
sudo apt-get install ros-melodic-cartographer*
#安装依赖
sudo apt-get install -y \
g++ \
git \
google-mock \
libboost-all-dev \
libcairo2-dev \
libeigen3-dev \
libgflags-dev \
libgoogle-glog-dev \
liblua5.2-dev \
libsuitesparse-dev \
ninja-build \
python-sphinx
#安装wstool和rosdep
sudo apt-get install -y python-wstool python-rosdep ninja-build
创建工作区
mkdir carto_ws
cd carto_ws
wstool init src
下载cartographer、cartographer_ros、ceres-solver的代码
cd ~/carto_ws/src
git clone https://github.com/googlecartographer/cartographer_ros.git
git clone https://github.com/googlecartographer/cartographer.git
git clone https://github.com/ceres-solver/ceres-solver.git
安装proto3以及其他依赖
cd ~/carto_ws
sudo apt-get install autoconf autogen
git clone https://github.com/protocolbuffers/protobuf.git
cd protobuf
git submodule update --init --recursive
./autogen.sh
./configure
make
make check
sudo make install
sudo ldconfig
cd ~/carto_ws
sudo rosdep init #报错直接跳过
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y
编译安装
catkin_make_isolated --install --use-ninja #见报错1
source install_isolated/setup.bash
下载DEMO测试
2d slam
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_2d/cartographer_paper_deutsches_museum.bag
roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=${HOME}/Downloads/cartographer_paper_deutsches_museum.bag
成功搞定
报错1:
<== Failed to process package 'cartographer':
Command '['cmake', '/home/willingham/carto_ws/src/cartographer', '-DCMAKE_INSTALL_PREFIX=/home/willingham/carto_ws/install_isolated', '-G', 'Ninja']' returned non-zero exit status 1
Reproduce this error by running:
==> cd /home/willingham/carto_ws/build_isolated/cartographer && cmake /home/willingham/carto_ws/src/cartographer -DCMAKE_INSTALL_PREFIX=/home/willingham/carto_ws/install_isolated -G Ninja
Command failed, exiting.
网上说有可能是proto版本问题,可以通过protoc --version
查询版本,应该需要proto3 我的是3.15.8.但是我的并不是这个问题。
我的解决过程是:
Install cartographer for the following error?–Failed to process package ‘cartographer’:
在这个过程中cmake .. -G Ninja
报错
发现absl有问题,又查到这里安装cartographer,找不到 “absl” 解决方法
最后总结出来的解决方式:
sudo apt-get install stow
sudo chmod +x ~/carto_ws/src/cartographer/scripts/install_abseil.sh
cd ~/carto_ws/src/cartographer/scripts
./install_abseil.sh
然后重新catkin_make_isolated --install --use-ninja
成功得到: