Back to Apollo

激光雷达感知参数开发实践

docs/应用实践/开发调试教程/Apollo感知实践/基于配置参数开发/激光雷达感知参数开发实践.md

11.0.034.3 KB
Original Source

激光雷达和相机是目前自动驾驶中最重要的 2 个传感器,由于激光雷达测距准确,因此检测出的障碍物的精度普遍会比相机高。

激光雷达(Laser Radar,简称 LiDAR)是一种通过激光束来探测目标位置、反射强度等特征量的传感器。它由激光发射机、光学接收机、转台和信息处理系统等组成。激光器将电脉冲变成光脉冲发射出去,光接收机再把从目标反射回来的光脉冲还原成电脉冲,送到显示器。

激光雷达相比传统雷达,具有高分辨率、高精度、抗有源干扰能力强等优点。它的工作原理是利用激光的波长和脉冲宽度,通过测量光的传播时间来精确测量距离。激光雷达的发射系统口径很小,可接收区域窄,有意发射的激光干扰信号进入接收机的概率极低。

根据扫描系统的差异,激光雷达可以分为机械式、混合固态(转镜式、棱镜式、MEMS振镜)、固态(FLASH、OPA)等。根据测距方法的差异,就可以分为 TOF 激光雷达、FMCW 激光雷达。

激光雷达感知整体框架

Apollo 激光雷达的感知由以下几个组件构成,它们一起工作共同实现了激光雷达感知功能。

在介绍各个模块之前,我们首先需要知道激光雷达感知模块的输入和输出,以及它的工作原理。

激光雷达感知模块的输入:

  • 激光雷达点云。由激光雷达传感器生成,通过扫描周围环境得到一系列的点和反射强度值。订阅消息的通道/apollo/sensor/lidar16/compensator/PointCloud2

  • 坐标转换。检测到的障碍物在激光雷达坐标系,需要转换到世界坐标系下,因此需要激光雷达到世界坐标的转换关系。订阅消息的通道/tf和/tf_static

激光雷达感知模块的输出:

  • 障碍物信息。通过点云检测到的障碍物信息,包括目标的类别,大小,速度以及追踪 ID 等,用于后续的规划模块进行路径规划。发布消息的通道为/apollo/perception/obstacles

接下来我们详细介绍这几个模块。

点云预处理(pointcloud_preprocess)

点云预处理是激光雷达感知的第一个组件,它的主要功能如下:

  • 过滤无效点,即过滤坐标为 nan 的点

  • 过滤高度超过 z_threshold 的点。比如过滤高度大于 6 米的点。

  • 通过自车的点,考虑到激光雷达安装位置,有可能扫描到自己,因此过滤自身的点,避免误当作障碍物。

高精度地图过滤(pointcloud_map_based_roi)

过滤 ROI 之外的点云。

感兴趣区域 (ROI) 指定可行驶区域,包括从高精地图检索到的路面和路口。 HDMap ROI 过滤器处理 ROI 外部的 lidar 点,去除背景物体,例如道路周围的建筑物和树木。剩下的就是 ROI 中的点云以供后续处理。

地面检测(pointcloud_ground_detection)

查找地面,查找地面的目的主要是为了后续做点云分割。

3D 目标检测(lidar_detection)

通过深度学习算法,对上述处理过的点云进行目标检测,最后得到当前场景下的行人、车辆和非机动车辆的位置和速度信息等。

目前 Apollo 一共支持以下 4 种激光雷达目标检测模型。

  • center_point_detection :是一种基于点云的 anchor-free 的三维目标检测算法,该模型在计算效率和准确度上有一定的优势。其核心思想是通过预测物体的中心点来进行目标检测和位置回归,而不需要预先产生大量候选框(anchor)。

  • cnn_segmentation :自研模型。

  • mask_pillars_detection :自研模型,基于 point_pillars 做了一些改进。

  • point_pillars_detection :是一种用于自动驾驶的3D目标检测模型,它基于点云数据实现。该模型通过将点云数据转化为柱形稀疏表示,然后结合 2D CNN 和 3D SSD 来进行目标检测。

