一、在安装cartographer前,需要系统满足如下的要求:
- 64-bit, modern CPU (e.g. 3rd generation i7)
- 16 GB RAM
- Ubuntu 14.04 (Trusty)
- gcc version 4.8.4
- ROS Indigo
本人是自己设计制作的机器人平台,只有一个激光雷达传感器URG-04LX-UG01。本人就是利用这个传感器实现的SLAM。
二、安装过程及命令:
# 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
# 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
source install_isolated/setup.bash
备注:
问题:在catkin_make_isolated –install –use-ninja这一步,需要连接国外网下载ceres-solver,如果没有翻墙,会提示下载ceres-solver失败。
解决方法:
1.购买个VPN,连上国外网,翻墙后再运行该步骤的命令
- 打开下面这个文件,修改git下载的地址
build_isolated/ceres_solver/install/ceres_src-prefix/tmp/ceres_src-gitclone.cmake
黑体部分修改成如下这样
while(error_code AND 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
修改后的文件如下:
1
2
3
4
5
6
7
|
<
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"</code> <code class="xml color1">output</code><code class="xml plain">=</code><code class="xml string">"screen"</code><code class="xml plain">></code></div><div class="line number4 index3 alt1"><code class="xml spaces"> </code><code class="xml plain"><</code><code class="xml keyword">remap</code> <code class="xml color1">from</code><code class="xml plain">=</code><code class="xml string">"scan"</code> <code class="xml color1">to</code><code class="xml plain">=</code><code class="xml string">"scan"</code> <code class="xml plain">/></code></div><div class="line number5 index4 alt2"><code class="xml spaces"> </code><code class="xml plain"></</code><code class="xml keyword">node</code><code class="xml plain">> </code></div><div class="line number6 index5 alt1"><code class="xml spaces"> </code><code class="xml plain"><</code><code class="xml keyword">node</code> <code class="xml color1">name</code><code class="xml plain">=</code><code class="xml string">"rviz"</code> <code class="xml color1">pkg</code><code class="xml plain">=</code><code class="xml string">"rviz"</code> <code class="xml color1">type</code><code class="xml plain">=</code><code class="xml string">"rviz"</code> <code class="xml color1">required</code><code class="xml plain">=</code><code class="xml string">"true"</code> <code class="xml color1">args</code><code class="xml plain">=</code><code class="xml string">"-d $(find cartographer_ros)/configuration_files/demo_2d.rviz"
/>
</
launch
>
|
3.修改配置参数文件revo_lds.lua
vim ../configuration_files/revo_lds.lua
修改后的文件如下:
01
02
03
04
05
06
07
08
09
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
49
50
51
52
53
|
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可能需要做相应的调整。
本人博客:http://blog.csdn.net/happiness_jia/article/details/52856197
参考资料:
https://google-cartographer-ros.readthedocs.io/en/latest/index.html
http://wiki.ros.org/hokuyo_node/Tutorials/UsingTheHokuyoNode
</div>
<div class="clear"></div>
</div>