1.安装所有依赖项
sudo apt-get install -y google-mock libboost-all-dev libeigen3-dev libgflags-dev libgoogle-glog-dev liblua5.2-dev libprotobuf-dev libsuitesparse-dev libwebp-dev ninja-build protobuf-compiler python-sphinx ros-medolic-tf2-eigen libatlas-base-dev libsuitesparse-dev liblapack-dev
2. 安装ceres solver
安装ceres-solver-1.13.0版本,其中ceres-solver-1.11.0和ceres-solver-1.14.0编译时会发生错误。
直接从http://ceres-solver.org/ceres-solver-1.13.0.tar.gz上下载ceres-solver-1.13.0,将其置于相应的工作空间的src文件夹(其他位置也可以)下,并进行下面的操作:
tar xvf ceres-solver-1.13.0.tar.gz
cd ceres-solver-1.13.0
mkdir build
cd build
cmake ..
make
sudo make install
3. 安装 cartographer
将其置于相应的工作空间的src文件夹(其他位置也可以)下,安装cartographer功能包过程如下:
git clone https://github.com/cartographer-project/cartographer.git
cd cartographer
mkdir build
cd build
cmake ..
make
sudo make install
如果执行cmake … 指令发生如下错误时:
-- Found GMock: gmock_main;-lpthread
CMake Error at CMakeLists.txt:32 (find_package):
By not providing "Findabsl.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "absl", but
CMake did not find one.
Could not find a package configuration file provided by "absl" with any of
the following names:
abslConfig.cmake
absl-config.cmake
Add the installation prefix of "absl" to CMAKE_PREFIX_PATH or set
"absl_DIR" to a directory containing one of the above files. If "absl"
provides a separate development package or SDK, be sure it has been
installed.
解决方案如下:在下载回来的cartographer上有安装absl的脚本
sudo apt-get install stow
sudo chmod +x ~/你的工作空间名/src/cartographer/scripts/install_abseil.sh
cd ~/你的工作空间名/src/cartographer/scripts
./install_abseil.sh
其中,执行 ./install_abseil.sh指令时,可能会发生如下错误:
fatal: unable to access 'http://github.com/abseil/abseil-cpp.git': Failed to connect to
将install_abseil.sh文件的20行对应进行修改为:
git clone git://github.com/abseil/abseil-cpp.git
4.安装cartographer_ros
#初始化工作空间
mkdir -p ~/你的工作空间名/src
cd ~/你的工作空间名/src
catkin_init_workspace
echo "source 你的工作空间名/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
#安装cartographer_ros
cd ~/你的工作空间名/src
git clone https://github.com/cartographer-project/cartographer_ros.git
cd ~/你的工作空间名
catkin_make_isolated
执行catkin_make_isolated编译时,出现下面的错误:
/usr/local/include/cartographer/common/lua.h:20:10: fatal error: lua.hpp: 没有那个文件或目录#include <lua.hpp>
解决方案如下:在/usr目录下搜索lua.hpp文件
find . -name lua.hpp
./include/lua5.2/lua.hpp
将lua.h中<lua.hpp>改成<lua5.2/lua.hpp> 即可解决。