個人能力有限,若有錯誤請批評指正!
轉載請標明出處:http://www.cnblogs.com/wenhust/
Cartographer簡介
Cartographer is a system that provides real-time simultaneous localization and mapping (SLAM) in 2D and 3D across multiple platforms and sensor configurations. This project provides Cartographer's ROS integration.
Cartographer是google開源的通用2D和3D定位與地圖同步構建的SLAM工具,並提供ROS接口。
官網地址:https://github.com/googlecartographer
安裝說明
- 官網提供了基於Ubuntu14.04(Trusty)和ROS(indigo)的安裝和測試說明,有博客寫道在Ubuntu16.04(Xenial)和ROS(Kinetic)上安裝和測試成功,該博客也有Cartographer的介紹和安裝流程:
http://blog.csdn.net/zhangrelay/article/details/52757573 - 以下安裝流程主要參考hitcm(張明明)的博客及Cartographer的官方安裝教程:
- hitcm(張明明)博客:http://www.cnblogs.com/hitcm/p/5939507.html
- 官方安裝教程Getting started without ROS: https://google-cartographer.readthedocs.io/en/latest/
- 官方安裝教程Getting started with ROS: https://google-cartographer-ros.readthedocs.io/en/latest/
安裝流程
- 安裝Ubuntu14.04(Trusty),將安裝鏡像文件制作U盤鏡像,進入BIOS或WIN10下進入設置->更新和安全->恢復->高級啟動,使用U盤啟動,完成Ubuntu14.04(Trusty)的安裝。
- 安裝ROS(indigo),參考文件http://wiki.ros.org/indigo/Installation/Ubuntu(英文原版)、http://wiki.ros.org/cn/indigo/Installation/Ubuntu(中文翻譯);
注意: 如果每次打開一個新的終端時ROS環境變量都能夠自動配置好(即添加到bash會話中),那將會方便得多:echo "source /opt/ros/indigo/setup.bash" >> ~/.bashrc
source ~/.bashrc
如果你安裝有多個ROS版本,~/.bashrc
必須只能source
你當前使用版本所對應的setup.bash
。
如果你只想改變當前終端下的環境變量,你可以執行命令:source /opt/ros/indigo/setup.bash
- 安裝所有依賴項
# Install the required libraries that are available as debs.
sudo apt-get update
sudo apt-get install -y \
cmake \
g++ \
git \
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
- 安裝ceres solver,下載安裝在主目錄下,由於googlesource.com需要翻牆,這里使用hitcm(張明明)的github地址
# Build and install Ceres.
# git clone https://ceres-solver.googlesource.com/ceres-solver
# cd ceres-solver
git clone https://github.com/hitcm/ceres-solver-1.11.0.git
cd ceres-solver-1.11.0
mkdir build
cd build
cmake .. -G Ninja
ninja
ninja test
sudo ninja install
- 安裝cartographer,下載安裝在主目錄下,這里同樣使用的是hitcm(張明明)的github地址
# Build and install Cartographer.
git clone https://github.com/hitcm/cartographer.git
cd cartographer
mkdir build
cd build
cmake .. -G Ninja
ninja
ninja test
sudo ninja install
- 安裝cartographer_ros,這里使用的是hitcm(張明明)的github地址,由於google官方的教程需要翻牆下載一些文件,因此容易失敗,經驗證hitcm(張明明)對原文件進行了少許修改后可以成功安裝,在他的修改中核心代碼不變,只修改了編譯文件。
We recommend using wstool and rosdep. For faster builds, we also recommend using Ninja.# Install wstool and rosdep.
sudo apt-get update
sudo apt-get install -y python-wstool python-rosdep ninja-build
# Create a new workspace in 'catkin_ws'.
mkdir catkin_ws
cd catkin_ws
wstool init src
# 下載到catkin_ws下面的src文件夾下面
cd src
git clone https://github.com/hitcm/cartographer_ros.git
# 然后到catkin_ws下面運行catkin_make安裝
cd
cd catkin_ws
catkin_make
source ./devel/setup.bash
注意: 如果每次打開一個新的終端時ROS環境變量都能夠自動配置好(即添加到bash會話中),那將會方便得多:echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
如果你只想改變當前終端下的環境變量,你可以執行命令:source ~/catkin_ws/devel/setup.bash
- 運行DEMO
Now that Cartographer and Cartographer’s ROS integration are installed, download the example bags (e.g. 2D and 3D backpack collections of the Deutsches Museum) to a known location, in this case ~/Downloads, and use roslaunch to bring up the demo:# Download the 2D backpack example bag.
wget -P ~/Downloads
https://storage.googleapis.com/cartographer-public-data/bags/backpack_2d/cartographer_paper_deutsches_museum.bag
# Launch the 2D backpack demo.
roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=${HOME}/Downloads/cartographer_paper_deutsches_museum.bag
# Download the 3D backpack example bag.
wget -P ~/Downloads
https://storage.googleapis.com/cartographer-public-data/bags/backpack_3d/cartographer_3d_deutsches_museum.bag
# Launch the 3D backpack demo.
roslaunch cartographer_ros demo_backpack_3d.launch bag_filename:=${HOME}/Downloads/cartographer_3d_deutsches_museum.bag
# Download the Revo LDS example bag.
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/revo_lds/cartographer_paper_revo_lds.bag
# Launch the Revo LDS demo.
roslaunch cartographer_ros demo_revo_lds.launch bag_filename:=${HOME}/Downloads/cartographer_paper_revo_lds.bag
# Download the PR2 example bag.
wget -P ~/Downloads
https://storage.googleapis.com/cartographer-public-data/bags/pr2/2011-09-15-08-32-46.bag
# Launch the PR2 demo.
roslaunch cartographer_ros demo_pr2.launch bag_filename:=${HOME}/Downloads/2011-09-15-08-32-46.bag
The launch files will bring up roscore and rviz automatically.