slam :google鐳射雷達slam演算法Cartographer的安裝及bag包demo測試

NO IMAGE

Cartographer 是google於2016年9月開源的一套鐳射雷達slam演算法,精度和效果在業界處於領先水準。本文將演示在ROS JADE版中的安裝使用方法。
0_1481260673955_lidar1.png

操作步驟:

1.安裝依賴包

# 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 \
libcairo2-dev \
libeigen3-dev \
libgflags-dev \
libgoogle-glog-dev \
liblua5.2-dev \
libprotobuf-dev \
libsuitesparse-dev \
libwebp-dev \
ninja-build \
protobuf-compiler \
python-sphinx

2.安裝ceres solver

cd  ~/Documents
git clone https://github.com/BlueWhaleRobot/ceres-solver.git
cd ceres-solver
mkdir build
cd build
cmake ..
make -j
sudo make install

3.安裝cartographer

cd  ~/Documents
git clone https://github.com/BlueWhaleRobot/cartographer.git
cd cartographer
mkdir build
cd build
cmake ..
make -j
sudo make install

4.安裝cartographer_ros

cd ~/Documents/ros/src   #請修改路徑到自己的ROS catkin工作空間
git clone https://github.com/BlueWhaleRobot/cartographer_ros.git
cd ..
catkin_make

5.安裝已完成,開始下載測試用的bag檔案

點選下述連結下載檔案,儲存到桌面
https://storage.googleapis.com/cartographer-public-data/bags/backpack_2d/cartographer_paper_deutsches_museum.bag

6.啟動demo演示,正常可以看到rviz啟動並開始建圖

根據個人平臺計算能力不同,本demo完整執行時間一般為半個小時到1個小時之間

roslaunch cartographer_ros demo_backpack_2d.launch  bag_filename:=${HOME}/Desktop/cartographer_paper_deutsches_museum.bag
roslaunch cartographer_ros demo_backpack_2d.launch  bag_filename:=${HOME}/cartographer_paper_deutsches_museum.bag

 

7.儲存地圖,結束測試

rosservice call /finish_trajectory "stem: 'test'"

0_1481262253284_lidar2.png
現在在home目錄下的.ros資料夾內會生成建立的地圖檔案,這兩個檔案(pgm 和 yaml)在ros中的map_server中可以載入使用

  1. 注意: 如果每次開啟一個新的終端時ROS環境變數都能夠自動配置好(即新增到bash會話中),那將會方便得多:
    echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
    source ~/.bashrc
    如果你只想改變當前終端下的環境變數,你可以執行命令:
    source ~/catkin_ws/devel/setup.bash
  2. 執行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.