官方安装步骤一直没有成功
以下安装步骤参考hitcm的博客
需要安装3个软件包ceres-solver、cartographer和cartographer_ros。
0.安装所有依赖项
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-indigo-tf2-eigen libatlas-base-dev libsuitesparse-dev liblapack-dev
1.首先安装ceres solver,选择的版本是1.11,路径随意
git clone https://github.com/hitcm/ceres-solver-1.11.0.git
cd ceres-solver-1.11.0
mkdir build
cd build
cmake ..
make -j4
sudo make install
2.然后安装 cartographer,路径随意
git clone https://github.com/hitcm/cartographer.git
cd cartographer
mkdir build
cd build
cmake .. -G Ninja
ninja
ninja test
sudo ninja install
3.安装cartographer_ros。
谷歌官方提供的安装方法比较繁琐,对原来的文件进行了少许的修改,核心代码不变,只是修改了编译文件
#初始化工作空间
mkdir -p ~/catkin_google_ws/src
cd ~/catkin_google_ws/src
catkin_init_workspace
cd ..
catkin_make
echo "source ~/catkin_google_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
#安装cartographer_ros
cd ~/catkin_google_ws/src
git clone https://github.com/hitcm/cartographer_ros.git
cd ~/catkin_google_ws
catkin_make
4.数据下载测试
2d数据
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_2d/cartographer_paper_deutsches_museum.bag
3d数据
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_3d/cartographer_3d_deutsches_museum.bag
运行launch文件
roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=${HOME}/Downloads/cartographer_paper_deutsches_museum.bag
roslaunch cartographer_ros demo_backpack_3d.launch bag_filename:=${HOME}/Downloads/cartographer_3d_deutsches_museum.bag
刚开始使用ROS的同学运行下面两句是无法工作的,可能出现的错误如下。
[demo_backpack_2d.launch] is neither a launch file in package [cartographer_ros] nor is [cartographer_ros] a launch file name
The traceback for the exception was written to the log file
这种错误的主要原因是ros的catkin_google_ws配置问题,可以运行rospack profile试试。
实在不行还有如下所示的两种解决方法。推荐第二种。