要求:
64-bit, modern CPU (e.g. 3rd generation i7)
16 GB RAM
Ubuntu 18.04 (Bionic), 20.04 (Focal)
gcc version 6.3.0, 7.5.0, 9.3.0
参考安装指南:https://google-cartographer-ros.readthedocs.io/en/latest/compilation.html
cartographer
cartographer_ros
建立cartographer_ws/src,并把以上两个文件放入到src下面:
sudo apt-get update
sudo apt-get install -y python-wstool python-rosdep ninja-build stow
sudo rosdep init
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y
如果失败,参照:Ubuntu下多版本sophus、opencv使用: 3. 鱼香ROS一键安装程序包依赖
wget http://fishros.com/install -O fishros && . fishros
rosdepc install -y --from-paths src --ignore-src --rosdistro $ROS_DISTRO
src/cartographer/scripts/install_abseil.sh
同时卸载方式为:
sudo apt-get remove ros-${ROS_DISTRO}-abseil-cpp
catkin_make_isolated --install --use-ninja
2D数据集
3D数据集
建图:
2D
roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=${HOME}/Downloads/cartographer_paper_deutsches_museum.bag
3D:
roslaunch cartographer_ros demo_backpack_3d.launch bag_filename:=${HOME}/Downloads/b3-2016-04-05-14-14-00.bag
纯定位
下载2D数据集:
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_2d/b2-2016-04-05-14-44-52.bag
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_2d/b2-2016-04-27-12-31-41.bag
一个用来定位一个用来建立地图,
roslaunch cartographer_ros offline_backpack_2d.launch bag_filenames:=${HOME}/Downloads/b2-2016-04-05-14-44-52.bag
roslaunch cartographer_ros demo_backpack_2d_localization.launch \
load_state_filename:=${HOME}/Downloads/b2-2016-04-05-14-44-52.bag.pbstream \
bag_filename:=${HOME}/Downloads/b2-2016-04-27-12-31-41.bag
下载3D数据集,操作相同:
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_3d/b3-2016-04-05-13-54-42.bag
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_3d/b3-2016-04-05-15-52-20.bag
roslaunch cartographer_ros offline_backpack_3d.launch bag_filenames:=${HOME}/Downloads/b3-2016-04-05-13-54-42.bag
roslaunch cartographer_ros demo_backpack_3d_localization.launch \
load_state_filename:=${HOME}/Downloads/b3-2016-04-05-13-54-42.bag.pbstream \
bag_filename:=${HOME}/Downloads/b3-2016-04-05-15-52-20.bag
backpack_2d.launch:
backpack_2d.lua:
修改以下几句:
num_laser_scans = 0,
num_multi_echo_laser_scans = 0,
num_subdivisions_per_laser_scan = 1,
num_point_clouds = 1,
添加几句:
MAP_BUILDER.use_trajectory_builder_2d = true
TRAJECTORY_BUILDER_2D.use_imu_data = false
TRAJECTORY_BUILDER_2D.num_accumulated_range_data = 1
TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching = true
参照:https://www.codeleading.com/article/77834618087/
完整的backpack_2d.lua:
include "map_builder.lua"
include "trajectory_builder.lua"
options = {
map_builder = MAP_BUILDER,
trajectory_builder = TRAJECTORY_BUILDER,
map_frame = "map",
tracking_frame = "base_link",
published_frame = "base_link",
odom_frame = "odom",
provide_odom_frame = true,
publish_frame_projected_to_2d = false,
use_pose_extrapolator = true,
use_odometry = false,
use_nav_sat = false,
use_landmarks = false,
num_laser_scans = 0,
num_multi_echo_laser_scans = 0,
num_subdivisions_per_laser_scan = 1,
num_point_clouds = 1,
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.use_imu_data = false
TRAJECTORY_BUILDER_2D.num_accumulated_range_data = 1
TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching = true
return options
backpack_2d.urdf: 为激光雷达的frame_id,imu暂且不管
<joint name="velodyne_joint" type="fixed"> 与base_link链接情况,暂且理解base_link为车体坐标系
<parent link="base_link" />
<child link="velodyne" />
<origin xyz="0.1007 0 0.0558" />
joint>
完整的backpack_2d.urdf:
<robot name="cartographer_backpack_2d">
<material name="orange">
<color rgba="1.0 0.5 0.2 1" />
material>
<material name="gray">
<color rgba="0.2 0.2 0.2 1" />
material>
<link name="imu_link">
<visual>
<origin xyz="0 0 0" />
<geometry>
<box size="0.06 0.04 0.02" />
geometry>
<material name="orange" />
visual>
link>
<link name="velodyne">
<visual>
<origin xyz="0 0 0" />
<geometry>
<cylinder length="0.05" radius="0.03" />
geometry>
<material name="gray" />
visual>
link>
<link name="base_link" />
<joint name="imu_link_joint" type="fixed">
<parent link="base_link" />
<child link="imu_link" />
<origin xyz="0 0 0" />
joint>
<joint name="velodyne_joint" type="fixed">
<parent link="base_link" />
<child link="velodyne" />
<origin xyz="0.1007 0 0.0558" />
joint>
robot>
roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=/home/xxx/a.bag
完成轨迹, 不接受进一步的数据:
新开终端:
注意要进行source,不然无法启用rosservice
source ~/cartographer/devel_isolated/setup.bash
rosservice call /finish_trajectory 0
序列化保存其当前状态
rosservice call /write_state "{filename: '${HOME}/Downloads/mymap.pbstream'}"
将pbstream转换为pgm和yaml
rosrun cartographer_ros cartographer_pbstream_to_ros_map -map_filestem=${HOME}/Downloads/mymap -pbstream_filename=${HOME}/Downloads/mymap.pbstream -resolution=0.05
或者
roslaunch cartographer_ros assets_writer_ros_map.launch bag_filenames:=/home/xxxxx/a.bag pose_graph_filename:=/home/xxxx/a.bag.pbstream -resolution=0.05
demo_backpack_2d_localization.launch:
添加:
<remap from="points2" to="/velodyne_points" />
注释:
<!--
</launch> -->改由手动rosbag play xx.bag -s 50
roslaunch cartographer_ros demo_backpack_2d_localization.launch load_state_filename:=/home/xxxx/a.bag.pbstream
启动bag包:
rosbag play xx.bag -s 50
-s 50表示在bag第50s的时候启动
catkin_make_isolated --install --use-ninja
occupancy_grid_node_main.cc中的 occupancy_grid_publisher_.publish(*msg_ptr);
注释掉
backpack_2d.launch和demo_backpack_2d_localization.launch添加:
backpack_2d.lua:修改为TRAJECTORY_BUILDER_2D.use_imu_data = true
具体操作系列:
Cartographer用于机器人纯定位
cartographer建图,重定位及发布消息结构为nav_msgs::Odometry的odom话题
ROS小车记录系列(二)IMU采集、过滤,与odom数据融合,发布新的odom话题
ROS小车记录系列(八)树莓派4b安装cartographer,使用官方bag包测试建图
cartographer_ros定位功能位姿获取与重定位设置
cartographer pure_localization 纯定位修改 +初始化位置
ROS小车,乐视深度相机+cartographer+move_base从零开始配置导航
cartographer+move_base在gazebo中给px4添加激光雷达并接入ROS进行SLAM自动导航避障
第一讲【ROS-SLAM】2D激光雷达 cartographer构建地图
第二讲 【cartographer】Ubuntu16.04 kinetic 最新版cartographer安装
第三讲 【cartographer】 添加功能以从RVIZ为纯本地化模式设置初始姿势
第四讲 【cartographer】纯定位 纯本地化 pure_localization
第五讲【cartographer】在仿真环境中 建图 纯定位
第六讲【cartographer】纯定位参数优化(初级篇)
Cartographer魔改 cartographer定位模式下设置起始位姿——快速重定位