目前支持的在线推理框架有:

  • pytorch

  • paddle

  • onnx

  • TensorRT

已经开放训练代码的模型是 center_point 激光雷达检测模型,后续会讲到如何进行模型训练和部署。

检测结果过滤(lidar_detection_filter)

根据对象属性、车道线、ROI 等过滤模型检测出的前景和背景障碍物。

目标追踪(lidar_tracking)

对检测到的障碍物进行追踪,从而获取到目标的速度和追踪 ID,用于后续进行目标轨迹预测。

消息转发(msg_adapter)

msg 适配器模块用于在感知模块内部转发消息。

内部消息的通道名称通常有一个内部字段“inner”。 这些消息仅在线程之间传递,而不是在进程之间传递,因此您无法使用 cyber_monitor 来查看它们。因为这些消息一般都比较大,比如图像、点云数据,为了避免复制、序列化和反序列化,我们采用直接传递对象的方法,所以这些消息只能在线程内传递。

为了方便调试,可以使用 msg 适配器模块转发消息,这样就可以通过 cyber_monitor 查看。而且单纯的激光雷达感知不需要进行传感器融合,因此需要通过 msg_adapter 模块进行消息转发输出,如果有多传感器融合模块,则需要启动激光雷达、相机和毫米波雷达模块加上融合模块才能输出最终的感知结果。

激光雷达感知参数介绍

接下来我们会介绍第一种感知开发模式:修改激光雷达感知模块参数。

参数目录结构

首先介绍各个组件的配置目录,以激光雷达检测模块为例

bash
├── lidar_detection
    ├── conf            // 组件配置文件
    ├── dag             // 组件dag文件
    ├── data            // 功能配置文件
    ├── detector
    │   ├── center_point_detection
    │   ├── cnn_segmentation
    │   ├── mask_pillars_detection
    │   └── point_pillars_detection
    ├── interface
    ├── proto
    ├── lidar_detection_component.cc
    ├── lidar_detection_component.h
    ├── cyberfile.xml   // 包配置文件
    ├── README.md
    └── BUILD

公共配置目录,多个组件的公共配置放到modules/perception/data路径下。

bash
modules/perception/data
├── BUILD
├── conf    // 感知公共配置,例如一些单例
├── cyberfile.xml
├── flag    // 感知模块所有的gflags命令行传入,用于dag
├── models  // 模型存放路径
└── params  // 传感器内外参

全局配置

gflag配置:modules/perception/common/perception_gflags.h

参数名默认值含义
obs_sensor_intrinsic_path/apollo/modules/perception/data/params传感器内参路径
obs_sensor_meta_filesensor_meta.pb.txt传感器meta文件名
enable_base_object_poolenable_base_object_pool开启对象池
config_manager_path./配置管理器路径
work_root/apollo/modules/perception工作目录
onnx_obstacle_detector_model/apollo/modules/perception/camera/lib/obstacle/detector/yolov4/model/yolov4_1_3_416_416.onnx目标检测模型
onnx_test_input_path/apollo/modules/perception/inference/onnx/testdata/dog.jpg目标检测测试路径
onnx_test_input_name_file/apollo/modules/perception/inference/onnx/testdata/coco.names目标检测测试文件
onnx_prediction_image_path/apollo/modules/perception/inference/onnx/testdata/prediction.jpg目标检测预测图像路径
num_classes80目标类型数量
torch_detector_model/apollo/modules/perception/camera/lib/obstacle/detector/yolov4/model/yolov4.pttorch检测模型路径
lidar_sensor_namevelodyne128lidar传感器名称
use_trtfalse是否使用tensorrt
trt_precision1tensorrt的精度,0: 32float,1: kInt8
trt_use_statictrue是否从磁盘路径加载tensorrt图优化
use_calibrationtrue是否使用校正表
use_dynamicshapetrue是否使用动态形状
collect_shape_infotrue是否采集动态形状信息
dynamic_shape_file/apollo/modules/perception/lidar_detection/data/center_point_paddle/pillar_20_0625/collect_shape_info_3lidar_20.pbtxt动态文件路径
object_template_fileobject_template.pb.txt对象模版配置文件
hdmap_sample_step5高精度地图采样率
scene_manager_filescene_manager.conf场景管理器配置文件
roi_service_fileroi_service.confROI服务配置文件
ground_service_fileground_service.conf地面检测服务配置文件

