编译
# 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的编译与运行。
转载请注明出处~~