最近在新电脑上重新安装Cartographer,试着用一下之前(去年)安装的时候跟着做的教程,基本都没能成功编译。
Cartographer本身不是很容易编译安装,各个依赖库也不断在变,谷歌的官方安装教程不用去看,早就没法使用了,而且有很多坑也没有写出来还得自己一步一步的去适配。这里我就大概总结一下最新的安装方法吧,环境是ubuntu16.04,ros自行安装kinetic版。
一、安装前准备和注意事项
1、依赖项
sudo apt-get updatesudo 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
直接复制执行就好。
然后是一些Ceres等的依赖:
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
2、abseil的安装
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
然后:
sudo apt-get install stow安装stow
cd /usr/local/stow
sudo stow absl
3、ptoto3安装
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
这之中如果报不是严重的错,可以先无视
4、注意事项
A、cartographer需要的pcl版本为1.7,安装ros的时候会自带一个1.7,不需要额外安装,如果电脑上安装了pcl1.9,要么完全卸载1.9,要么编译的时候得注意使用1.7的版本,不然的最后使用的时候rviz会卡在第一帧
二、开始安装主体
1、创建工作区
mkdir cartographer_ws
cd cartographer_ws
wstool init src
2、clone cartographer, cartographer_ros, ceres-solver代码
cd 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
3、
cd .. (也就是回到cartographer_ws这个目录)
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y
catkin_make_isolated --install --use-ninja
4、至此,安装完毕,每次新开终端使用时需要
source install_isolated/setup.bash
原因应该不必多说。