http://blog.youkuaiyun.com/happiness_jia/article/details/52856197
一、在安装cartographer前,需要系统满足如下的要求:
· 64-bit, modern CPU (e.g. 3rd generation i7)
· 16 GB RAM
· Ubuntu 14.04 (Trusty)
· gcc version 4.8.4
· ROS Indigo
二、安装过程及命令:
# Install wstool and rosdep.
sudo apt-getupdate
sudo apt-getinstall -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 fetchcode for dependencies.
wstool merge -tsrchttps://raw.githubusercontent.com/googlecartographer/cartographer_ros/master/cartographer_ros.rosinstall
wstool update -tsrc
# Install deb dependencies.
rosdep update
rosdep install--from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y
# Build and install.
catkin_make_isolated --install --use-ninja
isolated --install --use-ninja
source install_isolated/setup.bash
备注:
问题:在catkin_make_isolated --install --use-ninja这一步,需要连接国外网下载ceres-solver,如果没有翻墙,会提示下载ceres-solver失败。
解决方法:
1.购买个VPN,连上国外网,翻墙后再运行该步骤的命令
2. 打开下面这个文件,修改git下载的地址
build_isolated/ceres_solver/install/ceres_src-prefix/tmp/ceres_src-gitclone.cmake
红色部分修改成如下这样
while(error_codeAND number_of_tries LESS 3)
execute_process(
COMMAND "/usr/bin/git" clone"https://github.com/ceres-solver/ceres-solver" "ceres_src"
WORKING_DIRECTORY
修改好后从新运行该步骤命令
三、运行google提供的demo,显示google采集到的一个房间的地图。
# 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
备注,在运行测试这个demo的过程中,本人出现了两个错误:
1.rviz提示错误。原因是我是用teamviewer远程连到机器人上操作的,而rviz无法在远程运行显示。所以本人只好在机器人上接上了显示器,这样rviz就能正常运行了
2.playbag提示错误。原因是cartographer_paper_deutsches_museum.bag这个包没有完整下载。完整下载应该是500M左右。
四、利用cartographer,实现实时的构图定位
1.先将激光雷达节点的运行起来
rosrun hokuyo hokuyo
2.修改demo_revo_lds.launch
vim demo_revo_lds.launch
修改后的文件如下:
<launch>
<param name="/use_sim_time" value="true" />
<node name="cartographer_node" pkg="cartographer_ros"
type="cartographer_node" args="
-configuration_directory $(find cartographer_ros)/configuration_files
-configuration_basename revo_lds.lua"
output="screen">
<remap from="scan" to="scan" />
</node>
<node name="rviz" pkg="rviz" type="rviz" required="true"
args="-d $(find cartographer_ros)/configuration_files/demo_2d.rviz" />
</launch>
3.修改配置参数文件revo_lds.lua
vim ../configuration_files/revo_lds.lua
修改后的文件如下:
include "map_builder.lua"
options = {
map_builder = MAP_BUILDER,
sensor_bridge = {
horizontal_laser_min_range = 0.3,
horizontal_laser_max_range = 5.6,
horizontal_laser_missing_echo_ray_length = 1.2,
constant_odometry_translational_variance = 0.,
constant_odometry_rotational_variance = 0.,
},
map_frame = "map",
tracking_frame = "laser",
published_frame = "laser",
odom_frame = "odom",
provide_odom_frame = true,
use_odometry_data = false,
use_horizontal_laser = true,
use_horizontal_multi_echo_laser = false,
num_lasers_3d = 0,
lookup_transform_timeout_sec = 0.2,
submap_publish_period_sec = 0.3,
pose_publish_period_sec = 5e-3,
}
MAP_BUILDER.use_trajectory_builder_2d = true
TRAJECTORY_BUILDER_2D.use_imu_data = false
TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching = true
SPARSE_POSE_GRAPH.optimization_problem.huber_scale = 1e2
return options
4.重新编译
catkin_make_isolated --install --use-ninja
5.运行脚本进行实时构图定位
roslaunch cartographer_ros demo_revo_lds.launch
备注:
1.如果您使用的激光雷达不同,上面修改demo_revo_lds.launch和配置参数文件revo_lds.lua可能需要做相应的调整。
以上方案安装要是不行,可能就是下载不了一些ceres非线性优化库啦什么的原因,用国内张明明的github下载
http://www.cnblogs.com/wenhust/p/5961017.html
Cartographer简介
Cartographer is a system that provides real-time simultaneous localization and mapping (SLAM) in 2D and 3D across multiple platforms and sensor configurations. This project provides Cartographer's ROS integration.
Cartographer是google开源的通用2D和3D定位与地图同步构建的SLAM工具,并提供ROS接口。
官网地址:https://github.com/googlecartographer
安装说明
- 官网提供了基于Ubuntu14.04(Trusty)和ROS(indigo)的安装和测试说明,有博客写道在Ubuntu16.04(Xenial)和ROS(Kinetic)上安装和测试成功,该博客也有Cartographer的介绍和安装流程:
http://blog.youkuaiyun.com/zhangrelay/article/details/52757573 - 以下安装流程主要参考hitcm(张明明)的博客及Cartographer的官方安装教程:
- hitcm(张明明)博客:http://www.cnblogs.com/hitcm/p/5939507.html
- 官方安装教程Getting started without ROS: https://google-cartographer.readthedocs.io/en/latest/
- 官方安装教程Getting started with ROS: https://google-cartographer-ros.readthedocs.io/en/latest/
安装流程
-
- 安装Ubuntu14.04(Trusty),将安装镜像文件制作U盘镜像,进入BIOS或WIN10下进入设置->更新和安全->恢复->高级启动,使用U盘启动,完成Ubuntu14.04(Trusty)的安装。
- 安装ROS(indigo),参考文件http://wiki.ros.org/indigo/Installation/Ubuntu(英文原版)、http://wiki.ros.org/cn/indigo/Installation/Ubuntu(中文翻译);
注意: 如果每次打开一个新的终端时ROS环境变量都能够自动配置好(即添加到bash会话中),那将会方便得多:
echo "source /opt/ros/indigo/setup.bash" >> ~/.bashrc
source ~/.bashrc
如果你安装有多个ROS版本,~/.bashrc
必须只能source
你当前使用版本所对应的setup.bash
。
如果你只想改变当前终端下的环境变量,你可以执行命令:
source /opt/ros/indigo/setup.bash
- 安装所有依赖项
# Install the required libraries that are available as debs.
sudo apt-get update
sudo apt-get install -y \
cmake \
g++ \
git \
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
- 安装ceres solver,下载安装在主目录下,由于googlesource.com需要FQ,这里使用hitcm(张明明)的github地址
# Build and install Ceres.
# git clone https://ceres-solver.googlesource.com/ceres-solver
# cd ceres-solver
git clone https://github.com/hitcm/ceres-solver-1.11.0.git
cd ceres-solver-1.11.0
mkdir build
cd build
cmake .. -G Ninja
ninja
ninja test
sudo ninja install
- 安装cartographer,下载安装在主目录下,这里同样使用的是hitcm(张明明)的github地址
# Build and install Cartographer.
git clone https://github.com/hitcm/cartographer.git
cd cartographer
mkdir build
cd build
cmake .. -G Ninja
ninja
ninja test
sudo ninja install
- 安装cartographer_ros,这里使用的是hitcm(张明明)的github地址,由于google官方的教程需要FQ下载一些文件,因此容易失败,经验证hitcm(张明明)对原文件进行了少许修改后可以成功安装,在他的修改中核心代码不变,只修改了编译文件。
We recommend using wstool and rosdep. For faster builds, we also recommend using 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
# 下载到catkin_ws下面的src文件夹下面
cd src
git clone https://github.com/hitcm/cartographer_ros.git
# 然后到catkin_ws下面运行catkin_make安装
cd
cd catkin_ws
catkin_make
source ./devel/setup.bash
注意: 如果每次打开一个新的终端时ROS环境变量都能够自动配置好(即添加到bash会话中),那将会方便得多:
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
如果你只想改变当前终端下的环境变量,你可以执行命令:
source ~/catkin_ws/devel/setup.bash
- 运行DEMO
Now that Cartographer and Cartographer’s ROS integration are installed, download the example bags (e.g. 2D and 3D backpack collections of the Deutsches Museum) to a known location, in this case ~/Downloads, and use roslaunch to bring up the demo:
# 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/cartographer_3d_deutsches_museum.bag
# Launch the 3D backpack demo.
roslaunch cartographer_ros demo_backpack_3d.launch bag_filename:=${HOME}/Downloads/cartographer_3d_deutsches_museum.bag
# Download the Revo LDS example bag.
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/revo_lds/cartographer_paper_revo_lds.bag
# Launch the Revo LDS demo.
roslaunch cartographer_ros demo_revo_lds.launch bag_filename:=${HOME}/Downloads/cartographer_paper_revo_lds.bag
# Download the PR2 example bag.
wget -P ~/Downloads
https://storage.googleapis.com/cartographer-public-data/bags/pr2/2011-09-15-08-32-46.bag
# Launch the PR2 demo.
roslaunch cartographer_ros demo_pr2.launch bag_filename:=${HOME}/Downloads/2011-09-15-08-32-46.bag
The launch files will bring up roscore and rviz automatically.