Cartographer是一个在2D和3D跨越多个平台和传感器配置提供实时同时定位和绘图(SLAM)的系统。此教程根据官方文档以及个人安装经验总结而来,根据该教程进行Cartographer的安装需要但不必须参考笔者的系统配置。
个人电脑配置:
- Ubuntu 14.04 LTS
- 8 GB RAM
- 64-bit,i5-6500 CPU
一、ROS indigo 安装
说明:目前Cartographer支持Indigo、Kinetic两版ROS,在安装之前,首先要安装ROS。在这里介绍Indigo的安装方式,详细参考:这里
1.1.安装前准备:设置你的电脑,使其能从package.ros.org接收软件安装
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
1.2.安装前准备:设置钥匙(keys)
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
1.3. indigo安装,安装版本为官网推荐版本:Desktop-Full
#make sure your Debian package index is up-to-date
sudo apt-get update
#Deskop-Full Install
sudo apt-get install ros-indigo-desktop-full
1.4.安装rosdep
sudo rosdep init
rosdep update
1.5.环境配置
echo "source /opt/ros/indigo/setup.bash" >> ~/.bashrc
source ~/.bashrc
1.6安装 rosinstall
sudo apt-get install python-rosinstall
到此,ROS安装完成。
二、Cartographer_ROS安装
2.1必要的依赖环境,一次性安装
sudo apt-get install -y 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
2.2安装CMake3。默认版本是Cmake2.8一下,编译时会提醒版本过低,故安装CMake3.5
sudo apt-get install cmake3
2.3安装Cartographer_ros。我们使用wstool、rosdep、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
# 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,这一步自动下载cartographer、cartographer_ros、ceres-solver。但是.rosinstall文件中默认ceres-solver的默认下载地址是https://ceres-solver.googlesource.com/ceres-solver.git ,国内无法登入,所以直接进行 wstool update -t src 会出错。解决方法有两个,以下方法二选一。
-------------->>>> start『『『『『『『『『『『『『『『『『
方法一:
wstool update -t src
#出现报错后
cd src
git clone https://github.com/ceres-solver/ceres-solver.git
cd ..
方法二:
cd src
gedit .rosinstall
此时会出现.rosinstall文件,将其中的
https://ceres-solver.googlesource.com/ceres-solver.git
更换为
https://github.com/ceres-solver/ceres-solver.git
然后执行命令:
wstool update -t src
cd ..
』』』』』』』』』』』』』』』』』end <<<<---------------
在解决了上面的问题后,继续执行命令
# 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
-------------->>>> start 『『『『『『『『『『『『『『『
在执行这一步时,如果正常请继续,如果以下报错:
请在Ubuntu文件系统全局搜索 FindEigen3.cmake 文件,并将其复制到 ‘/home/robot/catkin_ws/src/cartographer/cmake/modules’中,然后再次执行 catkin_make_isolated --install --use-ninja 命令。有必要说明的是必须是 FindEigen3.cmake ,少个3(FindEigen.cmake)都不行。
』』』』』』』』』』』』』』』end <<<<------------------
然后执行最后一条命令:
source install_isolated/setup.bash
到这里Cartographer_ros,基本上安装完成。