小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
cartographer进行大范围建图出现卡顿
-
标题:使用cartographer在仿真环境中进行大范围建图出现卡顿
背景:
需要实现大范围建图,实现扫描整个校园,之后进行导航。暂时使用仿真模拟大范围建图,但仿真范围相对于校园是比较小的。
问题描述:
硬件平台 nuc x86平台
系统版本 ubuntu20.04
ros版本 foxy使用cartographer在仿真环境中模拟大范围建图一段时间后,rviz显示走过的路与map更新不统一,map更新较为迟缓甚至出现卡顿,需要等一段时间(可能10分钟,或者半小时,甚至更长)后rviz的map才会更新到最新的点。曾经尝试过等待,卡顿的时间并不是线性的,感觉是指数级增长,且内存占用也比较高,建图一段时间后,内存使用量从原来的2gb左右(正常使用情况,刚运行的时候)上升到7gb左右 如下图所示:
如下图所示,是卡顿的情况:
仿真模型如下图所示:
刚出现卡顿时一部分rviz 日志:
[cartographer_node-1] [INFO] [1712731552.511735516] [cartographer_ros]: I0410 14:45:52.000000 24051 collated_trajectory_builder.cc:72] odom rate: 17.61 Hz 5.68e-02 s +/- 1.73e-02 s (pulsed at 99.71% real time) [cartographer_node-1] [INFO] [1712731552.511765476] [cartographer_ros]: I0410 14:45:52.000000 24051 collated_trajectory_builder.cc:72] scan rate: 5.00 Hz 2.00e-01 s +/- 6.62e-04 s (pulsed at 99.44% real time) [cartographer_node-1] [INFO] [1712731567.527431246] [cartographer_ros]: I0410 14:46:07.000000 24051 collated_trajectory_builder.cc:72] odom rate: 17.36 Hz 5.76e-02 s +/- 1.88e-02 s (pulsed at 99.32% real time) [cartographer_node-1] [INFO] [1712731567.527496576] [cartographer_ros]: I0410 14:46:07.000000 24051 collated_trajectory_builder.cc:72] scan rate: 5.00 Hz 2.00e-01 s +/- 6.08e-04 s (pulsed at 99.69% real time) [cartographer_node-1] [INFO] [1712731582.551846932] [cartographer_ros]: I0410 14:46:22.000000 24051 collated_trajectory_builder.cc:72] odom rate: 17.84 Hz 5.61e-02 s +/- 1.73e-02 s (pulsed at 99.15% real time) [cartographer_node-1] [INFO] [1712731582.551876766] [cartographer_ros]: I0410 14:46:22.000000 24051 collated_trajectory_builder.cc:72] scan rate: 5.00 Hz 2.00e-01 s +/- 4.38e-04 s (pulsed at 99.82% real time) [cartographer_node-1] [INFO] [1712731597.566277359] [cartographer_ros]: I0410 14:46:37.000000 24051 collated_trajectory_builder.cc:72] odom rate: 17.79 Hz 5.62e-02 s +/- 1.78e-02 s (pulsed at 99.54% real time) [cartographer_node-1] [INFO] [1712731597.566311384] [cartographer_ros]: I0410 14:46:37.000000 24051 collated_trajectory_builder.cc:72] scan rate: 5.00 Hz 2.00e-01 s +/- 5.10e-04 s (pulsed at 99.64% real time) [cartographer_node-1] [INFO] [1712731612.617004872] [cartographer_ros]: I0410 14:46:52.000000 24051 collated_trajectory_builder.cc:72] odom rate: 17.62 Hz 5.68e-02 s +/- 1.68e-02 s (pulsed at 99.52% real time) [cartographer_node-1] [INFO] [1712731612.617035914] [cartographer_ros]: I0410 14:46:52.000000 24051 collated_trajectory_builder.cc:72] scan rate: 5.00 Hz 2.00e-01 s +/- 6.82e-04 s (pulsed at 99.43% real time) [cartographer_node-1] [INFO] [1712731627.630846753] [cartographer_ros]: I0410 14:47:07.000000 24051 collated_trajectory_builder.cc:72] odom rate: 17.59 Hz 5.68e-02 s +/- 1.65e-02 s (pulsed at 99.46% real time) [cartographer_node-1] [INFO] [1712731627.630900505] [cartographer_ros]: I0410 14:47:07.000000 24051 collated_trajectory_builder.cc:72] scan rate: 5.00 Hz 2.00e-01 s +/- 6.30e-04 s (pulsed at 99.96% real time) [cartographer_node-1] [INFO] [1712731628.793949106] [cartographer_ros]: I0410 14:47:08.000000 24051 motion_filter.cc:42] Motion filter reduced the number of nodes to 47.9781%. [cartographer_node-1] [INFO] [1712731642.663164354] [cartographer_ros]: I0410 14:47:22.000000 24051 collated_trajectory_builder.cc:72] odom rate: 17.73 Hz 5.64e-02 s +/- 1.61e-02 s (pulsed at 99.38% real time) [cartographer_node-1] [INFO] [1712731642.663195643] [cartographer_ros]: I0410 14:47:22.000000 24051 collated_trajectory_builder.cc:72] scan rate: 5.00 Hz 2.00e-01 s +/- 4.97e-04 s (pulsed at 100.04% real time) [cartographer_node-1] [INFO] [1712731657.712615266] [cartographer_ros]: I0410 14:47:37.000000 24051 collated_trajectory_builder.cc:72] odom rate: 17.75 Hz 5.63e-02 s +/- 1.67e-02 s (pulsed at 99.52% real time) [cartographer_node-1] [INFO] [1712731657.712651190] [cartographer_ros]: I0410 14:47:37.000000 24051 collated_trajectory_builder.cc:72] scan rate: 5.00 Hz 2.00e-01 s +/- 5.49e-04 s (pulsed at 99.73% real time) [cartographer_node-1] [INFO] [1712731672.750544375] [cartographer_ros]: I0410 14:47:52.000000 24051 collated_trajectory_builder.cc:72] odom rate: 17.59 Hz 5.68e-02 s +/- 1.68e-02 s (pulsed at 99.40% real time) [cartographer_node-1] [INFO] [1712731672.750597528] [cartographer_ros]: I0410 14:47:52.000000 24051 collated_trajectory_builder.cc:72] scan rate: 5.00 Hz 2.00e-01 s +/- 7.02e-04 s (pulsed at 99.91% real time) [cartographer_node-1] [INFO] [1712731687.823128666] [cartographer_ros]: I0410 14:48:07.000000 24051 collated_trajectory_builder.cc:72] odom rate: 17.65 Hz 5.67e-02 s +/- 1.63e-02 s (pulsed at 99.28% real time) [cartographer_node-1] [INFO] [1712731687.823228259] [cartographer_ros]: I0410 14:48:07.000000 24051 collated_trajectory_builder.cc:72] scan rate: 5.00 Hz 2.00e-01 s +/- 4.68e-04 s (pulsed at 99.89% real time) [cartographer_node-1] [INFO] [1712731702.862857259] [cartographer_ros]: I0410 14:48:22.000000 24051 collated_trajectory_builder.cc:72] odom rate: 20.99 Hz 4.76e-02 s +/- 1.69e-02 s (pulsed at 100.36% real time) [cartographer_node-1] [INFO] [1712731702.864018212] [cartographer_ros]: I0410 14:48:22.000000 24051 collated_trajectory_builder.cc:72] scan rate: 5.00 Hz 2.00e-01 s +/- 2.87e-04 s (pulsed at 99.80% real time)
等待30分钟后一部分rviz日志:
[cartographer_node-1] [INFO] [1712733927.665480146] [cartographer_ros]: I0410 15:25:27.000000 24051 collated_trajectory_builder.cc:72] odom rate: 15.85 Hz 6.31e-02 s +/- 2.21e-02 s (pulsed at 99.96% real time) [cartographer_node-1] [INFO] [1712733927.668576325] [cartographer_ros]: I0410 15:25:27.000000 24051 collated_trajectory_builder.cc:72] scan rate: 5.00 Hz 2.00e-01 s +/- 8.68e-04 s (pulsed at 99.75% real time) [cartographer_node-1] [INFO] [1712733934.773953652] [cartographer_ros]: I0410 15:25:34.000000 24051 motion_filter.cc:42] Motion filter reduced the number of nodes to 36.3149%. [cartographer_node-1] [INFO] [1712733942.694428955] [cartographer_ros]: I0410 15:25:42.000000 24051 collated_trajectory_builder.cc:72] odom rate: 16.19 Hz 6.18e-02 s +/- 2.04e-02 s (pulsed at 99.84% real time) [cartographer_node-1] [INFO] [1712733942.694463213] [cartographer_ros]: I0410 15:25:42.000000 24051 collated_trajectory_builder.cc:72] scan rate: 5.00 Hz 2.00e-01 s +/- 7.31e-04 s (pulsed at 99.54% real time) [cartographer_node-1] [INFO] [1712733957.738089993] [cartographer_ros]: I0410 15:25:57.000000 24051 collated_trajectory_builder.cc:72] odom rate: 15.58 Hz 6.42e-02 s +/- 2.16e-02 s (pulsed at 99.92% real time) [cartographer_node-1] [INFO] [1712733957.738118990] [cartographer_ros]: I0410 15:25:57.000000 24051 collated_trajectory_builder.cc:72] scan rate: 5.00 Hz 2.00e-01 s +/- 8.99e-04 s (pulsed at 99.31% real time) [cartographer_node-1] [INFO] [1712733972.801014655] [cartographer_ros]: I0410 15:26:12.000000 24051 collated_trajectory_builder.cc:72] odom rate: 17.79 Hz 5.62e-02 s +/- 1.92e-02 s (pulsed at 99.33% real time) [cartographer_node-1] [INFO] [1712733972.809865571] [cartographer_ros]: I0410 15:26:12.000000 24051 collated_trajectory_builder.cc:72] scan rate: 5.00 Hz 2.00e-01 s +/- 7.49e-04 s (pulsed at 99.81% real time) [cartographer_node-1] [INFO] [1712733987.852491175] [cartographer_ros]: I0410 15:26:27.000000 24051 collated_trajectory_builder.cc:72] odom rate: 17.27 Hz 5.79e-02 s +/- 2.08e-02 s (pulsed at 99.08% real time) [cartographer_node-1] [INFO] [1712733987.852517236] [cartographer_ros]: I0410 15:26:27.000000 24051 collated_trajectory_builder.cc:72] scan rate: 5.00 Hz 2.00e-01 s +/- 7.49e-04 s (pulsed at 99.87% real time) [cartographer_node-1] [INFO] [1712734002.953640554] [cartographer_ros]: I0410 15:26:42.000000 24051 collated_trajectory_builder.cc:72] odom rate: 17.38 Hz 5.75e-02 s +/- 1.89e-02 s (pulsed at 99.21% real time) [cartographer_node-1] [INFO] [1712734002.954095649] [cartographer_ros]: I0410 15:26:42.000000 24051 collated_trajectory_builder.cc:72] scan rate: 5.00 Hz 2.00e-01 s +/- 8.36e-04 s (pulsed at 99.94% real time) [cartographer_node-1] [INFO] [1712734018.003455380] [cartographer_ros]: I0410 15:26:58.000000 24051 collated_trajectory_builder.cc:72] odom rate: 17.05 Hz 5.87e-02 s +/- 2.23e-02 s (pulsed at 100.39% real time) [cartographer_node-1] [INFO] [1712734018.005777640] [cartographer_ros]: I0410 15:26:58.000000 24051 collated_trajectory_builder.cc:72] scan rate: 5.00 Hz 2.00e-01 s +/- 7.85e-04 s (pulsed at 99.80% real time) [cartographer_node-1] [INFO] [1712734033.051672753] [cartographer_ros]: I0410 15:27:13.000000 24051 collated_trajectory_builder.cc:72] odom rate: 17.08 Hz 5.85e-02 s +/- 2.19e-02 s (pulsed at 100.08% real time) [cartographer_node-1] [INFO] [1712734033.052880943] [cartographer_ros]: I0410 15:27:13.000000 24051 collated_trajectory_builder.cc:72] scan rate: 5.00 Hz 2.00e-01 s +/- 7.76e-04 s (pulsed at 99.45% real time) [cartographer_node-1] [INFO] [1712734035.161934350] [cartographer_ros]: I0410 15:27:15.000000 24051 motion_filter.cc:42] Motion filter reduced the number of nodes to 35.9477%. [cartographer_node-1] [INFO] [1712734048.053592713] [cartographer_ros]: I0410 15:27:28.000000 24051 collated_trajectory_builder.cc:72] odom rate: 17.54 Hz 5.70e-02 s +/- 1.95e-02 s (pulsed at 99.14% real time) [cartographer_node-1] [INFO] [1712734048.053625189] [cartographer_ros]: I0410 15:27:28.000000 24051 collated_trajectory_builder.cc:72] scan rate: 5.00 Hz 2.00e-01 s +/- 8.84e-04 s (pulsed at 99.90% real time) [cartographer_node-1] [INFO] [1712734063.086749043] [cartographer_ros]: I0410 15:27:43.000000 24051 collated_trajectory_builder.cc:72] odom rate: 16.69 Hz 5.99e-02 s +/- 2.02e-02 s (pulsed at 99.19% real time) [cartographer_node-1] [INFO] [1712734063.086786005] [cartographer_ros]: I0410 15:27:43.000000 24051 collated_trajectory_builder.cc:72] scan rate: 5.00 Hz 2.00e-01 s +/- 7.94e-04 s (pulsed at 99.68% real time) [cartographer_node-1] [INFO] [1712734078.141211460] [cartographer_ros]: I0410 15:27:58.000000 24051 collated_trajectory_builder.cc:72] odom rate: 16.83 Hz 5.94e-02 s +/- 1.99e-02 s (pulsed at 99.08% real time) [cartographer_node-1] [INFO] [1712734078.141237015] [cartographer_ros]: I0410 15:27:58.000000 24051 collated_trajectory_builder.cc:72] scan rate: 5.00 Hz 2.00e-01 s +/- 7.76e-04 s (pulsed at 99.87% real time)
尝试过的解决方法:
一开始修改过lua文件,根据cartographer官方提供的调优文档修改过,但效果并不明显。
后又修改过launch文件中地图分辨率从原来的0.05修改为0.4,以及修改map更新频率从原来的0.5修改为1,建图范围增大的较为明显。但还是会出现卡顿的情况。 -
-
@2475887309 大场景确实会消耗更多的内存,而且还是在仿真情况下,需要对参数进一步的调整,不止是更新频率和分辨率,还要调整子图数量之类的参数,建议附上完整的参数配置,并详细尝试调整其他参数进行测试。
-
@小鱼 大佬您好,参数配置是根据您的教程来的,就launch文件修改了一下分辨率以及更新地图,其他的例如lua文件没有修改。现在需要修改的是哪部分参数啊
-
@2475887309 你倒是把你现在的参数贴出来呀,大兄弟
-
@小鱼 不好意思,昨天忙着做其他事情去了,就没看论坛
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", --base_link
-- base_link改为odom,发布map到odom之间的位姿态
published_frame = "odom", --odom
odom_frame = "odom", --odom
-- true改为false,不用提供里程计数据
provide_odom_frame = false,
-- false改为true,仅发布2D位资
publish_frame_projected_to_2d = true,
-- false改为true,使用里程计数据
use_odometry = true,
use_nav_sat = false,
use_landmarks = false,
-- 0改为1,使用一个雷达
num_laser_scans = 1,
-- 1改为0,不使用多波雷达
num_multi_echo_laser_scans = 0,
-- 10改为1,1/1=1等于不分割
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.,
}-- false改为true,启动2D SLAM
MAP_BUILDER.use_trajectory_builder_2d = true
-- 0改成0.10,比机器人半径小的都忽略
TRAJECTORY_BUILDER_2D.min_range = 0.10 --0.10
-- 30改成3.5,限制在雷达最大扫描范围内,越小一般越精确些
TRAJECTORY_BUILDER_2D.max_range = 30 --5
-- 5改成3,传感器数据超出有效范围最大值
TRAJECTORY_BUILDER_2D.missing_data_ray_length = 30. --3.0
-- true改成false,不使用IMU数据,大家可以开启,然后对比下效果
TRAJECTORY_BUILDER_2D.use_imu_data = false
-- false改成true,使用实时回环检测来进行前端的扫描匹配
TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching = true
-- 1.0改成0.1,提高对运动的敏感度
TRAJECTORY_BUILDER_2D.motion_filter.max_angle_radians = math.rad(0.1) --0.1-- 0.55改成0.65,Fast csm的最低分数,高于此分数才进行优化。
POSE_GRAPH.constraint_builder.min_score = 0.65 --0.65
--0.6改成0.7,全局定位最小分数,低于此分数则认为目前全局定位不准确
POSE_GRAPH.constraint_builder.global_localization_min_score = 0.7 --0.7-- 设置0可关闭全局SLAM
POSE_GRAPH.optimize_every_n_nodes = 0return options
launch文件如下
import os
from launch import LaunchDescription
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageSharedef generate_launch_description():
# 定位到功能包的地址
pkg_share = FindPackageShare(package='fishbot_cartographer').find('fishbot_cartographer')#=====================运行节点需要的配置======================================================================= # 是否使用仿真时间,我们用gazebo,这里设置成true use_sim_time = LaunchConfiguration('use_sim_time', default='true') # 地图的分辨率--0.05 resolution = LaunchConfiguration('resolution', default='0.4') # 地图的发布周期--0.5 publish_period_sec = LaunchConfiguration('publish_period_sec', default='1') # 配置文件夹路径 configuration_directory = LaunchConfiguration('configuration_directory',default= os.path.join(pkg_share, 'config') ) # 配置文件 configuration_basename = LaunchConfiguration('configuration_basename', default='fishbot_2d.lua') #=====================声明三个节点,cartographer/occupancy_grid_node/rviz_node================================= cartographer_node = Node( package='cartographer_ros', executable='cartographer_node', name='cartographer_node', output='screen', parameters=[{'use_sim_time': use_sim_time}], arguments=['-configuration_directory', configuration_directory, '-configuration_basename', configuration_basename]) occupancy_grid_node = Node( package='cartographer_ros', executable='occupancy_grid_node', name='occupancy_grid_node', output='screen', parameters=[{'use_sim_time': use_sim_time}], arguments=['-resolution', resolution, '-publish_period_sec', publish_period_sec]) rviz_node = Node( package='rviz2', executable='rviz2', name='rviz2', # arguments=['-d', rviz_config_dir], parameters=[{'use_sim_time': use_sim_time}], output='screen') #===============================================定义启动文件======================================================== ld = LaunchDescription() ld.add_action(cartographer_node) ld.add_action(occupancy_grid_node) ld.add_action(rviz_node) return ld
-
格式有点不对,我重新发以下配置
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", --base_link -- base_link改为odom,发布map到odom之间的位姿态 published_frame = "odom", --odom odom_frame = "odom", --odom -- true改为false,不用提供里程计数据 provide_odom_frame = false, -- false改为true,仅发布2D位资 publish_frame_projected_to_2d = true, -- false改为true,使用里程计数据 use_odometry = true, use_nav_sat = false, use_landmarks = false, -- 0改为1,使用一个雷达 num_laser_scans = 1, -- 1改为0,不使用多波雷达 num_multi_echo_laser_scans = 0, -- 10改为1,1/1=1等于不分割 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., } -- false改为true,启动2D SLAM MAP_BUILDER.use_trajectory_builder_2d = true -- 0改成0.10,比机器人半径小的都忽略 TRAJECTORY_BUILDER_2D.min_range = 0.10 --0.10 -- 30改成3.5,限制在雷达最大扫描范围内,越小一般越精确些 TRAJECTORY_BUILDER_2D.max_range = 30 --5 -- 5改成3,传感器数据超出有效范围最大值 TRAJECTORY_BUILDER_2D.missing_data_ray_length = 30. --3.0 -- true改成false,不使用IMU数据,大家可以开启,然后对比下效果 TRAJECTORY_BUILDER_2D.use_imu_data = false -- false改成true,使用实时回环检测来进行前端的扫描匹配 TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching = true -- 1.0改成0.1,提高对运动的敏感度 TRAJECTORY_BUILDER_2D.motion_filter.max_angle_radians = math.rad(0.1) --0.1 -- 0.55改成0.65,Fast csm的最低分数,高于此分数才进行优化。 POSE_GRAPH.constraint_builder.min_score = 0.65 --0.65 --0.6改成0.7,全局定位最小分数,低于此分数则认为目前全局定位不准确 POSE_GRAPH.constraint_builder.global_localization_min_score = 0.7 --0.7 -- 设置0可关闭全局SLAM POSE_GRAPH.optimize_every_n_nodes = 0 return options
launch文件配置
import os from launch import LaunchDescription from launch.substitutions import LaunchConfiguration from launch_ros.actions import Node from launch_ros.substitutions import FindPackageShare def generate_launch_description(): # 定位到功能包的地址 pkg_share = FindPackageShare(package='fishbot_cartographer').find('fishbot_cartographer') #=====================运行节点需要的配置======================================================================= # 是否使用仿真时间,我们用gazebo,这里设置成true use_sim_time = LaunchConfiguration('use_sim_time', default='true') # 地图的分辨率--0.05 resolution = LaunchConfiguration('resolution', default='0.4') # 地图的发布周期--0.5 publish_period_sec = LaunchConfiguration('publish_period_sec', default='1') # 配置文件夹路径 configuration_directory = LaunchConfiguration('configuration_directory',default= os.path.join(pkg_share, 'config') ) # 配置文件 configuration_basename = LaunchConfiguration('configuration_basename', default='fishbot_2d.lua') #=====================声明三个节点,cartographer/occupancy_grid_node/rviz_node================================= cartographer_node = Node( package='cartographer_ros', executable='cartographer_node', name='cartographer_node', output='screen', parameters=[{'use_sim_time': use_sim_time}], arguments=['-configuration_directory', configuration_directory, '-configuration_basename', configuration_basename]) occupancy_grid_node = Node( package='cartographer_ros', executable='occupancy_grid_node', name='occupancy_grid_node', output='screen', parameters=[{'use_sim_time': use_sim_time}], arguments=['-resolution', resolution, '-publish_period_sec', publish_period_sec]) rviz_node = Node( package='rviz2', executable='rviz2', name='rviz2', # arguments=['-d', rviz_config_dir], parameters=[{'use_sim_time': use_sim_time}], output='screen') #===============================================定义启动文件======================================================== ld = LaunchDescription() ld.add_action(cartographer_node) ld.add_action(occupancy_grid_node) ld.add_action(rviz_node) return ld
-
@2475887309 在 cartographer进行大范围建图出现卡顿 中说:
TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching = true
比如这个参数就可以关掉,应该能剩不少算力
以下内容由GPT给出:
减小扫描匹配参数:
TRAJECTORY_BUILDER_2D.min_range: 减小此参数可以忽略机器人附近太近的数据,减少计算量。
TRAJECTORY_BUILDER_2D.max_range: 限制传感器数据的最大范围可以减少计算负载,避免处理超出此范围的数据。
TRAJECTORY_BUILDER_2D.missing_data_ray_length: 调整此参数可以有效处理缺失或无效的传感器数据,从而减少不必要的计算。
禁用未使用的功能:TRAJECTORY_BUILDER_2D.use_imu_data: 如果不使用IMU数据,将此设置为false可以防止与IMU数据相关的不必要处理。
use_nav_sat、use_landmarks: 如果不使用卫星导航或地标,则确保这些参数为false。
优化扫描匹配参数:TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching: 如果系统允许,您可以禁用在线扫描匹配以减少实时计算。但是,这可能会影响SLAM的质量。
调整运动滤波器灵敏度:TRAJECTORY_BUILDER_2D.motion_filter.max_angle_radians: 减小此参数会增加对运动的敏感性,这可能会改善对运动的响应,但也可能略微增加计算量。您可以根据机器人的动态特性进行微调。
约束构建参数:POSE_GRAPH.constraint_builder.min_score: 降低此值可能会减少在优化过程中考虑的约束数量,从而减少计算负载。但这可能会影响生成地图的准确性。
POSE_GRAPH.constraint_builder.global_localization_min_score: 同样,降低此值可能会减少全局定位尝试的次数,节省计算资源。
全局SLAM优化:POSE_GRAPH.optimize_every_n_nodes: 将此设置为0可以有效地禁用全局SLAM优化,这可以节省大量计算资源。但是,这会以随时间降低地图质量为代价。
-
@小鱼 好的大佬,我尝试一下
-
@小鱼 大佬,我又回来了,在修改以上提到的参数过后,确实有所改善,但是建图效果并没有之前的好了,而且还是会出现卡顿的情况,只不过就是比调整之前的建图范围大了一些。
然后我去cartographer的github上面寻找到一个issue,问题与我类似,但似乎并没有解决,这个问题似乎是因为迁移到ros2中形成的一个bug,我把链接放下面,如果大佬有时间的话,可否看一下,如果是因为这个原因,我是否可以更换算法,比如您发的Lego-LOAM这个算法https://github.com/ros2/cartographer_ros/issues/36
-
@2475887309 可以试试一些其他版本的建图方法,比如slam_toolbox 或者 gmapping等