基于Cartographer的安装过程比较简单,基本就是ubuntu18.04,ros-melodic,cartographer,cartographer-ros。本文主要针对国内上网不便的情况,给出快速安装的过程说明。
sudo sh -c 'echo "deb https://mirrors.ustc.edu.cn/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt update
sudo apt install ros-melodic-desktop-full
sudo apt-get -y install python-rosdep
为了把rosdep的依赖设置成本地,需要修改多个文件,具体如下。
cd ~/
git clone https://gitee.com/c1h2/rosdistro.git
cd /home/h1c/rosdistro/rosdep/sources.list.d/
将20-default.list的所有内容替换为:
# os-specific listings first
yaml file:///home/h1c/rosdistro/rosdep/osx-homebrew.yaml osx
# generic
yaml file:///home//rosdistro/rosdep/base.yaml
yaml file:///home//rosdistro/rosdep/python.yaml
yaml file:///home//rosdistro/rosdep/ruby.yaml
gbpdistro file:///home//rosdistro/releases/fuerte.yaml fuerte
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
替换文件中的对应内容为:
FUERTE_GBPDISTRO_URL = 'file:///home//rosdistro/releases/fuerte.yaml'
替换文件中的对应内容为:
REP3_TARGETS_URL = 'file:///home//rosdistro/releases/targets.yaml'
替换文件中的对应内容为:
DEFAULT_INDEX_URL = 'file:///home//rosdistro/index-v4.yaml'
替换文件中的对应内容为:
DEFAULT_SOURCES_LIST_URL = 'file:///home//rosdistro/rosdep/sources_list.d/20-default.list'
sudo rosdep init
rosdep update
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential
rosversion -d
sudo apt-get update
sudo apt-get install ros-melodic-cartographer*
运行如下命令确认protoc版本是3.0以上。
protoc --version
sudo apt-get update
sudo apt-get install -y \
clang \
cmake \
g++ \
git \
google-mock \
libboost-all-dev \
libcairo2-dev \
libcurl4-openssl-dev \
libeigen3-dev \
libgflags-dev \
libgoogle-glog-dev \
liblua5.2-dev \
libsuitesparse-dev \
lsb-release \
ninja-build \
stow
需要从源码安装如下包:
mkdir -p ~/carto_ws
cd ~/carto_ws
wstool init src
#wstool merge -t src https://raw.githubusercontent.com/cartographer-project/cartographer_ros/master/cartographer_ros.rosinstall
- git:
local-name: cartographer
uri: https://github.com/cartographer-project/cartographer.git
version: master
- git:
local-name: cartographer_ros
uri: https://github.com/cartographer-project/cartographer_ros.git
version: master
- git:
local-name: ceres-solver
uri: https://github.com/ceres-solver/ceres-solver.git
version: 1.13.0
wstool update -t src
cd ~/carto_ws/src
git clone https://github.com/cartographer-project/cartographer.git
git clone https://github.com/cartographer-project/cartographer_ros.git
git clone https://github.com/ceres-solver/ceres-solver.git
cd ~/carto_ws/src/cartographer/scripts
./install_abseil.sh
rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y
catkin_make_isolated --install --use-ninja
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_2d/cartographer_paper_deutsches_museum.bag
cd ~/carto_ws
source install_isolated/setup.bash
roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=${HOME}/Downloads/cartographer_paper_deutsches_museum.bag