1、【推荐】快速安装方法

cartographer_ws下载地址

cartographer_ws 是我下载完成验证过的 只需要下载放在主目录下 和正常的工作空间一样进行编译即可 国内推荐使用gitee源下载

2020.08.02

国内安装cartographer十分困难,因此我将其下载放入工作空间中

兼容:已经测试: Ubuntu16.04+Kinetic

使用方法:下载or克隆到朱目录下

1
cd ~

1.国外:Github

1
git clone https://github.com/yltzdhbc/cartographer_ws.git

1.国内:Gitee

1
git clone https://gitee.com/yltzdhbc/cartographer_ws.git

2.然后进入工作工作空间编译

1
2
cd ~/cartographer_ws
catkin_make_isolated --install --use-ninja

3.声明工作空间

1
echo "source ~/cartographer_ws/install_isolated/setup.bash" >> ~/.bashrc

4.测试 下载bag运行

1
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_2d/cartographer_paper_deutsches_museum.bag
1
roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=${HOME}/Downloads/cartographer_paper_deutsches_museum.bag

5.如果能运行则安装成功

6.enjoy!

2、探究原因

Cartographer ROS 国内安装失败

系统要求

Cartographer ROS 支持四种版本的ROS
Indigo
Kinetic
Lunar
Melodic

Cartographer总是安装失败,原因是有一个地方需要从google drive下载
以下来源于官方文档
https://google-cartographer-ros.readthedocs.io/en/latest/compilation.html

编译 & 安装

编译Cartographer ROS,我们推荐使用 wstool和rosdep,为了更快的编译,我们同样推荐使用Ninja

1
2
sudo apt-get update
sudo apt-get install -y python-wstool python-rosdep ninja-build

创建一个新的cartographer_ros工作空间名为 ‘catkin_ws’.

1
2
3
4
5
6
mkdir catkin_ws
cd catkin_ws
wstool init src
wstool merge -t src https://raw.githubusercontent.com/googlecartographer/cartographer_ros/master/cartographer_ros.rosinstall
sudo gedit ~/catkin_ws/src/.rosinstall #这里更改
wstool update -t src

!!注意:更改ceres-solver的uri为
uri: https://github.com/ceres-solver/ceres-solver.git
在这里插入图片描述

安装 cartographer_ros’ 的依赖 (proto3 and deb packages). 命令 ‘sudo rosdep init’ 将会打印一个错误如果你之前已经安装了这些文件. 这个错误可以忽略

1
2
3
4
src/cartographer/scripts/install_proto3.sh
sudo rosdep init
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y

编译、安装

1
catkin_make_isolated --install --use-ninja

测试

1
roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=${HOME}/Downloads/cartographer_paper_deutsches_museum.bag

3、Cartographer lua 脚本报错

在使用古月的mrobot的cartographer例程的时候会报错

1
attempt to index global 'SPARSE_POSE_GRAPH' (a nil value)ailed: status == 0 (2 vs. 0) 

原因是新版本的cartographer的脚本写法和之前不一样,参照 cartographer_ros/cartographer_ros/configuration_files/revo_lds.lua的写法 改进rplidar.lua

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
include "map_builder.lua"
include "trajectory_builder.lua"

options = {
map_builder = MAP_BUILDER,
trajectory_builder = TRAJECTORY_BUILDER,
map_frame = "map",
tracking_frame = "laser_link",
published_frame = "laser_link",
odom_frame = "odom",
provide_odom_frame = true,
publish_frame_projected_to_2d = false,
use_odometry = false,
use_nav_sat = false,
use_landmarks = false,
num_laser_scans = 1,
num_multi_echo_laser_scans = 0,
num_subdivisions_per_laser_scan = 1,
num_point_clouds = 0,
lookup_transform_timeout_sec = 0.2,
submap_publish_period_sec = 0.3,
pose_publish_period_sec = 5e-3,
trajectory_publish_period_sec = 30e-3,
rangefinder_sampling_ratio = 1.,
odometry_sampling_ratio = 1.,
fixed_frame_pose_sampling_ratio = 1.,
imu_sampling_ratio = 1.,
landmarks_sampling_ratio = 1.,
}

MAP_BUILDER.use_trajectory_builder_2d = true

TRAJECTORY_BUILDER_2D.submaps.num_range_data = 35
TRAJECTORY_BUILDER_2D.min_range = 0.3
TRAJECTORY_BUILDER_2D.max_range = 8.
TRAJECTORY_BUILDER_2D.missing_data_ray_length = 1.
TRAJECTORY_BUILDER_2D.use_imu_data = false
TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching = true
TRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.linear_search_window = 0.1
TRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.translation_delta_cost_weight = 10.
TRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.rotation_delta_cost_weight = 1e-1

POSE_GRAPH.optimization_problem.huber_scale = 1e2
POSE_GRAPH.optimize_every_n_nodes = 35
POSE_GRAPH.constraint_builder.min_score = 0.65

return options

使用 POSE_GRAPH 替换 SPARSE_POSE_GRAPH
在option中增加use_nav_sat 等配置,再运行就不会报错了。