cartographer--2d(速腾16线)融合 imu 建图

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 = "base_link",
  odom_frame = "odom",
  provide_odom_frame = true,
  publish_frame_projected_to_2d = true,
  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.1,
  submap_publish_period_sec = 0.05,
  pose_publish_period_sec = 0.002,
  trajectory_publish_period_sec = 0.005,
  rangefinder_sampling_ratio = 1.,
  odometry_sampling_ratio = 1.,
  fixed_frame_pose_sampling_ratio = 1.,
  imu_sampling_ratio = 1.,
  landmarks_sampling_ratio = 1.,
}

-- 使用2D轨迹构建器
MAP_BUILDER.use_trajectory_builder_2d = true

-- 2D轨迹构建器的具体配置
TRAJECTORY_BUILDER_2D = {
  num_accumulated_range_data = 1,  -- 只设置一次
  use_imu_data = true,
  min_range = 0.2,
  max_range = 30.,
  missing_data_ray_length = 5.,
  use_online_correlative_scan_matching = true,
  motion_filter = {  -- 确保motion_filter是一个表
    max_angle_radians = math.rad(0.1)
  }
}

-- 姿态图配置
POSE_GRAPH = {
  optimize_every_n_nodes = 5,
  optimization_problem = {
    huber_scale = 5e2,
    ceres_solver_options = {
      max_num_iterations = 20
    },
    odometry_translation_weight = 1e3,
    odometry_rotation_weight = 1e3
  },
  constraint_builder = {
    sampling_ratio = 0.03,
    min_score = 0.5,
    global_localization_min_score = 0.55
  }
}

return options

 launch文件 这里我是通过静态坐标变换替代雷达和imud的URDF文件。静态坐标变换节点可以发布固定的TF变换

<launch>

 <!-- 启动Cartographer节点 -->
    <node name="cartographer_node" pkg="cartographer_ros"
      type="cartographer_node" args="
          -configuration_directory $(find cartographer_ros)/configuration_files
          -configuration_basename test.lua"
      output="screen">
      <remap from="imu" to="/CartImu"/>
      <remap from="odom" to="/odom"/>
    </node>
  <!-- 启动Cartographer的占用栅格地图节点 -->
    <node name="cartographer_occupancy_grid_node" pkg="cartographer_ros"
        type="cartographer_occupancy_grid_node" args="-resolution 0.05" />
  <!-- 静态坐标变换 -->
  
 <node pkg="tf" type="static_transform_publisher" name="base_link_to_rslidar" args="1 0 0.5 0 0 0 base_link rslidar 100" />
 <node pkg="tf" type="static_transform_publisher" name="base_link_to_CartImu" args="0 0 0.1 0 0 0 base_link /CartImu 100" />
</launch>

运行后:

不理解我在launch文件里面做了CartImu的静态变换为什么还说我坐标系不存在---------检查了一下发现imu的坐标系整错了

重新修改launch文件后

<launch>

 <!-- 启动Cartographer节点 -->
    <node name="cartographer_node" pkg="cartographer_ros"
      type="cartographer_node" args="
          -configuration_directory $(find cartographer_ros)/configuration_files
          -configuration_basename test.lua"
      output="screen">
      <remap from="imu" to="/CartImu"/>
      <remap from="odom" to="/odom"/>
    </node>
  <!-- 启动Cartographer的占用栅格地图节点 -->
    <node name="cartographer_occupancy_grid_node" pkg="cartographer_ros"
        type="cartographer_occupancy_grid_node" args="-resolution 0.05" />
  <!-- 静态坐标变换 -->
  
 <node pkg="tf" type="static_transform_publisher" name="base_link_to_rslidar" args="1 0 0.5 0 0 0 base_link rslidar 100" />
 <node pkg="tf" type="static_transform_publisher" name="base_link_to_cart_imu" args="0 0 0.1 0 0 0 base_link cart_imu 100" />
</launch>

 启动新的launch文件后又出现新问题

 这个问题翻译过来说是-----Cartographer在处理IMU数据时遇到了问题。具体来说,它期望IMU帧(cart_imu)和跟踪帧(base_link)是共定位的(即它们应该具有相同的原点)。但是,根据日志中的警告信息,这两个帧之间存在一个非零的平移变换,这导致了程序崩溃。

我发现我的

跟踪坐标系是base_link,这里改成 cart_imu 设置为imu的坐标系后就解决了这个问题

最终载入小车底盘的模型文件

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值