Cartographer 简介
github官方给出的介绍是这样的:
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接口。
安装构建
我使用的是ros-kinect版本 Ubuntu是16.04
- 安装所需要的工具集等(我将基本上会用到的所有库都列出来了,实际上我自己在安装的时候有很多之前都已经安装过了,如果你的环境已经安装过了的可以直接略过)
sudo apt-get update
sudo apt-get install -y \
python-wstool \
python-rosdep \
ninja-build \
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-kinect-tf2-eigen \
libatlas-base-dev \
libsuitesparse-dev \
liblapack-dev
- 初始化工作空间
mkdir google_ws
cd google_ws
wstool init src
- 设置下载地址并下载源码
注意:因为源地址的原因,需要我们在终端下配置一下代理才能正常下载,如果使用的是shadowsock,可以在终端输入
export ALL_PROXY=socks5://127.0.0.1:1080
如果是使用的其他代理工具,可以按照下列格式改成自己的配置以生效
export http_proxy="http://localhost:port"
export https_proxy="http://localhost:port"
没有代理的小伙伴,可以通过修改src/.rosinstall文件中的下载地址,将原来的地址更换为可以访问的ceres-solver的github地址,再使用命令下载就好了。
image.pngwstool merge -t src https://raw.githubusercontent.com/googlecartographer/cartographer_ros/master/cartographer_ros.rosinstall
wstool update -t src
- 安装proto3
src/cartographer/scripts/install_proto3.sh
- 安装deb依赖项
注意:如果之前已经安装了ros的话,可以跳过下面的前两个命令。
sudo rosdep init
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y - 编译
catkin_make_isolated --install --use-ninja
source install_isolated/setup.bash
下载和运行demo
此时只能使用代理配置之后才能下载官方demo了
下载2D demo
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_2d/cartographer_paper_deutsches_museum.bag
运行2D demo
roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=${HOME}/Downloads/cartographer_paper_deutsches_museum.bag
下载3D demo
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_3d/with_intensities/b3-2016-04-05-14-14-00.bag
运行3D demo
roslaunch cartographer_ros demo_backpack_3d.launch bag_filename:=${HOME}/Downloads/b3-2016-04-05-14-14-00.bag
应用功能包
- 需要添加自己的launch文件,此处以rpidar为例(cartographer_demo_rplidar.launch),将该launch文件放到google_ws/src/cartographer_ros/cartographer_ros/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 rplidar.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>
- 配置参数,需要参考google_ws/src/cartographer_ros/cartographer_ros/configuration_files目录下的revo_lds.lua文件来配置自己需要的参数,此处以rplidar为例,rplidar.lua。添加或修改后需要重新编译才能生效。
-- Copyright 2016 The Cartographer Authors
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
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,
use_odometry = 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,
}
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
SPARSE_POSE_GRAPH.optimization_problem.huber_scale = 1e2
SPARSE_POSE_GRAPH.optimize_every_n_scans = 35
SPARSE_POSE_GRAPH.constraint_builder.min_score = 0.65
return options
然后就可以通过我们的launch文件来使用cartographer功能包了。
网友评论