作者:1凡evan | 来源:互联网 | 2023-09-06 11:54
一、Cartographer简介Cartographer是google开源的通用2D和3D定位与地图同步构建的SLAM工具,并提供ROS接口。官网地址:https:github.comgoo
一、Cartographer简介
Cartographer是google开源的通用2D和3D定位与地图同步构建的SLAM工具,并提供ROS接口。官网地址:https://github.com/googlecartographer
二、安装方法
1、安装全部依赖项
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-kinetic-tf2-eigen \
libatlas-base-dev \
libsuitesparse-dev \
liblapack-dev
2、安装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
3、安装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
4、安装cartographer_ros,这里使用的是hitcm(张明明)的github地址,由于google官方的教程需要FQ下载一些文件,因此容易失败,经验证hitcm(张明明)对原文件进行了少许修改后可以成功安装,在他的修改中核心代码不变,只修改了编译文件。
# 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.zsh
5、改变命令进行编译
catkin_make_isolated --install --use-ninja
6、修改cartographer_ros--cartographer_ros--launch--demo_revo_lds.launch
"
/use_sim_time" value=
"true" />
"cartographer_node" pkg="cartographer_ros"
type="cartographer_node" args="
-configuration_directory $(find cartographer_ros)/configuration_files
-configuration_basename revo_lds.lua"
output="screen">
"scan" to="scan" />
"rviz" pkg="rviz" type="rviz" required="true"
args="-d $(find cartographer_ros)/configuration_files/demo_2d.rviz" />
修改cartographer_ros--cartographer_ros--configuration_files--revo_lds.lua
options = {
map_builder = MAP_BUILDER,
sensor_bridge = {
horizontal_laser_min_range = 0.3,
horizontal_laser_max_range = 8,
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_constant_odometry_variance = true,
constant_odometry_translational_variance = 1e-2,
constant_odometry_rotational_variance = 1e-1,
use_horizontal_laser = true,
use_horizontal_multi_echo_laser = false,
horizontal_laser_min_range = 0.1,
horizontal_laser_max_range = 30.,
horizontal_laser_missing_echo_ray_length = 5.,
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
修改完以上2个文件重新编译一下,命令行输入
catkin_make_isolated --install --use-ninja
7、运行
最后命令行中运行rplidar的Node和launch文件
roslaunch rplidar_ros rplidar.launch
roslaunch cartographer_ros demo_revo_lds.launch