cartographer参数解析

trajectory_builder_2d.lua

-- Copyright 2016 The Cartographer Authors
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
--      http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

TRAJECTORY_BUILDER_2D = {
  use_imu_data = true,  --是否使用imu
  min_range = 0.,       --激光滤波时最小范围
  max_range = 30.,      --激光滤波最大范围
  min_z = -0.8,         --激光滤波高度下限
  max_z = 2.,           --激光滤波高度上限
  missing_data_ray_length = 5., --激光扫描点在设定最大范围外设置一定长度的作miss点
  num_accumulated_range_data = 1, --每次累积多少帧数据进行local map
  voxel_filter_size = 0.025,       --代码中未使用

  adaptive_voxel_filter = {
    max_length = 0.5,  --用于分辨率过滤点云点数,点数不够时以该长度一半作为分辨率细化点云
    min_num_points = 200,
    max_range = 50.,  --激光扫描最大范围
  },

  loop_closure_adaptive_voxel_filter = {  --代码中未体现
    max_length = 0.9,
    min_num_points = 100,
    max_range = 50.,
  },

  use_online_correlative_scan_matching = false,  --是否使用实时匹配策略 2d切片处理,3d暴力
  real_time_correlative_scan_matcher = {
    linear_search_window = 0.1,             --线性搜索,根据分辨率用于计算线性边界,
    angular_search_window = math.rad(20.),  --根据分辨率用于计算角度搜索个数以及扫描点数
    translation_delta_cost_weight = 1e-1, --未用
    rotation_delta_cost_weight = 1e-1,  --未用
  },

  ceres_scan_matcher = {
    occupied_space_weight = 1.,
    translation_weight = 10.,
    rotation_weight = 40.,
    ceres_solver_options = {
      use_nonmonotonic_steps = false,
      max_num_iterations = 20,
      num_threads = 1,
    },
  },
--运动滤波,通过检测2帧激光数据是否相似,可以用于判断车辆是否移动,以下条件要满足
  motion_filter = {
    max_time_seconds = 5.,          --2帧激光最小间隔
    max_distance_meters = 0.2,      --2帧激光最小距离
    max_angle_radians = math.rad(1.), --2帧激光最小角度
  }, 

  -- TODO(schwoere,wohe): Remove this constant. This is only kept for ROS.
  imu_gravity_time_constant = 10.,
  pose_extrapolator = {
    use_imu_based = false,
    constant_velocity = {
      imu_gravity_time_constant = 10.,
      pose_queue_duration = 0.001,
    },
    imu_based = {
      pose_queue_duration = 5.,
      gravity_constant = 9.806,
      pose_translation_weight = 1.,
      pose_rotation_weight = 1.,
      imu_acceleration_weight = 1.,
      imu_rotation_weight = 1.,
      odometry_translation_weight = 1.,
      odometry_rotation_weight = 1.,
      solver_options = {
        use_nonmonotonic_steps = false;
        max_num_iterations = 10;
        num_threads = 1;
      },
    },
  },

  submaps = {
    num_range_data = 90,          --子图中Node的数量
    grid_options_2d = {
      grid_type = "PROBABILITY_GRID", --概率栅格地图
      resolution = 0.05,
    },
    range_data_inserter = {
      range_data_inserter_type = "PROBABILITY_GRID_INSERTER_2D",
      probability_grid_range_data_inserter = {
        insert_free_space = true,       --是否改变改变占用网格中的概率。
        hit_probability = 0.55,          --hit(占用) 时的概率
        miss_probability = 0.49,         --miss(空闲) 时的概率
      },
      tsdf_range_data_inserter = {
        truncation_distance = 0.3,
        maximum_weight = 10.,
        update_free_space = false,
        normal_estimation_options = {
          num_normal_samples = 4,
          sample_radius = 0.5,
        },
        project_sdf_distance_to_scan_normal = true,
        update_weight_range_exponent = 0,     --与tsdf有关
        update_weight_angle_scan_normal_to_ray_kernel_bandwidth = 0.5,
        update_weight_distance_cell_to_hit_kernel_bandwidth = 0.5,
      },
    },
  },
}

