自动驾驶开发者说|框架|如何理解Apollo感知模块的配置文件?
引言
学习百度Apollo框架是入门自动驾驶技术较为有效的途径之一。在所有模块中,感知模块最为复杂,大量的代码和配置文件让众多初学者望而却步,我在学习的过程中有很大的收货,总结记录一下,希望能帮助到更多想要入门自动驾驶的同学。这篇文章主要分析Apollo感知模块配置文件的层次结构和所承担的作用。
启动文件--dag文件
dag文件中配置需要启动的模块的库文件路径和目录,components配置需要初始化类的类名和相关的配置文件。
位置: /apollo/modules/perception/production/dag/dag_streaming_perception_camera.dag
module_config {
module_library : "/apollo/bazel-bin/modules/perception/onboard/component/libperception_component_camera.so"
components {
class_name : "FusionCameraDetectionComponent"
config {
name: "FusionCameraComponent"
config_file_path: "/apollo/modules/perception/production/conf/perception/camera/fusion_camera_detection_component.pb.txt"
flag_file_path: "/apollo/modules/perception/production/conf/perception/perception_common.flag"
}
}
}
感知硬件/算法/使能的配置文件fusion_camera_detection_component.pb.txt
在dag文件中的config_file_path定义,是感知模块算法运行的核心配置文件,主要的内容包括配置消息接收和发送的channel;定义所使用的传感器,所用的算法和一些使能选项等。
位置:
/apollo/modules/perception/production/conf/perception/camera/fusion_camera_detection_component.pb.txt
camera_names: "front_6mm,front_12mm" #传感器
input_camera_channel_names : "/apollo/sensor/camera/front_6mm/image,/apollo/sensor/camera/front_12mm/image"
timestamp_offset : 0.0 #时间戳偏差
camera_obstacle_perception_conf_dir : "/apollo/modules/perception/production/conf/perception/camera" #模型相关的配置文件位置
camera_obstacle_perception_conf_file : "obstacle.pt" #算法模型相关的配置
frame_capacity : 20
image_channel_num : 3
enable_undistortion : false
enable_visualization : false
output_final_obstacles : false
output_obstacles_channel_name : "/perception/obstacles"
camera_perception_viz_message_channel_name : "/perception/inner/camera_viz_msg"
prefused_channel_name : "/perception/inner/PrefusedObjects"
default_camera_pitch : 0.0
default_camera_height : 1.5
lane_calibration_working_sensor_name : "front_6mm"
calibrator_method : "LaneLineCalibrator"
calib_service_name : "OnlineCalibrationService"
run_calib_service : true
output_camera_debug_msg : false
camera_debug_channel_name : "/perception/camera_debug"
ts_diff : 0.1
visual_debug_folder : "/apollo/debug_output"
visual_camera : "front_6mm"
write_visual_img : false
enable_cipv : true
debug_level : 0
cipv : "Cipv"
不同硬件类实例化配置文件
感知模块设计障碍物目标检测,多目标跟踪,车道线检测等多个算法。此外多个硬件需要对类进行多次实例化。
位置:/apollo/modules/perception/production/conf/perception/camera/obstacle.pt
gpu_id : 0
detector_param {
plugin_param{
name : "YoloObstacleDetector"
root_dir : "/apollo/modules/perception/production/data/perception/camera/models/yolo_obstacle_detector"
config_file : "config.pt"
}
camera_name : "front_6mm"
#camera_name : "spherical_left_forward"
}
detector_param {
plugin_param{
name : "YoloObstacleDetector"
root_dir : "/apollo/modules/perception/production/data/perception/camera/models/yolo_obstacle_detector"
config_file : "config.pt"
}
camera_name : "front_12mm"
}
tracker_param {
plugin_param{
name : "OMTObstacleTracker"
root_dir : "/apollo/modules/perception/production/data/perception/camera/models/omt_obstacle_tracker"
config_file : "config.pt"
}
}
算法参数的配置文件config.pt
主要配置算法模型的一些参数,包括anchors box的尺寸文件等。还有一些神经网络相关的文件配置。
位置:
/apollo/modules/perception/production/data/perception/camera/models/yolo_obstacle_detector/config.pt
model_param {
model_name: "./3d-r4-half"
model_type: "RTNetInt8"
weight_file: "deploy.model"
proto_file: "deploy.pt"
anchors_file: "anchors.txt"
types_file: "types.txt"
calibratetable_root: "./3d-r4-half"
confidence_threshold: 0.4
offset_ratio: 0.288889
cropped_ratio: 0.711111
resized_width: 1440
aligned_pixel: 32
min_2d_height: 10
min_3d_height: 0.1
ori_cycle: 2
with_box3d: true
light_swt_conf_threshold: 0
light_vis_conf_threshold: 0
with_lights: true
with_ratios: false
# num_areas: 4
border_ratio: 0.01
}
net_param {
det1_loc_blob: "loc_pred"
det1_obj_blob: "obj_pred"
det1_cls_blob: "cls_pred"
det1_ori_blob: "ori_pred"
det1_dim_blob: "dim_pred"
input_blob: "data"
feat_blob: "conv3_3"
}
nms_param {
type: "NormalNMS"
threshold: 0.5
sigma: 0.4
inter_cls_nms_thresh: 0.6
}
总结:
相比较其他模块的配置,感知模块略显复杂,算法模块的模型加载都是类似caffe的操作,和现在libtorch等的模型推理比,显得更加臃肿。文档中提到在apollo7中使用libtorch部署了smoke的算法,这部分在实际的代码中并没有体现。后续计划尝试增加/替换感知模块的算法。
往期回顾:
自动驾驶开发者说| 求职 | 2022年如何找到优秀的自动驾驶公司?
自动驾驶开发者说|框架|如何用vscode调试apollo?
自动驾驶开发者说|框架|如何单独运行apollo相机感知模块?
自动驾驶开发者说|框架|如何找到apollo感知模块的爽点?
自动驾驶开发者说| 框架 |如何快准狠的安装apollo6.0?
自动驾驶开发者说| 前沿 | CVPR2022有哪些自动驾驶方面的工作?
自动驾驶开发者说| 前沿 | 2022年ViT(vision transform)如何应用在自动驾驶任务上?
自动驾驶开发者说| 前沿 | 近两年有哪些ViT(Vision Transformer)的改进算法?
自动驾驶开发者说| 仿真 | 如何利用开源的自动驾驶仿真环境?
自动驾驶开发者说|仿真|如何安装配置lgsvl-apollo联调环境?