cartographer参数调整

一、cartographer安装测试

  基本配置:ubuntu 16.04 (x64),ROS Kinetic

  1、按顺序安装ceres-solver 1.14.0、protobuf 3.5.0、cartographer 1.0.0、cartographer_ros 1.0.0;

    1)ceres-solver在ubuntu 16.04下有预编译包,可以通过apt-get安装;

    2)protobuf在ubuntu 16.04下有预编译包,但版本不匹配,需要从源码安装;

    3)cartographer需要源码安装,安装命令参考官方文档:https://google-cartographer.readthedocs.io/en/latest/index.html

    4)安装依赖时可以通过dpkg –l | grep <software_name>查看依赖是否已经安装;

    5)cartographer_ros可以通过catkin_make直接编译;

  2、参考 https://google-cartographer-ros.readthedocs.io/en/latest/index.html 测试Demo;

    1)此处仅测试了2D Demo;

 

二、cartographer测试问题

  测试问题:在上述测试过程中,cartographer出现了极大的延迟(rosbag play约30min,而在rosbag play结束后,建图仍然需要大约1h),如何解决?

  1、首先检查硬件配置(i7-4500U(1.8GHz,双核四线程),8G RAM),满足cartographer的硬件需求(官方文档所述16G RAM在上述测试中限制不大,通过top命令可知上述测试的RAM使用最大30%左右);

  2、对比cartographer论文(Real-Time Loop Closure in 2D LIDAR SLAM)中的硬件配置(Intel Xeon E5-1650(3.2GHz,六核十二线程));

    (╯‵□′)╯︵┻━┻

  3、所以解决方法分为两种:

    1)分离法:将cartographer运行在高性能机器上,运动终端将传感器信息通过无线网络上传,从技术上来说,ROS作为分布式控制系统可以轻松实现这种功能分离,但是存在两个问题:稳定的无线网络和成本;

    2)妥协法:通过调整参数,降低建图质量和鲁棒性,提高实时性,适合计算资源不足的小型工控机以及中小范围建图应用;

 

三、cartographer参数调整

  cartographer的配置文件在/usr/local/share/cartographer/configuration_files/目录下

  参数调整主要参考cartographer_ros官方文档中的Low Latency:https://google-cartographer-ros.readthedocs.io/en/latest/tuning.html

  以下参数调整根据上述测试过程中使用的硬件配置进行

  1、MAP_BUILDER.num_background_threads=2(=核数(双核四线程=2));

  2、POSE_GRAPH.constraint_builder.sampling_ratio=0.10,对应于约束的数量上限;

  3、POSE_GRAPH.min_score=0.60,成为约束的最低分数,这个值越大,计算速度相对越快,约束数量相对越少,在sampling_ratio较小的情况下,很可能会造成约束过少而导致建图失败,这个值越小,则效果相反,因此这个值可能需要多次调整;

  4、POSE_GRAPH.constraint_builder.fast_correlative_scan_matcher.linear_search_window=5.

    POSE_GRAPH.constraint_builder.fast_correlative_scan_matcher.angular_search_window=math.rad(20.),对应于闭环检测(约束检测)时的搜索范围;

  备注:上述各参数调整核心是闭环检测(约束检测),闭环检测是图优化过程中最为重要的部分,也是最为耗时的部分,因此减少约束总数和搜索范围可以有效提高实时性。

 

四、cartographer_ros

  cartographer_ros配置文件在cartographer_ros/configuration_files/目录下

  cartographer_ros实际应用时需要进行一些参数调整以适配实际情况,以2D建图为例,其配置文件为backpack_2d.lua

  1、一个惯导,发布惯导数据/imu (Imu),惯导坐标系为base_link;

  2、一个普通2D激光雷达,发布雷达数据/scan (LaserScan),tf: base_link->base_laser,

    修改options.num_laser_scans=1,options.num_multi_echo_laser_scans=0;

  3、roslaunch cartographer_ros demo_backpack_2d.launch;

  如果需要使用odom

  4、一个轮速计,发布/odom (Odometry),tf: odom->base_link,

    修改options.published_frame=”odom”,options.use_odometry=true;

  如果没有惯导或不相信其他传感器,而只使用激光雷达数据:

  5、修改cartographer配置文件:

    TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching=true;

 

以上。

你可能感兴趣的