modules/perception/common/onboard/common_flags/common_flags.h

参数名默认值含义
obs_enable_hdmap_inputtrue为 roi 过滤器启用 hdmap 输入
obs_enable_visualizationfalse是否发送可视化消息
obs_screen_output_dir./输出目录,用于保存可视化屏幕截图
obs_benchmark_modefalse是否开启 benchmark 模式,默认 false
obs_save_fusion_supplementfalse是否保存融合补充数据,默认false
start_visualizerfalse

点云预处理配置(pointcloud_preprocess)

pointcloud_preprocessor配置:

modules/perception/pointcloud_preprocess/data/pointcloud_preprocessor.pb.txt

参数类型参数名默认值含义
boolfilter_naninf_pointstrue是否过滤nan点
boolfilter_nearby_box_pointstrue是否过滤自车周围的点(大小由以下4个值确定)
floatbox_forward_x1.0(米)自车imu到右边界距离
floatbox_backward_x-1.0(米)自车imu到左边界距离
floatbox_forward_y2.0(米)自车imu到前边界距离
floatbox_backward_y-1.5(米)自车imu到后边界距离
boolfilter_high_z_pointstrue是否过滤超过高度阈值的点
floatz_threshold2.0(米)高度过滤阈值

高精度地图过滤(pointcloud_map_based_roi)

hdmap_roi_filter配置:

modules/perception/pointcloud_map_based_roi/data/hdmap_roi_filter.pb.txt

参数类型参数名默认值含义
floatrange120.0基于LiDAR传感器点的2D网格ROI LUT的图层范围
floatcell_size0.25用于量化2D网格的单元格的大小。
floatextend_dist0外扩ROI边界的距离。
boolno_edge_tablefalse是否有edge table
boolset_roi_servicetrue是否启用ROI Service

map_manager配置:

modules/perception/pointcloud_map_based_roi/data/map_manager.pb.txt

参数类型参数名默认值含义
boolupdate_posefalse是否更新lidar到世界坐标系的位姿
floatroi_search_distance120.0(米)ROI搜索的距离范围

地面检测(pointcloud_ground_detection)

spatio_temporal_ground_detector配置文件: modules/perception/pointcloud_ground_detection/data/spatio_temporal_ground_detector.pb.txt

参数类型参数名默认值含义
uint32grid_size16网格size
floatground_thres0.25地面高度阈值,低于则认为是地面
floatroi_rad_x120.0x方向roi radius
floatroi_rad_y120.0y方向roi radius
floatroi_rad_z100.0z反向roi radius
uint32nr_smooth_iter5smooth迭代次数
booluse_roitrue是否用roi内的点云
booluse_ground_servicetrue是否用ground service

3D目标检测(lidar_detection)

此模块配置文件路径: modules/perception/lidar_detection/confmodules/perception/lidar_detection/data

ModelInfo 配置,文件路径:modules/perception/common/proto/model_info.proto

参数类型参数名默认值含义
stringname/模型名称,同models/下文件夹名
stringframework/模型推理框架
stringModelFile.proto_file/模型网络结构
stringModelFile.weight_file/模型权重文件
stringModelFile.anchors_file/anchor size
stringModelBlob.inputs/模型输入数据名称及维度
int32ModelBlob.outputs/模型输出数据名称及维度

PointCloudPreProcess:

