/****************Apollo源码分析****************************
Copyright 2018 The File Authors & zouyu. All Rights Reserved.
Contact with: 1746430162@qq.com 181663309504
源码主要是c++实现的,也有少量python,git下载几百兆,其实代码不太多,主要是地图和数据了大量空间,主要程序
在apollo/modules目录中,
在apollo/modules目录中,
我们把它分成以下几部分(具体说明见各目录下的modules):
感知:感知当前位置,速度,障碍物等等
Apollo/modules/perception
预测:对场景下一步的变化做出预测
Apollo/modules/prediction
规划:
(1) 全局路径规划:通过起点终点计算行驶路径
Apollo/modules/routing
(2) 规划当前轨道:通过感知,预测,路径规划等信息计算轨道
Apollo/modules/planning
(3) 规划转换成命令:将轨道转换成控制汽车的命令(加速,制动,转向等)
Apollo/modules/control
其它
(1) 输入输出
i. Apollo/modules/drivers 设备驱动
ii. Apollo/modules/localization 位置信息
iii. Apollo/modules/monitor 监控模块
iv. Apollo/modules/canbus 与汽车硬件交互
v. Apollo/modules/map 地图数据
vi. Apollo/modules/third_party_perception 三方感知器支持
(2) 交互
i. Apollo/modules/dreamview 可视化模块
ii. Apollo/modules/hmi 把汽车当前状态显示给用户
(3) 工具
i. Apollo/modules/calibration 标注工具
ii. Apollo/modules/common 支持其它模块的公共工具
iii. Apollo/modules/data 数据工具
iv. Apollo/modules/tools 一些Python工具
(4) 其它
i. Apollo/modules/elo 高精度定位系统,无源码,但有文档
ii. Apollo/modules/e2e 收集传感器数据给PX2,ROS
自动驾驶系统先通过起点终点规划出整体路径(routing);然后在行驶过程中感知(perception)当前环境
(识别车辆行人路况标志等),并预测下一步发展;然后把已知信息都传入规划模块(planning),规划出之后的轨道;
控制模块(control)将轨道数据转换成对车辆的控制信号,通过汽车交互模块(canbus)控制汽车.
(识别车辆行人路况标志等),并预测下一步发展;然后把已知信息都传入规划模块(planning),规划出之后的轨道;
控制模块(control)将轨道数据转换成对车辆的控制信号,通过汽车交互模块(canbus)控制汽车.
我觉得这里面算法技术含量最高的是感知perception和规划planning,具体请见本博客中各模块的分析代码。
/****************************************************************************************
/******************************************************************************
* Copyright 2017 The Apollo Authors. All Rights Reserved.
*
* 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.
*****************************************************************************/
#include "modules/perception/common/perception_gflags.h"
DEFINE_string(perception_adapter_config_filename,
"modules/perception/conf/adapter.conf",
"The adapter config filename");
/// lib/config_manager/config_manager.cc
DEFINE_string(config_manager_path, "./conf/config_manager.config",
"The ModelConfig config paths file.");
DEFINE_string(work_root, "modules/perception", "Project work root direcotry.");
/// obstacle/base/object.cc
DEFINE_bool(is_serialize_point_cloud, false,
"serialize and output object cloud");
/// obstacle/onboard/hdmap_input.cc
DEFINE_double(map_radius, 60.0, "get map radius of car center");
DEFINE_int32(map_sample_step, 1, "step for sample road boundary points");
/// obstacle/onboard/lidar_process.cc
DEFINE_bool(enable_hdmap_input, false, "enable hdmap input for roi filter");
DEFINE_string(onboard_roi_filter, "DummyROIFilter", "onboard roi filter");
DEFINE_string(onboard_segmentor, "DummySegmentation", "onboard segmentation");
DEFINE_string(onboard_object_builder, "DummyObjectBuilder",
"onboard object builder");
DEFINE_string(onboard_tracker, "DummyTracker", "onboard tracker");
DEFINE_string(onboard_type_fuser, "DummyTypeFuser", "onboard type fuser");
DEFINE_int32(tf2_buff_in_ms, 10, "the tf2 buff size in ms");
DEFINE_int32(localization_buffer_size, 40, "localization buffer size");
DEFINE_string(lidar_tf2_frame_id, "novatel", "the tf2 transform frame id");
DEFINE_string(lidar_tf2_child_frame_id, "velodyne64",
"the tf2 transform child frame id");
DEFINE_string(obstacle_module_name, "perception_obstacle",
"perception obstacle module name");
DEFINE_bool(enable_visualization, false, "enable visualization for debug");
/// obstacle/perception.cc
DEFINE_string(dag_config_path, "./conf/dag_streaming.config",
"Onboard DAG Streaming config.");
/// obstacle/onboard/radar_process_subnode.cc
DEFINE_string(onboard_radar_detector, "DummyRadarDetector",
"onboard radar detector");
DEFINE_string(radar_tf2_frame_id, "novatel", "the tf2 transform frame id");
DEFINE_string(radar_tf2_child_frame_id, "radar",
"the tf2 transform child frame id");
DEFINE_double(front_radar_forward_distance, 120.0,
"get front radar forward distancer");
DEFINE_string(radar_extrinsic_file,
"modules/perception/data/params/radar_extrinsics.yaml",
"radar extrinsic file");
DEFINE_string(short_camera_extrinsic_file,
"modules/perception/data/params/short_camera_extrinsics.yaml",
"short_camera extrinsic file");
DEFINE_string(front_camera_extrinsics_file,
"modules/perception/data/params/front_camera_extrinsics.yaml",
"front_camera extrinsic file");
DEFINE_string(front_camera_intrinsics_file,
"modules/perception/data/params/front_camera_intrinsics.yaml",
"front_camera intrinsic file");
/// obstacle/onboard/fusion_subnode.cc
DEFINE_string(onboard_fusion, "ProbabilisticFusion",
"fusion name which enabled onboard");
DEFINE_double(query_signal_range, 100.0, "max distance to front signals");
DEFINE_bool(output_raw_img, false, "write raw image to disk");
DEFINE_bool(output_debug_img, false, "write debug image to disk");
/// Temporarily change Kalman motion fusion to config here.
DEFINE_double(q_matrix_coefficient_amplifier, 0.5,
"Kalman fitler matrix Q coeffcients");
DEFINE_double(r_matrix_amplifier, 1, "Kalman fitler matrix r coeffcients");
DEFINE_double(p_matrix_amplifier, 1, "Kalman fitler matrix p coeffcients");
DEFINE_double(a_matrix_covariance_coeffcient_1, 0.05,
"Kalman fitler matrix a coeffcients, a_matrix_(0, 2)");
DEFINE_double(a_matrix_covariance_coeffcient_2, 0.05,
"Kalman fitler matrix a coeffcients, a_matrix_(1, 3)");
/// calibration_config_manager.cc
DEFINE_int32(obs_camera_detector_gpu, 0, "device id for camera detector");
// obstacle/onboard/lane_post_processing_subnode.cc
DEFINE_string(onboard_lane_post_processor, "CCLanePostProcessor",
"onboard lane post-processing algorithm name");
/// visualization
DEFINE_bool(show_front_radar_raw, false, "");
DEFINE_bool(show_back_radar_raw, false, "");
DEFINE_bool(show_radar_objects, false, "");
DEFINE_bool(show_front_radar_objects, false, "");
DEFINE_bool(show_back_radar_objects, false, "");
DEFINE_bool(show_camera_objects2d, false, "");
DEFINE_bool(show_camera_objects, false, "");
DEFINE_bool(show_camera_parsing, false, "");
DEFINE_bool(show_fused_objects, false, "");
DEFINE_bool(show_fusion_association, false, "");
DEFINE_bool(capture_screen, false, "");
DEFINE_string(screen_output_dir, "./", "");
DEFINE_string(frame_visualizer, "GLFusionVisualizer", "");
DEFINE_double(car_length, 3.564, "car_length");
DEFINE_double(car_width, 1.620, "car_width");
/******************************************************************************
* Copyright 2017 The Apollo Authors. All Rights Reserved.
*
* 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.
*****************************************************************************/
#include
"modules/perception/common/perception_gflags.h"
//这是上一个博客里提到的头文件
DEFINE_string
(perception_adapter_config_filename,
"modules/perception/conf/adapter.conf"
,
"The adapter config filename"
);
//下面就是 adapter.conf这个文件,里面包含了点云、定位、雷达、图像、 交通灯等等消息
// config: {
// type: POINT_CLOUD
// mode: RECEIVE_ONLY
// message_history_limit: 1
// }
// config: {
// type: LOCALIZATION
// mode: RECEIVE_ONLY
// message_history_limit: 1
// }
// config: {
// type: CONTI_RADAR
// mode: RECEIVE_ONLY
// message_history_limit: 2
// }
// config {
// type: PERCEPTION_OBSTACLES
// mode: PUBLISH_ONLY
// message_history_limit: 50
// }
// config: {
// type: IMAGE_SHORT
// mode: RECEIVE_ONLY
// message_history_limit: 5
// }
// config {
// type: IMAGE_LONG
// mode: RECEIVE_ONLY
// message_history_limit: 5
// }
// config {
// type: TRAFFIC_LIGHT_DETECTION
// mode: PUBLISH_ONLY
// message_history_limit: 50
// }
//is_ros: true
/// lib/config_manager/config_manager.cc
DEFINE_string
(config_manager_path,
"./conf/config_manager.config"
,
"The ModelConfig config paths file."
);
DEFINE_string
(work_root,
"modules/perception"
,
"Project work root direcotry."
);
/// obstacle/base/object.cc
DEFINE_bool
(is_serialize_point_cloud,
false
,
"serialize and output object cloud"
);
/// obstacle/onboard/hdmap_input.cc//高清地图的输入
DEFINE_double
(map_radius,
60.0
,
"get map radius of car center"
);
DEFINE_int32
(map_sample_step,
1
,
"step for sample road boundary points"
);
/// obstacle/onboard/lidar_process.cc
DEFINE_bool
(enable_hdmap_input,
false
,
"enable hdmap input for roi filter"
);
DEFINE_string
(onboard_roi_filter,
"DummyROIFilter"
,
"onboard roi filter"
);
DEFINE_string
(onboard_segmentor,
"DummySegmentation"
,
"onboard segmentation"
);
DEFINE_string
(onboard_object_builder,
"DummyObjectBuilder"
,
"onboard object builder"
);
DEFINE_string
(onboard_tracker,
"DummyTracker"
,
"onboard tracker"
);
DEFINE_string
(onboard_type_fuser,
"DummyTypeFuser"
,
"onboard type fuser"
);
DEFINE_int32
(tf2_buff_in_ms,
10
,
"the tf2 buff size in ms"
);
DEFINE_int32
(localization_buffer_size,
40
,
"localization buffer size"
);
DEFINE_string
(lidar_tf2_frame_id,
"novatel"
,
"the tf2 transform frame id"
);
DEFINE_string
(lidar_tf2_child_frame_id,
"velodyne64"
,
"the tf2 transform child frame id"
);
DEFINE_string
(obstacle_module_name,
"perception_obstacle"
,
"perception obstacle module name"
);
DEFINE_bool
(enable_visualization,
false
,
"enable visualization for debug"
);
/// obstacle/perception.cc
DEFINE_string
(dag_config_path,
"./conf/dag_streaming.config"
,
"Onboard DAG Streaming config."
);
/// obstacle/onboard/radar_process_subnode.cc
DEFINE_string
(onboard_radar_detector,
"DummyRadarDetector"
,
"onboard radar detector"
);
DEFINE_string
(radar_tf2_frame_id,
"novatel"
,
"the tf2 transform frame id"
);
DEFINE_string
(radar_tf2_child_frame_id,
"radar"
,
"the tf2 transform child frame id"
);
DEFINE_double
(front_radar_forward_distance,
120.0
,
"get front radar forward distancer"
);
DEFINE_string
(radar_extrinsic_file,
"modules/perception/data/params/radar_extrinsics.yaml"
,
"radar extrinsic file"
);
DEFINE_string
(short_camera_extrinsic_file,
"modules/perception/data/params/short_camera_extrinsics.yaml"
,
"short_camera extrinsic file"
);
DEFINE_string
(front_camera_extrinsics_file,
"modules/perception/data/params/front_camera_extrinsics.yaml"
,
"front_camera extrinsic file"
);
DEFINE_string
(front_camera_intrinsics_file,
"modules/perception/data/params/front_camera_intrinsics.yaml"
,
"front_camera intrinsic file"
);
/// obstacle/onboard/fusion_subnode.cc
DEFINE_string
(onboard_fusion,
"ProbabilisticFusion"
,
"fusion name which enabled onboard"
);
DEFINE_double
(query_signal_range,
100.0
,
"max distance to front signals"
);
DEFINE_bool
(output_raw_img,
false
,
"write raw image to disk"
);
DEFINE_bool
(output_debug_img,
false
,
"write debug image to disk"
);
/// Temporarily change Kalman motion fusion to config here.
DEFINE_double
(q_matrix_coefficient_amplifier,
0.5
,
"Kalman fitler matrix Q coeffcients"
);
DEFINE_double
(r_matrix_amplifier,
1
,
"Kalman fitler matrix r coeffcients"
);
DEFINE_double
(p_matrix_amplifier,
1
,
"Kalman fitler matrix p coeffcients"
);
DEFINE_double
(a_matrix_covariance_coeffcient_1,
0.05
,
"Kalman fitler matrix a coeffcients, a_matrix_(0, 2)"
);
DEFINE_double
(a_matrix_covariance_coeffcient_2,
0.05
,
"Kalman fitler matrix a coeffcients, a_matrix_(1, 3)"
);
/// calibration_config_manager.cc
DEFINE_int32
(obs_camera_detector_gpu,
0
,
"device id for camera detector"
);
// obstacle/onboard/lane_post_processing_subnode.cc
DEFINE_string
(onboard_lane_post_processor,
"CCLanePostProcessor"
,
"onboard lane post-processing algorithm name"
);
/// visualization
DEFINE_bool
(show_front_radar_raw,
false
,
""
);
DEFINE_bool
(show_back_radar_raw,
false
,
""
);
DEFINE_bool
(show_radar_objects,
false
,
""
);
DEFINE_bool
(show_front_radar_objects,
false
,
""
);
DEFINE_bool
(show_back_radar_objects,
false
,
""
);
DEFINE_bool
(show_camera_objects2d,
false
,
""
);
DEFINE_bool
(show_camera_objects,
false
,
""
);
DEFINE_bool
(show_camera_parsing,
false
,
""
);
DEFINE_bool
(show_fused_objects,
false
,
""
);
DEFINE_bool
(show_fusion_association,
false
,
""
);
DEFINE_bool
(capture_screen,
false
,
""
);
DEFINE_string
(screen_output_dir,
"./"
,
""
);
DEFINE_string
(frame_visualizer,
"GLFusionVisualizer"
,
""
);
DEFINE_double
(car_length,
3.564
,
"car_length"
);
DEFINE_double
(car_width,
1.620
,
"car_width"
);