安裝總結
看了下官方的安裝步驟,本以為沒太多的依賴,結果還是趟了一路的坑。。。
先做下總結,說下安裝思路,在針對具體問題描述下解決辦法。
總結一
首先最大的坑來自Dockerfile,使用cartographer自帶的Dockerfile文件,經過番茄等一些列操作,下載鏡像還算順利,
但是在跑demo時遇到以下問題:
??????? 1).docker中調用Rviz時, 存在GUI顯示服務的問題,這個問題的常規(guī)解法是用X11顯示服務
????????????? ubuntu1604的做法是
?????????????? xhost +
?????????????? docker run -id --name cartographer_rosc -v /data/apollo_all/slam:/work -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY cartographer_ros:1.1
? ? ? ? ? ? ? Mac OS上的做法需要安裝 ? XQuartz ,詳情參考此連接
??????? 2). 就算上面能夠解決docker GUI的問題,但在ubuntu上依然存在顯卡驅動問題,涉及到nvidia驅動,這個實在是太繁瑣,最后直接放棄了。
總之最終結論是建議繞過Dockerfile,直接安裝在ubuntu系統上。
總結二
完全可以先按照cartographer官方的文檔中的步驟進行編譯安裝,如果問題太多,總是編譯不過,再考慮我下面的思路。
protobuf與cartographer編譯版本不匹配,這個問題簡直頭疼死了,要么報google::protobuf的什么函數未定義(例如, undefined reference to `google::protobuf::internal::ComputeUnknownFieldsSize),要么是xx未使用(error: ‘dynamic_init_dummy_src_2fproto_2fgrpc_2fcore_2fstats_2eproto’ defined but not used [-Werror=unused-variable),
對這個問題,沒有其他辦法,就是反復的嘗試proto的不同版本+反復編譯cartographer,
一定要用下面的方法確保protobuf完全安裝成功,要make check,
在每次重新編譯cartographer之前,一定要刪除原來編譯一半的文件夾。
總結三
如果官網的步驟通不過,那就按照自己的步驟安裝吧,
??????? 1) 安裝Ros-kenitic,以及rosdep各種依賴,
??????? 2) 單獨下載cartographer , cartographer_ros, 和ceres-solver 源碼
??????? 3)安裝protobuf
??????? 4) 手動編譯安裝ceres-solver, 參考 src/cartographer/script/install_ceres.sh
??????? 5) 手動編譯安裝 cartographer,參考src/cartographer/script/install_cartographer_cmake.sh
??????? 6)最后在catkin_ws的工作目錄下,直行catkin_make_isolated --install --use-ninja, 建立完整的工作環(huán)境
然后就可以用了^^~
source install_isolated/setup.bash
roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=/data/apollo_all/slam/ros_bag/2d/cartographer_paper_deutsches_museum.bag

以下是我在Ubuntu16.04上的安裝詳情:
安裝Ros-Kenitic
本步驟中參考ros的官方指導安裝即可,
遇到的坑:
??????? 1)找不到某個ros-*包的問題,?
???????????? 需要更新ros的源, 亞洲源 + deb源 ,這兩個源也都來自官方的參考說明
先離線下載源碼
?官方提供的下載方式是用rosinstall file,但是里面ceres的git地址要科學上網,可以自己把三部分源碼下到 src
里就好。
https://github.com/googlecartographer/cartographer
https://github.com/googlecartographer/cartographer_ros
https://github.com/ceres-solver/ceres-solver
下載后都是最新的,也不用 wstool update -t src 這條了
?安裝Protobuf
git clone https://github.com/protocolbuffers/protobuf.git
$ cd protobuf
$ git submodule update --init --recursive
$ ./autogen.sh
$ ./configure --disable-werror? #這個選項需要帶著防止gtest報錯
$ make
$ make check
$ sudo make install
$ sudo ldconfig # refresh shared library cache.
坑:
??? 1)error: ‘dynamic_init_dummy_src_2fproto_2fgrpc_2fcore_2fstats_2eproto’ defined but not used [-Werror=unused-variable
???????????????????? ./configure --disable-werror 解決此問題
??? 2)編譯cartographer時,遇到 undefined reference to `google::protobuf::internal::ComputeUnknownFieldsSize)? 或類似的報錯
???????????? 反復編譯protobuf 和cartorgrapher,一定要注意編譯的順序,還有刪除所有沒有編譯完成的文件夾。
?安裝其他cartorgrapher相關的包
只要上面的準備工作做好了,剩下的就按cartographer照官網的步驟安裝即可
sudo rosdep init
rosdep update
??????? rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y