本人讲解关于slam一系列文章汇总链接:史上最全slam从零开始,针对于本栏目讲解(02)Cartographer源码无死角解析-接如下:
(02)Cartographer源码无死角解析- (00)目录_最新无死角讲解:https://blog.csdn.net/weixin_43013761/article/details/127350885
文末正下方中心提供了本人 联系方式, 点击本人照片即可显示 W X → 官方认证 {\color{blue}{文末正下方中心}提供了本人 \color{red} 联系方式,\color{blue}点击本人照片即可显示WX→官方认证} 文末正下方中心提供了本人联系方式,点击本人照片即可显示WX→官方认证
通过上一篇博客熟悉了bag文件,如何配置.launch与.lua文件,初步调参。该篇博客会对参数做一个详细的解析。另外,还记录了一些常见错误与解决方式。
因为为bag文件路径设置错误,如 src/cartographer_ros/cartographer_ros/launch/zwh_rs16_2d_outdoor.launch 文件中,
[ INFO] [1666593645.197645155]: I1024 14:40:45.000000 79766 configuration_file_resolver.cc:41] Found '/my_work/catkin_ws/install_isolated/share/cartogtory_builder_3d.lua' for 'trajectory_builder_3d.lua'.
[FATAL] [1666593645.227351636]: Error opening file: /root/ownloads/rslidar-outdoor-gps-notf.bag
[ INFO] [1666593645.365874613]: I1024 14:40:45.000000 79766 map_builder_bridge.cc:135] Added trajectory with ID '0'.
[playbag-5] process has died [pid 79798, exit code 1, cmd /opt/ros/melodic/lib/rosbag/play --clock /root/ownloads/rslidar-outdoor-gps-notf.bag __name:f78700-5366-11ed-863f-0242ac110002/playbag-5.log].
log file: /root/.ros/log/c8f78700-5366-11ed-863f-0242ac110002/playbag-5*.log
[ WARN] [1666593648.534747843]: W1024 14:40:48.000000 79766 node.cc:883] Expected topic "points2" (trajectory 0) (resolved topic "/rslidar_points") bue.
[ WARN] [1666593648.534860869]: W1024 14:40:48.000000 79766 node.cc:883] Expected topic "imu" (trajectory 0) (resolved topic "/imu") but no publisher
[ WARN] [1666593648.534901146]: W1024 14:40:48.000000 79766 node.cc:892] Currently available topics are: /move_base_simple/goal,/constraint_list,/subm
launch 订阅话题的名字没有设置对,如把如src/cartographer_ros/cartographer_ros/launch/zwh_rs16_2d_outdoor.launch 文件中rslidar_points参数修改成rslidar_points1,进行错误模拟会产生如下错误:
[ INFO] [1666603816.041083968]: I1024 17:30:16.000000 82604 map_builder_bridge.cc:135] Added trajectory with ID '0'.
[ WARN] [1666603817.071359674, 1606808650.139165979]: Could not compute submap fading: "map" passed to lookupTransform argument target_frame does not exist.
[ WARN] [1666603818.089436676, 1606808651.158864140]: Could not compute submap fading: "map" passed to lookupTransform argument target_frame does not exist.
[ WARN] [1666603819.093072213, 1606808652.166480699]: W1024 17:30:19.000000 82604 node.cc:883] Expected topic "points2" (trajectory 0) (resolved topic "/rslidar_points1") but no publisher is currently active.
[ WARN] [1666603819.093191561, 1606808652.166480699]: W1024 17:30:19.000000 82604 node.cc:892] Currently available topics are: /front_scan,/fix,/constraint_list,/submap_list,/scan_matched_points2,/heading,/rosout,/initialpose,/tf,/move_base_simple/goal,/tf_static,/clock,/imu,/odom_scout,/rosout_agg,/map,/clicked_point,/trajectory_node_list,/rslidar_points,/landmark_poses_list,
[ WARN] [1666603819.163932645, 1606808652.237229789]: Could not compute submap fading: "map" passed to lookupTransform argument target_frame does not exist.
[ WARN] [1666603820.223971311, 1606808653.291531796]: Could not compute submap fading: "map" passed to lookupTransform argument target_frame does not exist.
[ WARN] [1666603821.269292376, 1606808654.340306965]: Could not compute submap fading: "map" passed to lookupTransform argument target_frame does not exist.
Expected topic “points2” (trajectory 0) (resolved topic “/rslidar_points1”) but no publisher is currently active.大概的意思说,期待话题“points2”(轨迹0)(映射成“/rslidar_points1”),但当前没有活动的发布者。并且还会打印当前存在的话题:
Currently available topics are: /front_scan,/fix,/constraint_list,/submap_list,/scan_matched_points2,/heading,/rosout,/initialpose,/tf,/move_base_simple/goal,/tf_static,/clock,/imu,/odom_scout,/rosout_agg,/map,/clicked_point,/trajectory_node_list,/rslidar_points,/landmark_poses_list,
另外还可以通过前面提到的rqt指令,查看订阅关系,选择Plugins→introspection→Node Graph,如下:
可以看到 /rslidar_points1 是没有发布者的(取消 Leaf topics 的勾选)。
lua 文件中坐标系设置的不对, 导致 tf 树连不起来, 会在运行时产生 passed to lookupTransform argument source_frame dose not exit 这种问题,bag 的最上边一个坐标系是 odom, 把 src/cartographer_ros/cartographer_ros/configuration_files/lx_rs16_2d_outdoor.lua 里的 published_frame 设置成是odom2, 就会产生如下错误:
[ INFO] [1666611271.256275745, 1606808649.651826394]: I1024 19:34:31.000000 96999 local_trajectory_builder_2d.cc:124] Extrapolator not yet initialized.
[ INFO] [1666611271.273925909, 1606808649.671949345]: I1024 19:34:31.000000 96999 pose_graph_2d.cc:148] Inserted submap (0, 0).
[ WARN] [1666611271.475629726, 1606808649.874053341]: W1024 19:34:31.000000 96999 tf_bridge.cc:52] "odom2" passed to lookupTransform argument source_frame does not exist.
[ WARN] [1666611271.697864728, 1606808650.096038248]: W1024 19:34:31.000000 96999 tf_bridge.cc:52] "odom2" passed to lookupTransform argument source_frame does not exist.
[ WARN] [1666611271.908907496, 1606808650.307406313]: W1024 19:34:31.000000 96999 tf_bridge.cc:52] "odom2" passed to lookupTransform argument source_frame does not exist.
[ WARN] [1666611272.056855406, 1606808650.448873068]: Could not compute submap fading: "map" passed to lookupTransform argument target_frame does not exist.
[ WARN] [1666611272.130697937, 1606808650.529352940]: W1024 19:34:32.000000 96999 tf_bridge.cc:52] "odom2" passed to lookupTransform argument source_frame does not exist
其大概的意思是说 odom2 找不到连接关系:
持此执行rqt指令,选择 plugins→visualization→ tf tree。可以看到其上是没有 odom2 的,因为连接不起来。published_frame 表示的是 map -> footprint 的tf,但是并不会影响其建图。
当我只订阅单线点云, 同时将 min_z 设置成了 0.2, 这时启动建图就会报错,因为单线点云z必须为0,如修改 src/cartographer_ros/cartographer_ros/configuration_files/lx_rs16_2d_outdoor.lua 中的参数如下:
TRAJECTORY_BUILDER_2D.min_z = 0.8
num_laser_scans = 1, -- 是否使用单线激光数据
num_point_clouds = 0, -- 是否使用点云数据
报错如下:
[ INFO] [1666612930.509022680, 1606808649.581334449]: I1024 20:02:10.000000 111361 ordered_multi_queue.cc:172] All sensor data for trajectory 0 is available starting at '637424054495900860'.
[ WARN] [1666612930.509770022, 1606808649.591392814]: W1024 20:02:10.000000 111361 local_trajectory_builder_2d.cc:218] Dropped empty horizontal range data.
[ INFO] [1666612930.574541128, 1606808649.651753766]: I1024 20:02:10.000000 111361 pose_graph_2d.cc:148] Inserted submap (0, 0).
当 bag 或者机器人中本身存在 odom 坐标系, 而 provide_odom_frame 又设置成了 true, 就会导致 odom 坐标系重复发布,会导致机器人位姿发生来回的跳动。如当参数(合理):
published_frame = "footprint",
odom_frame = "odom",
provide_odom_frame = true,
通过 rqt→plugins→visualization→ tf tree, 可以看到如下:
当参数:
published_frame = "odom",
odom_frame = "odom",
provide_odom_frame = true,
在实际使用中这样时不合理的,类似于有了一个odom,然后又还提供一个。所以时错误的。这种时候如下所示:
broadcaster 会发生跳动,也就是 odom 来自不同的节点。
该篇博客,对 Cartographer 的一些常见错误进行了模拟,并且给出了解决方式。下面就是对一些参数的讲解了,