1. 程式人生 > >cartographer 編譯與執行

cartographer 編譯與執行

編譯

# 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

# Merge the cartographer_ros.rosinstall file and fetch code for dependencies.
wstool merge -t src https://raw.githubusercontent.com/googlecartographer/cartographer_ros/master/cartographer_ros.rosinstall
wstool update -t src

# Install proto3.
src/cartographer/scripts/install_proto3.sh

# Install deb dependencies.
# The command 'sudo rosdep init' will print an error if you have already
# executed it since installing ROS. This error can be ignored.
sudo rosdep init
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y

# Build and install.
catkin_make_isolated --install --use-ninja
source install_isolated/setup.bash

 執行

# 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/with_intensities/b3-2016-04-05-14-14-00.bag

# Launch the 3D backpack demo.
roslaunch cartographer_ros demo_backpack_3d.launch bag_filename:=${HOME}/Downloads/b3-2016-04-05-14-14-00.bag

 效果圖

報錯

在執行 "catkin_make_isolated --install --use-ninja" 時候,報出如下關於libgflags的錯誤。

/usr/local/lib/libgflags.a: error adding symbols: Bad value 
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
<== Failed to process package 'cartographer_rviz':

 解決

重新編譯libgflags,在編譯的時候使用 "export CXXFLAGS="-fPIC" && cmake .. && make VERBOSE=1" 代替 cmake .. ,具體操作如下:

git clone https://github.com/gflags/gflags
cd ~/gflags
mkdir build
cd build 
export CXXFLAGS="-fPIC" && cmake .. && make VERBOSE=1
make -j8
sudo make install

然後重新 "catkin_make_isolated --install --use-ninja",並接著下邊的操作完成cartographer的編譯與執行。

轉載請註明出處~~