速腾聚创robosense16线在cartographer下进行2D建图

  • Post author:
  • Post category:其他


1.前提:安装好rslidar相关驱动,安装好point_to_laseerscan将点云数据转换成单线激光。

2.修改cartographer下的文件,

2.1 修改catkin_w/src/cartographer_ros/cartographer_ros/configuration_files/revo_lds.lua,

主要修改以下两行:

tracking_frame = "rslidar",
published_frame = "rslidar",

里面的”horizontal_laser_link”,改成你自己激光雷达的frame_id,,网上一般修改的是laser,但是我运行不了,rviz中显示不了地图。这样设置的原因应该是只用了一个激光器,而不是机器人,所以用“laser”,这个“laser”也需要查看激光器在tf_tree中的名称,用实际的名称替换,否则rviz中看不到地图,因为tf有问题。通过rosrun rqt_tf_tree rqt_tf_tree 查看机器人发布的tf_tree。由于激光雷达发布的frame_id为rslidar,因此需要进行修改,并重新编译。

通常情况下,按照下面规则:

a) 在只使用激光雷达的时候(tracking_frame=”laser”, publish_frame=”laser”)
b) 使用里程计+激光雷达时(tracking_frame=”base_link”, publish_frame=”odom”)
c) 使用IMU+激光+里程计时(tracking_frame=”imu_link”, publish_frame=”odom”)

修改后代码如下:

include "map_builder.lua"
include "trajectory_builder.lua"

options = {
  map_builder = MAP_BUILDER,
  trajectory_builder = TRAJECTORY_BUILDER,
  map_frame = "map",
  tracking_frame = "rslidar",
  published_frame = "rslidar",
  odom_frame = "odom",
  provide_odom_frame = false,
  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
--MAP_BUILDER.num_background_threads = 7

TRAJECTORY_BUILDER_2D.ceres_scan_matcher.translation_weight = 2
TRAJECTORY_BUILDER_2D.ceres_scan_matcher.rotation_weight = 10
TRAJECTORY_BUILDER_2D.submaps.num_range_data = 90
TRAJECTORY_BUILDER_2D.min_range = 0.3
TRAJECTORY_BUILDER_2D.max_range = 8.
TRAJECTORY_BUILDER_2D.missing_data_ray_length = 1.
TRAJECTORY_BUILDER_2D.use_imu_data = false
TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching = true
TRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.linear_search_window = 0.1
TRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.translation_delta_cost_weight = 10.
TRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.rotation_delta_cost_weight = 1e-1

POSE_GRAPH.optimization_problem.huber_scale = 5e2
POSE_GRAPH.optimize_every_n_nodes = 320
POSE_GRAPH.constraint_builder.sampling_ratio = 0.03
POSE_GRAPH.optimization_problem.ceres_solver_options.max_num_iterations = 10
POSE_GRAPH.constraint_builder.min_score = 0.62
POSE_GRAPH.constraint_builder.global_localization_min_score = 0.66

return options

2.2修改catkin_w/src/cartographer_ros/cartographer_ros/launch/demo_revo_lds.launch文件。

修改代码如下:

<launch>  
      
<param name="/use_sim_time" value="false" />  
<!--启动建图节点-->
<node name="cartographer_node" pkg="cartographer_ros"  
    type="cartographer_node" args="  
    -configuration_directory $(find cartographer_ros)/configuration_files  
    -configuration_basename revo_lds.lua"  
    output="screen">  
    <remap from="scan" to="/rslidar/scan" />  
</node>  

<node name="cartographer_occupancy_grid_node" pkg="cartographer_ros"
      type="cartographer_occupancy_grid_node" args="-resolution 0.05" />

<node name="rviz" pkg="rviz" type="rviz" required="true"  
          args="-d $(find cartographer_ros)/configuration_files/demo_2d.rviz" />  
</launch>

主要修改

 <remap from="scan" to="/rslidar/scan" />  

网上一般修改成 <remap from=”scan” to=”scan” /> ,要按照实际雷达发布节点进行,否则会报错。

3.

修改完之后,回到catkin_w目录下面编译

catkin_make_isolated --install --use-ninja

4.新开终端:分别运行

roslaunch rslidar_pointcloud rs_lidar_16.launch

roslaunch pointcloud_to_laserscan rslidar.launch

roslaunch cartographer_ros demo_revo_lds.launch

5.rviz中结果如下:



版权声明:本文为zzr1024原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。