参数类型参数名默认值含义
int32gpu_id0GPU的id
doublenormalizing_factor255强度归一化的缩放因子
int32num_point_feature4每个点的特征数量
boolenable_ground_removalfalse是否过滤掉地面点
doubleground_removal_height-1.5过滤掉z值小于阈值的点
boolenable_downsample_beamsfalse是否根据beam id对点云进行过滤
int32downsample_beams_factor4保留beam id为downsample_beams_factor的倍数的点云
boolenable_downsample_pointcloudfalse是否根据voxel过滤点云
doubledownsample_voxel_size_x0.01过滤时voxel的x方向长度
doubledownsample_voxel_size_y0.01过滤时voxel的y方向长度
doubledownsample_voxel_size_z0.01过滤时voxel的z方向长度
boolenable_fuse_framesfalse是否融合多帧点云
int32num_fuse_frames5融合点云的帧数
doublefuse_time_interval0.5融合点云的时间间隔
boolenable_shuffle_pointsfalse是否打乱点云索引
int32max_num_points2147483647允许的最大点云数量
boolreproduce_result_modefalse是否开启复现结果模式
boolenable_roi_outside_removalfalse是否在输入模型之前将roi外的点云进行过滤

PointCloudPostProcess:

参数类型参数名默认值含义
floatscore_threshold0.5置信度阈值
floatnms_overlap_threshold0.5NMS的iou阈值
int32num_output_box_feature7输出障碍物的属性个数
floatbottom_enlarge_height0.25获取目标真实点云时向上扩充的范围
floattop_enlarge_height0.25获取目标真实点云时向下扩充的范围
floatwidth_enlarge_value0获取目标真实点云时宽度扩充的范围
floatlength_enlarge_value0获取目标真实点云时长度扩充的范围

cnnseg 配置 modules/perception/lidar_detection/detector/cnn_segmentation/proto/model_param.proto

<table><thead><tr><th>参数类型</th><th></th><th>参数名</th><th>默认值</th><th>含义</th></tr></thead><tbody><tr><td>ModelInfo</td><td></td><td>info</td><td>/</td><td>模型基本配置</td></tr><tr><td rowspan="7">FeatureParam</td><td>float</td><td>point_cloud_range</td><td>90</td><td>点云范围</td></tr><tr><td>uint32</td><td>width</td><td>864</td><td>BEV宽度</td></tr><tr><td>uint32</td><td>height</td><td>864</td><td>BEV高度</td></tr><tr><td>float</td><td>min_height</td><td>-5.0</td><td>点云z值最小值</td></tr><tr><td>float</td><td>max_height</td><td>5.0</td><td>点云z值最大值</td></tr><tr><td>bool</td><td>use_intensity_feature</td><td>true</td><td>是否使用强度特征</td></tr><tr><td>bool</td><td>use_constant_feature</td><td>false</td><td>是否使用常数特征</td></tr><tr><td>bool</td><td></td><td>do_classification</td><td>true</td><td>是否预测分类信息</td></tr><tr><td>bool</td><td></td><td>do_heading</td><td>true</td><td>是否预测朝向角信息</td></tr><tr><td>PointCloudPreProcess</td><td></td><td>preprocess</td><td>/</td><td>预处理信息</td></tr><tr><td>SppEngineConfig</td><td>float</td><td>height_gap</td><td>0.5</td><td>高度差距</td></tr><tr><td>bool</td><td></td><td>remove_ground_points</td><td>true</td><td>是否过滤掉障碍物中的地面点</td></tr><tr><td>float</td><td></td><td>objectness_thresh</td><td>0.5</td><td>objectness的阈值</td></tr><tr><td>float</td><td></td><td>confidence_thresh</td><td>0.1</td><td>confidence的阈值</td></tr><tr><td>float</td><td></td><td>height_thresh</td><td>0.5</td><td>高度阈值</td></tr><tr><td>uint32</td><td></td><td>min_pts_num</td><td>3</td><td>目标最少点数</td></tr><tr><td>float</td><td></td><td>confidence_range</td><td>85</td><td>置信度范围</td></tr><tr><td>bool</td><td></td><td>fill_recall_with_segmentor</td><td>true</td><td>是否使用背景分割</td></tr></tbody></table>

centerpoint配置:

modules/perception/lidar_detection/data/center_point_param.pb.txt

