在官網的基礎上稍加修改,但保證代碼都是最新的
我的系統配置: Debian9 strech, ROS lunar 該方法對 ubuntu 系列操作系統以及其他ROS版本同樣適用。
1. 安裝依賴庫
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
2. 安裝ceres-solver
google提供的地址下載太慢,在github上git clone 也是太慢, 索性直接Donload zip
https://github.com/ceres-solver/ceres-solver.git
然后編譯安裝:
cd ceres-solver mkdir build cd build cmake .. make -j4 sudo make install
3. 安裝proto3
a. 重要說明: 如果你已經安裝了ROS Lunar, 恭喜你,其實你已經安裝了protobuf了, 但是你沒有安裝protobuf-compiler, 你只需要安裝一下protobuf-compiler就可以了
sudo apt-get install protobuf-compiler
然后你可以執行 protoc --version 查看protobuf 的版本.
b. 如果你裝的是ROS Kinetic, 你的protobuf 的版本應該是 2.x, 需要手動將其升級到 proto3
方法:
下載鏈接 https://github.com/google/protobuf/releases
官方安裝手冊:https://github.com/protocolbuffers/protobuf/blob/master/src/README.md
安裝:(下載安裝all版本)
tar zxvf protobuf-all-3.6.0.tar.gz cd protobuf-3.6.0/ ./configure –prefix=/usr/local/ (安裝路徑,一般情況下,默認會安裝到/usr/include 文件下,我們需要指定安裝到,/usr/local/include文件下,安裝完成會有一個goole文件在/usr/local/include 下) make make check make install protoc –version #查看版本
c. 如果你沒有裝ROS那么執行下面的步驟吧:
安裝依賴
sudo apt-get install autoconf automake libtool curl make g++ unzip
方式一(推薦):
sudo apt-get install libprotobuf-dev sudo apt-get install protobuf-compiler
方式二:
下載zip(git clone 太慢了)
地址: https://github.com/protocolbuffers/protobuf
編譯安裝:
./autogen.sh ./configure –prefix=/usr/local/ make -j4 make check sudo make install sudo ldconfig # refresh shared library cache.
make check 會提示又一些錯誤,沒關系啦,核心庫已經編譯好啦
4. 安裝cartographer
clone cartographer代碼,這個速度還可以
git clone https://github.com/googlecartographer/cartographer.git
編譯安裝
cd cartographer mkdir build cd build cmake .. make -j4 sudo make install
5. 安裝cartographer_ros
這個就簡單了,地址:
https://github.com/googlecartographer/cartographer_ros
clone 或者下載到自己的ROS工作空間,編譯一下就可以了.
6. 測試
2D:
// launch 2D example roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=${HOME}/Downloads/cartographer_paper_deutsches_museum.bag
3D:
# Launch the 3D backpack demo. roslaunch cartographer_ros demo_backpack_3d.launch bag_filename:=${HOME}/Downloads/b3-2016-04-05-14-14-00.bag
OK, 到此結束!