pose_graph_2d.lua

-- Copyright 2016 The Cartographer Authors
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
--      http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

POSE_GRAPH = {
  optimize_every_n_nodes = 90, --处理多少个node才会进行后端优化
  constraint_builder = {
    sampling_ratio = 0.3, --全局约束采样比率(nodes),用于后端构建约束,采样率低于该值不进行约束创建。
    max_constraint_distance = 15., --全局约束最大间距(当前node与当前submap之间的距离)用于后端约束初始位置判断,初始位置大于该值不做约束
    min_score = 0.55,  --全局约束当前最小得分(当前node与当前submap的匹配得分)
    global_localization_min_score = 0.6,--全局约束全局最小得分(当前node与全局submap的匹配得分)
    loop_closure_translation_weight = 1.1e4,--闭环检测平移权重
    loop_closure_rotation_weight = 1e5,--闭环检测旋转权重
    log_matches = true,--是否打开直方图约束
    fast_correlative_scan_matcher = {
      linear_search_window = 7.,--fast_CSM匹配搜索距离
      angular_search_window = math.rad(30.),
      branch_and_bound_depth = 7,
    },
    ceres_scan_matcher = {
      occupied_space_weight = 20.,  --ceres_scan匹配占据空间权重
      translation_weight = 10.,     --ceres_scan匹配平移权重
      rotation_weight = 1.,         --ceres_scan匹配旋转权重
      ceres_solver_options = {
        use_nonmonotonic_steps = true,--是否使用梯度下降策略
        max_num_iterations = 10,
        num_threads = 1,
      },
    },
    fast_correlative_scan_matcher_3d = {
      branch_and_bound_depth = 8,
      full_resolution_depth = 3,
      min_rotational_score = 0.77,
      min_low_resolution_score = 0.55,
      linear_xy_search_window = 5.,
      linear_z_search_window = 1.,
      angular_search_window = math.rad(15.),
    },
    ceres_scan_matcher_3d = {
      occupied_space_weight_0 = 5.,
      occupied_space_weight_1 = 30.,
      translation_weight = 10.,
      rotation_weight = 1.,
      only_optimize_yaw = false,
      ceres_solver_options = {
        use_nonmonotonic_steps = false,
        max_num_iterations = 10,
        num_threads = 1,
      },
    },
  },
  matcher_translation_weight = 5e2,--匹配平移约束(当前submap与在当前submap内的某个node)
  matcher_rotation_weight = 1.6e3,--匹配旋转约束(当前submap与在当前submap内的某个node)
  --以上两个配合huber_scale使用,用于后端约束减小对异常值的影响
  optimization_problem = {
    huber_scale = 1e1,                --Huber因子(与离群值(错误的数据)对整体的影响正相关)。
    acceleration_weight = 1.1e2,      --IMU加速度的权重
    rotation_weight = 1.6e4,           --IMU旋转项的权重
    local_slam_pose_translation_weight = 1e5, --平移约束权重(前后两个node之间的局部观测与全局优化)
    local_slam_pose_rotation_weight = 1e5,   --旋转约束权重(前后两个node之间的局部观测与全局优化)
    odometry_translation_weight = 1e5,       --平移约束权重(前后两个node之间的局部观测与里程计观测)
    odometry_rotation_weight = 1e5,          --旋转约束权重(前后两个node之间的局部观测与里程计观测)
    fixed_frame_pose_translation_weight = 1e1,
    fixed_frame_pose_rotation_weight = 1e2,
    fixed_frame_pose_use_tolerant_loss = false,
    fixed_frame_pose_tolerant_loss_param_a = 1,
    fixed_frame_pose_tolerant_loss_param_b = 1,
    log_solver_summary = false,
    use_online_imu_extrinsics_in_3d = true,
    fix_z_in_3d = false,
    ceres_solver_options = {
      use_nonmonotonic_steps = false,            --是否记录Ceres全局优化的结果
      max_num_iterations = 50,
      num_threads = 7,
    },
  },
  max_num_final_iterations = 200,                --建图结束后最终优化迭代次数 实际没用到
  global_sampling_ratio = 0.003,                 --全局地图匹配约束采样比率(nodes)
  log_residual_histograms = true,                 --是否输出残差直方图
  global_constraint_search_after_n_seconds = 10.,  --多长时间进行一次全局后端约束,与global_sampling_ratio配合使用达成目标
  --  overlapping_submaps_trimmer_2d = {
  --    fresh_submaps_count = 1,
  --    min_covered_area = 2,
  --    min_added_submaps_count = 5,
  --  },
}

  • 8
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Cartographer 是一款 Google 开源的用于实时构建 2D 和 3D 室内地图的工具,主要用于在机器人等移动设备上进行定位和建图任务。本文将对 Cartographer 的源代码进行分析解读,以帮助读者更好地理解该工具的实现原理。 1. 源码结构 Cartographer 的源码分为多个部分,包括: - cartographer:主要代码库,包含地图构建、局部地图匹配、位姿估计等核心功能。 - cartographer_ros:ROS wrapper,将 cartographer 代码库与 ROS 框架进行了整合,提供了 ROS 接口。 - cartographer_rviz:RViz 插件,用于可视化展示地图、轨迹等信息。 - cartographer_android:Android 版本,用于在 Android 系统上运行 Cartographer。 2. 核心算法 Cartographer 采用了多种算法来实现室内地图的构建和定位,其中比较重要的算法包括: - 位姿图优化(Pose Graph Optimization):通过对传感器数据进行多次优化,得到机器人在运动过程中的位置和方向信息。 - 实时建图(Real-Time Mapping):使用激光雷达等传感器,实时获取机器人周围环境的信息,构建室内地图。 - 局部地图匹配(Local Submap Matching):将当前传感器数据与已构建的局部地图进行匹配,从而得到更准确的位置信息。 - 点云滤波(Point Cloud Filtering):将激光雷达获取的点云数据进行滤波处理,去除噪声和无效数据。 3. 关键函数解析 以下是 Cartographer 中比较重要的几个函数的解析: - cartographer/mapping/internal/pose_graph_2d.cc: PoseGraph2D::AddNode():向位姿图中添加新的节点,包括节点 ID、位姿信息等。 - cartographer/mapping/internal/pose_graph_2d.cc: PoseGraph2D::AddConstraint():向位姿图中添加新的约束,包括约束类型、起始和终止节点 ID、约束值等。 - cartographer/mapping/internal/scan_matching/ceres_scan_matcher.cc: CeresScanMatcher::Match():使用 Ceres 库实现激光雷达数据与局部地图的匹配过程。 - cartographer/mapping/internal/3d/optimization/optimization_problem_3d.cc: OptimizationProblem3D::Solve():使用 Ceres 库实现位姿图优化过程,得到机器人在运动过程中的位置和方向信息。 - cartographer/mapping/internal/3d/scan_matching/real_time_correlative_scan_matcher_3d.cc: RealTimeCorrelativeScanMatcher3D::Match():实时建图过程中使用的一种激光雷达数据与局部地图的匹配算法。 4. 开发环境 Cartographer 的开发环境需要使用 Google 推荐的 Bazel 构建系统,以及 C++11 编译器和 ROS 框架。具体的开发环境搭建和编译过程可以参考 Cartographer 的官方文档。 5. 总结 Cartographer 是一款非常优秀的室内地图构建和定位工具,在机器人、自动驾驶等领域有着广泛的应用。本文对 Cartographer 的源代码进行了分析解读,希望能够帮助读者更好地理解该工具的实现原理。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值