运行 Cartographer的配置参数比较重要,稍微不注意就会报错,例如一个常见的错误类型:
[ERROR] [1602741280.449037435, 153.231000000]: Ignoring transform from authority "unknown_publisher" with frame_id and child_frame_id "odom" because they are the same
类似错误大多是因为配置文件设置的不正确。
以turtlebot3配置文件turtlebot3_lds_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 = "odom",
odom_frame = "odom",
provide_odom_frame = true,
publish_frame_projected_to_2d = false,
use_odometry = false,
use_nav_sat = false,
use_landmarks = 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,
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.use_online_correlative_scan_matching = true
…………后面省略
其中:
如果published_frame和odom_frame都被设置为odom,并且provide_odom_frame=true,那么这样才会提示之前的错误:
[ERROR] [1602741280.449037435, 153.231000000]: Ignoring transform from authority "unknown_publisher" with frame_id and child_frame_id "odom" because they are the same
这个错误本质上没有什么太大的影响,我更觉得这算一个Warnning,但是终端里红红的看起来很不舒服,如果要解决,则有两种办法:
1.第一种,把published_frame设置为base_link,这样两者就不是“the same”的关系了。
2.第二种,把provide_odom_frame=true改为false,关掉之间的转换即可。
如果这项为false,则扫描匹配使用的是通过前一帧位置的先验,将当前scan与之前做对比,使用 高斯牛顿法迭代求解最小二乘问题求得当前scan的坐标变换。
如果这项为true,则使用闭环检测的方法,将当前scan在一定的搜索范围内搜索,范围为设定的平移距离及角度大小,然后在将scan插入到匹配的最优位置处。这种方式建图的效果非常好,即使建图有漂移也能够修正回去,但是这个方法的计算复杂度非常高,非常耗cpu。
当然,实际的参数并不止上述介绍的,但是大多与算法原理和调优有关,写成不同的值一般不会引起报错,因此之后将放在别的文章中进行介绍。