跟着谷歌官网安装步骤来安装Cartographer without ros 没啥问题,Integration版本就出现一大堆问题,在网上也没有找到类似的,于是耗费数日,终于成功,这里给大家分享一下经验,如果英文好的朋友可以直接查看以下各个参考网址:
首先是万恶的cartographer官网地址:http://google-cartographer-ros.readthedocs.io/en/latest/
ros官网wstool说明:http://wiki.ros.org/wstool
ros官网rosdep说明:http://wiki.ros.org/rosdep
ninja官网说明:https://ninja-build.org
注意carographer对ros版本有所要求Indigo或者Kinetic,这里我们选择较新的Kinetic版本
首先设置源能够并安装ros-kinetic-desktop-full
对于国内,推荐使用清华源,各源设置详情参考:
http://wiki.ros.org/ROS/Installation/UbuntuMirrors
这里我们:
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
sudo apt-get update
//ros构建项目的依赖项
sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential
sudo apt-get install ros-kinetic-desktop-full
结下来参考Cartographer官网教程,前几步都没啥问题
//安装wstool rosdep ninja
apt-get update
sudo apt-get install -y python-wstool python-rosdep ninja-build
mkdir catkin_ws
cd catkin_ws
wstool init src
wstool merge -t src https://raw.githubusercontent.com/googlecartographer/cartographer_ros/master/cartographer_ros.rosinstall
wstool update -t src
直到上面最后一步,可能会报出ceres-solver无法获取,不必慌张,cd catkin_ws/src/之后 vim .rosinstall,将最后一个git来源网址由https://ceres-solver.googlesource.com/ceres-solver.git改为https://github.com/ceres-solver/ceres-solver.git,经过实验,这一步lantern和xx-net都无法从googlesource.com网站获取ceres-solver,还是老老实实改为github吧,这里直接复制粘贴可能会出现格式不对的错误提示,如果出现则手动输入即可。
重新:
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
可能会出现:
ERROR: the following packages/stacks could not have their rosdep keys resolved
to system dependencies (ROS distro is not set. Make sure `ROS_DISTRO` environment variable is set, or use `--rosdistro` option to specify the distro, e.g. `--rosdistro indigo`):
这里说的是环境变量ROS_DISTRO没有设置,ROS_DISTRO是表明ros版本的变量,根据ros官网指南设置环境变量:
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
继续:
rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y
漫长安装后,正确会出现:
#All required rosdeps installed successfully
继续往下:
# 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