首先安装依赖
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
注意! cartographer要求的cmake版本是3.2及以上。
建议使用wstool和rosdep
为了加快构建速度,我们还建议使用Ninja
安装 wstool 和 rosdep.
sudo apt-get update
sudo apt-get install -y python-wstool python-rosdep ninja-build
创建工作空间
$ mkdir catkin_ws
$ cd catkin_ws
$ wstool init src
下载 ceres solver、cartographer和cartographer_ros
$ wstool merge -t src https://raw.githubusercontent.com/googlecartographer/cartographer_ros/master/cartographer_ros.rosinstall
$ vim src/.rosinstall
#更改ceres-solver中地址改为下面的地址:
uri: https://github.com/ceres-solver/ceres-solver.git
$ wstool update -t src
注意! 这里的下载需要翻墙(大概吧 我有点没印象了) 而且 ceres slover很难下载下来。
可以在github上下载后两个包
https://github.com/googlecartographer/cartographer
ceres slover 下载地址 https://github.com/hitcm/ceres-solver-1.11.0.git
注意! ceres slover与eigen3.3会冲突。如果你电脑的eigen是3.3,请更换版本
https://github.com/eigenteam/eigen-git-mirror
下一步:
$ src/cartographer/scripts/install_proto3.sh
安装protobuf依赖
$ sudo rosdep init
$ rosdep update
注意! 这一步可能会出现
ERROR: default sources list file already exists:/etc/ros/rosdep/sources.list.d/20-default.list
这样的错误你可以忽略,因为你之前已经安装过ros。如果你想解决 可以参考这篇:
https://blog.csdn.net/Jinxiaoyu886/article/details/88664049
接着输入:
$ rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y
注意 这一步有可能会出现一些问题
Error(s): - The “package” tag must not have the following attributes:
packag …manifest.xml (with version 1) … … 大概是这样子的错误
这个问题是因为你的protobuf文件的环境有问题,我没有解决,所以我自己下了一个,编译如下:
首先安装依赖:
$ sudo apt-get install autoconf automake libtool curl
下载地址:https://github.com/protocolbuffers/protobuf/tree/v3.0.0
接着输入:
cd protobuf
进入到包里。
修改autogen.sh
peter@ubuntu14:~/protobuf/protobuf$ git diff
diff --git a/autogen.sh b/autogen.sh index 5b4c29f..f2abf77 100755
--- a/autogen.sh
+++ b/autogen.sh @@ -31,7 +31,7 @@ fi # directory is set up as an SVN external. if test ! -e gmock; then echo "Google Mock not present.
Fetching gmock-1.7.0 from the web..."
(删除 curl $curlopts -O https://googlemock.googlecode.com/files/gmock-1.7.0.zip)
(添加: curl $curlopts -L -o gmock-1.7.0.zip https://github.com/peter-wangxu/gmock/archive/1.7.0.zip)
unzip -q gmock-1.7.0.zip
rm gmock-1.7.0.zip
mv gmock-1.7.0 gmock
然后输入:
$ ./autogen.sh
$ ./configure
$ make
$ make check
$ sudo make install
$ sudo ldconfig
注意! 默认是安装在“/usr/local/lib”下的,在有些平台/usr/local/lib不是默认的LD_LIBRARY_PATH变量里面,可以在通过如下命令改变安装目录
$ ./configure --prefix=/usr
出现下面的文字就表示安装成功
============================================================================
Testsuite summary for Protocol Buffers 3.0.0-beta-2
============================================================================
# TOTAL: 6
# PASS: 6
# SKIP: 0
# XFAIL: 0
# FAIL: 0
# XPASS: 0
# ERROR: 0
============================================================================```
如果安装成功了 输入
$ rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y
如果失败了也没事,失败说明我们之前的安装已经有了这个依赖了。
编译:
$ catkin_make_isolated --install --use-ninja
下面这个指令要在每次运行前打一遍 要在工作空间的根目录下输入,即 cd ~/catkin_ws
后:
$ source install_isolated/setup.bash
运行测试案例:
2d数据,大概500M,用迅雷下载
3d数据,8G左右,同样用迅雷下载
https://storage.googleapis.com/cartographer-public-data/bags/backpack_3d/b3-2016-04-05-14-14-00.bag
比如我下载好后的位置是:
/home/jy/onemore/src/cartographer_ros/cartographer_ros
在cartograph_ros里的launch文件夹中打开终端,输入
roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=${HOME}/onemore/src/cartographer_ros/cartographer_ros/cartographer_paper_deutsches_museum.bag
结束。祝大家好运!