参数类型参数名默认值含义
ModelInfoinfo/模型通用配置
PointCloudPreProcesspreprocess/预处理
PointCloudPostProcesspostprocess/后处理
int32point2box_max_num5每个点最多可以属于多少个box
floatquantize0.2

检测结果过滤(lidar_detection_filter)

background_filter 配置: modules/perception/lidar_detection_filter/data/background_filter.pb.txt

参数类型参数名默认值含义
floatoutside_roi_filter_distance1.0在车道线之外的距离阈值

roi_boundary_filter配置:

modules/perception/lidar_detection_filter/data/roi_boundary_filter.pb.txt

参数类型参数名默认值含义
floatdistance_to_boundary_threshold2.5障碍物在车道线外时,距离车道线边界的阈值, 大于该阈值则被删除
floatconfidence_threshold0.0目标置信度阈值
floatcross_roi_threshold0.6目标是否在roi交界处的阈值
floatinside_threshold-1.0障碍物在车道线内时,距离车道线边界的阈值,

目标追踪(lidar_tracking)

fused_classifer

fused_classifier 配置文件:

modules/perception/lidar_tracking/data/fused_classifier/fused_classifier.pb.txt

参数类型参数名默认值含义
floattemporal_window20.0时间窗口
boolenable_temporal_fusiontrue是否开启时间融合
stringone_shot_fusion_methodCCRFOneShotTypeFusionone shot fusion方法
stringsequence_fusion_methodCCRFSequenceTypeFusionsequence fusion方法
booluse_tracked_objectstrue是否使用跟踪的目标

ccrf_type_fusion配置文件:

参数类型参数名默认值含义
stringclassifiers_property_file_pathnull分类属性文件路径
stringtransition_property_file_pathnull转移属性文件路径
floattransition_matrix_alpha1.8转移矩阵alpha参数

tracker

mlf_engine 配置文件: modules/perception/lidar_tracking/data/tracking/mlf_engine.pb.txt

参数类型参数名默认值含义
stringmain_sensor/主传感器
booluse_histogram_for_matchtrue是否用histogram用来做匹配
uint32histogram_bin_size10histogram的大小
booloutput_predict_objectsfalse是否输出预测目标
doublereserved_invisible_time0.2保留不可见时间
booluse_frame_timestampfalse是否用frame时间戳

mlf_track_object_matcher 配置文件: modules/perception/lidar_tracking/data/tracking/mlf_track_object_matcher.conf

参数类型参数名默认值含义
stringforeground_mathcer_methodMultiHmBipartiteGraphMatcher前景目标匹配方法
stringbackground_matcher_methodGnnBipartiteGraphMatcher背景目标匹配方法
floatbound_value100.0边界值
floatmax_match_distance4.0最大匹配距离

mlf_track_object_distance 配置文件: modules/perception/lidar_tracking/data/tracking/mlf_track_object_distance.conf

参数类型参数名默认值含义
stringsensor_name_pairnull传感器名称pair
floatlocation_dist_weight0位置距离权重
floatdirection_dist_weight0方向距离权重
floatbbox_size_dist_weight0bbox大小距离权重
floatpoint_num_dist_weight0目标点云数量距离权重
floathistogram_dist_weight0统计直方图距离权重
floatcentroid_shift_dist_weight0中心点偏移距离权重
floatbbox_iou_dist_weight0bbox iou距离权重
floatsemantic_map_dist_weight0语义图距离权重

mlf_tracker配置文件: modules/perception/lidar_tracking/data/tracking/mlf_tracker.conf

参数类型参数名默认值含义
stringfilter_name/filter名称

mlf_motion_filter配置文件: modules/perception/lidar_tracking/data/tracking/mlf_motion_filter.conf

