谷歌本身提供了安裝方法,可是安裝比較繁瑣,我作了必定的修改,代碼放到我的github上,https://github.com/hitcm/。python
ros下面的安裝很是快捷,只須要catkin_make便可。git
更多細節,能夠看看知乎的問題https://www.zhihu.com/question/51348391/answer/125560951?from=profile_answer_cardgithub
我的理解錯誤的地方還請不吝賜教,轉載請標明出處,內容若有改動更新,請看原博:http://www.cnblogs.com/hitcm/,若有任何問題,feel free to contact me at robotsming@gmail.comweb
若有問題,請及時反饋給我,博客會持續更新。api
以下,須要安裝3個軟件包,ceres solver、cartographer和cartographer_ros測試
0.安裝全部依賴項ui
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-devgoogle
1.首先安裝ceres solver,選擇的版本是1.11,路徑隨意lua
1. git clone https://github.com/hitcm/ceres-solver-1.11.0.gitspa
2. cd ceres-solver-1.11.0/build
3. cmake ..
4. make –j
5. sudo make install
2.而後安裝 cartographer,路徑隨意
1. git clone https://github.com/hitcm/cartographer.git
2 . cd cartographer/build
3. cmake .. -G Ninja
4. ninja
5. ninja test
6. sudo ninja install
上述第3步執行錯誤的同窗能夠忽略3-6步,改用下面的方法。
7. cmake ..
8 . make
9. sudo make install
3.安裝cartographer_ros。
谷歌官方提供的安裝方法比較繁瑣,我對原來的文件進行了少量的修改,核心代碼不變,只是修改了編譯文件
下載到catkin_ws下面的src文件夾下面
git clone https://github.com/hitcm/cartographer_ros.git
而後到catkin_ws下面運行catkin_make便可。
4.數據下載測試
2d數據,大概500M,用迅雷下載
https://storage.googleapis.com/cartographer-public-data/bags/backpack_2d/cartographer_paper_deutsches_museum.bag
3d數據,8G左右,一樣用迅雷下載
https://storage.googleapis.com/cartographer-public-data/bags/backpack_3d/cartographer_3d_deutsches_museum.bag
有同窗反映上面連接失效了,請用下面的便可。
https://storage.googleapis.com/cartographer-public-data/bags/backpack_3d/b3-2016-04-05-14-14-00.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_ws配置問題,能夠運行rospack profile試試。
實在不行還有以下所示的兩種解決方法。推薦第二種。
最終結果以下圖,左側爲2d,右側爲3d。
Good luck!關於代碼的原理解析,接下來的文章可能會詳細探討。