参数类型参数名默认值含义
booluse_adaptivetrue是否用自适应方法
booluse_breakdowntrue是否使用breakdown
booluse_convergence_boostuptrue是否用收敛启动
doubleinit_velocity_variance5.0速度方差初始参数
doubleinit_acceleration_variance10.0加速度方差初始参数
doublemeasured_velocity_variance0.4速度方差测量参数
doublepredict_variance_per_sqrsec1.0预测方差参数
uint32boostup_history_size_minimum3历史最小值初始化参数
uint32boostup_history_size_maximum6历史最大值初始化参数
doubleconverged_confidence_minimum0.5最小收敛置信度参数
doublenoise_maximum0.1最大噪声参数
doubletrust_orientation_range40方向范围信任参数

mlf_motion_refiner配置文件: modules/perception/lidar_tracking/data/tracking/mlf_motion_refiner.conf

参数类型参数名默认值含义
doubleclaping_acceleration_threshold10.0加速度截断阈值
doubleclaping_speed_threshold1.0速度截断阈值

mlf_shape_filter配置文件: modules/perception/lidar_tracking/data/tracking/mlf_shape_filter.conf

参数类型参数名默认值含义
doublebottom_points_ignore_threshold0.1底部点云忽略阈值
doubletop_points_ignore_threshold1.6头部点云忽略阈值

消息转发(msg_adapter)

modules/perception/msg_adapter/common/msg_adapter_gflags.h

参数名默认值含义
cameraframe_to_obstacles_in/fake_topiccameraframe输入
cameraframe_to_obstacles_out/apollo/perception/obstaclescameraframe转obstacles输出
sensorframe_message_to_obstacles_in/fake_topicsensorframe_message输入
sensorframe_message_to_obstacles_out/apollo/perception/obstaclessensorframe_message转obstacles输出
lidarframe_to_obstacles_in/fake_topiclidarframe输入
lidarframe_to_obstacles_out/apollo/perception/obstacles

激光雷达感知参数开发模式

1. 进入Docker环境

bash
# 进入容器
aem enter

# 下载安装依赖包: 会拉取安装core目录下的cyberfile.xml里面所有的依赖包
buildtool build --gpu

2. 启动Dreamview

bash
aem bootstrap start --plus

注意:plus 参数指的是启动 dreamview+,如需启动老版本 dreamview,去掉 --plus 参数即可。

3. 查看感知模型

通过 amodel 命令查看当前系统中已经安装的感知模型。

bash
amodel list

4. 修改参数

  1. 修改模型输出置信度

    通过调整模型输出置信度,学习如何调整模型的检测结果输出。模型的置信度越高,检测的结果越准确,但召回率会变低,模型的置信度变低,召回率变高,准确率变低,因此要平衡准确率和召回率,来达到一个比较好的效果。

    首先检查/apollo/modules/perception/lidar_detection/conf/lidar_detection_config.pb.txt中的配置是否为 CenterPointDetection:

    bash
    plugin_param {
       name: "CenterPointDetection"
       config_path: "perception/lidar_detection/data"
       config_file: "center_point_param.pb.txt"
     }
    

    然后在/apollo/modules/perception/lidar_detection/data/center_point_param.pb.txt修改score_threshold

    bash
        postprocess {
      score_threshold: 0.25      // 检测结果置信度
      num_output_box_feature: 7
      bottom_enlarge_height: 0.1  // 0.25 -> 0.1
      top_enlarge_height: 0.25
      width_enlarge_value: 0
      length_enlarge_value: 0
    }
    

  2. 修改 ROI 范围

    修改 ROI 参数可以通过规则过滤不需要关注的障碍物,避免对自动驾驶汽车的干扰。

    找到/apollo/modules/perception/lidar_detection_filter/data/roi_boundary_filter.pb.txt文件,修改参数

    bash
    distance_to_boundary_threshold: 0.0
    confidence_threshold: 0.0
    cross_roi_threshold: 0.6
    inside_threshold: -1.0
    

5. 启动lidar感知程序

选择相应车型配置

启动 transform 模块

启动 lidar 感知模块

下载并播放感知包,在dreamview+左下角点击resource manger,下载sensorrgb数据包,下载完成后选择sensorrgb数据包点击播放。

dreamview+ 查看 lidar 检测结果: