一、感知(perception)模块的作用
感知 (Perception)** 模块是自动驾驶系统的核心组件之一,负责从传感器数据中提取环境信息,为后续的决策和控制提供基础。
-
上游依赖:
传感器驱动(如激光雷达、摄像头、毫米波雷达)提供原始数据。 -
下游支持:
- 规划 (Planning):基于感知的障碍物信息规划无碰撞路径。
- 控制 (Control):根据感知的车道线和目标位置实现精确控制。
- 定位 (Localization):与感知结果融合提高定位精度。
二、启动流程
在源码autoware_launch里面找到
<!-- Perception -->
<group if="$(var launch_perception)">
<include file="$(find-pkg-share autoware_launch)/launch/components/tier4_perception_component.launch.xml">
<arg name="data_path" value="$(var data_path)"/>
</include>
</group>
然后以及进入相应的launch文件找到作中的 ground_segmentation.launch.py文件;然后看其启动的顺序以及传入的话题的名称和以下参数的配置。
如下所示
return launch.LaunchDescription(
launch_arguments
+ [set_container_executable, set_container_mt_executable]
+ [OpaqueFunction(function=launch_setup)]
)
然后看定义的python函数 launch_setup :
def launch_setup(context, *args, **kwargs):
pipeline = GroundSegmentationPipeline(context)
components = []
components.extend(
pipeline.create_single_frame_obstacle_segmentation_components(
input_topic=LaunchConfiguration("input/pointcloud"),
output_topic=pipeline.single_frame_obstacle_seg_output
if pipeline.use_single_frame_filter or pipeline.use_time_series_filter
else pipeline.output_topic,
)
)
relay_topic = "single_frame/filtered/pointcloud"
if pipeline.use_single_frame_filter:
components.extend(
pipeline.create_single_frame_outlier_filter_components(
input_topic=pipeline.single_frame_obstacle_seg_output,
output_topic=relay_topic
if pipeline.use_time_series_filter
else pipeline.output_topic,
context=context,
)
)
if pipeline.use_time_series_filter:
components.extend(
pipeline.create_time_series_outlier_filter_components(
input_topic=relay_topic
if pipeline.use_single_frame_filter
else pipeline.single_frame_obstacle_seg_output,
output_topic=pipeline.output_topic,
)
)
pointcloud_container_loader = LoadComposableNodes(
composable_node_descriptions=components,
target_container=LaunchConfiguration("pointcloud_container_name"),
)
return [pointcloud_container_loader]
进入相应的函数去找相应的启动的功能包。
三、功能包和重要的源码
(1)ground_segmentation
convertPointcloudGridScan(input, radial_ordered_points);
classifyPointCloudGridScan(input, radial_ordered_points, no_ground_indices);
注释:
1. convertPointcloudGridScan
函数
将输入点云数据按径向角度和距离进行结构化划分,生成便于后续处理的网格数据结构
2. classifyPointCloudGridScan
函数
基于结构化的网格点云,通过多条件判断将点分类为地面点或非地面点。
2) occupancy_grid_map_outlier_filter
主要功能是结合占用栅格地图(Occupancy Grid Map)和二维半径搜索算法,过滤点云中的离群点(Outlier),提高点云数据的质量 。
注释:
(1)onOccupancyGridMapAndPointCloud2
void OccupancyGridMapOutlierFilterComponent::onOccupancyGridMapAndPointCloud2(
const OccupancyGrid::ConstSharedPtr & input_ogm, const PointCloud2::ConstSharedPtr & input_pc)
- 功能:栅格地图和点云的同步回调函数,处理数据并发布结果
- 输入:
input_ogm
:占用栅格地图input_pc
:输入点云- 输出:发布过滤后的点云到
~/output/pointcloud
(2) splitPointCloudFrontBack
void OccupancyGridMapOutlierFilterComponent::splitPointCloudFrontBack(
const PointCloud2::ConstSharedPtr & input_pc, PointCloud2 & front_pc, PointCloud2 & behind_pc)
- 功能:将点云按车辆前后分割(x=0 为分界线)
- 输入:
input_pc
:原始点云- 输出:
front_pc
:车辆前方点云behind_pc
:车辆后方点云
(3) filterByOccupancyGridMap
void OccupancyGridMapOutlierFilterComponent::filterByOccupancyGridMap(
const OccupancyGrid & occupancy_grid_map, const PointCloud2 & pointcloud,
PointCloud2 & high_confidence, PointCloud2 & low_confidence, PointCloud2 & out_ogm)
- 功能:基于栅格地图代价过滤点云,分为高置信度、低置信度和地图外点
- 输入:
occupancy_grid_map
:占用栅格地图pointcloud
:待过滤点云
- 输出:
high_confidence
:高置信度点云(代价高于阈值)low_confidence
:低置信度点云(代价低于阈值)out_ogm
:地图外的点云
附加:主要是这个订阅在其作用
pointcloud_sub_.subscribe(this, "~/input/pointcloud", rmw_qos_profile_sensor_data);
occupancy_grid_map_sub_.subscribe(
this, "~/input/occupancy_grid_map", rclcpp::QoS{1}.get_rmw_qos_profile());
sync_ptr_ = std::make_shared<Sync>(SyncPolicy(5), occupancy_grid_map_sub_, pointcloud_sub_);
sync_ptr_->registerCallback(std::bind(
&OccupancyGridMapOutlierFilterComponent::onOccupancyGridMapAndPointCloud2, this,
std::placeholders::_1, std::placeholders::_2));
pointcloud_pub_ = create_publisher<PointCloud2>("~/output/pointcloud", rclcpp::SensorDataQoS());
3)multi_object_tracker
主要用于接收多个传感器(如摄像头、雷达等)的检测结果,通过跟踪算法对多个目标进行持续跟踪,并发布跟踪后的对象状态。
(1)onTrigger
void MultiObjectTracker::onTrigger()
- 作用:当输入数据到达时触发跟踪处理流程
- 关键操作:
- 从输入管理器获取检测对象列表
- 调用
onMessage
处理数据 - 根据配置决定是否立即发布结果
- 数据流入:通过输入管理器获取
DetectedObjects
列表 - 数据流出:触发后续处理流程,可能直接发布跟踪结果
(2)onTimer
void MultiObjectTracker::onTimer()
- 作用:定时触发跟踪处理(用于延迟补偿场景)
- 关键操作:
- 检查发布周期,决定是否执行处理
- 从输入管理器获取检测对象
- 调用
onMessage
处理数据并发布
- 数据流入:定时触发,获取最新检测数据
- 数据流出:发布跟踪结果到输出话题
4)map_based_prediction
主要用于借助高精度地图数据来预测交通参与者(像车辆、行人这类)的未来轨迹。该功能包会融合传感器检测结果与地图信息,进而提升运动预测的准确性和可靠性。
(1)主要的话题
ub_objects_ = this->create_subscription<TrackedObjects>(
"~/input/objects", 1,
std::bind(&MapBasedPredictionNode::objectsCallback, this, std::placeholders::_1));
sub_map_ = this->create_subscription<HADMapBin>(
"/vector_map", rclcpp::QoS{1}.transient_local(),
std::bind(&MapBasedPredictionNode::mapCallback, this, std::placeholders::_1));
pub_objects_ = this->create_publisher<PredictedObjects>("~/output/objects", rclcpp::QoS{1});
processing_time_publisher_ =
std::make_unique<tier4_autoware_utils::DebugPublisher>(this, "map_based_prediction");
(2)predictObjectManeuver
Maneuver MapBasedPredictionNode::predictObjectManeuver(
const TrackedObject & object, const LaneletData & current_lanelet_data,
const double object_detected_time)
- 输入:当前时间、检测到的物体、地图、车辆姿态。
- 输出:预测的物体轨迹(
PredictedObjects
消息)
(3) getPredictedReferencePath
std::vector<PredictedRefPath> MapBasedPredictionNode::getPredictedReferencePath(
const TrackedObject & object, const LaneletsData & current_lanelets_data,
const double object_detected_time, const double time_horizon)
- 根据物体位置和地图生成可能的行驶路径。
(4) objectsCallback
void MapBasedPredictionNode::objectsCallback(const TrackedObjects::ConstSharedPtr in_objects)
生成预测轨迹 。
(5)perception_online_evaluator功能包
实现对生成预测障碍物运动轨迹的评估
(6)其他
目前只看了一些我需要的,其它的目前还未看 这个perception模块里面的东西有点重要是要为了给控制规划提供信息的。
形状估计是给据基于雷达的点云数据,结合不同的算法进而给出障碍物的形状的大概样子。
四、总结
其主要的执行流程就是严格按「预处理→分割→识别→跟踪」顺序处理。其 中个中数据和过程的处理该模块下面的处理都有 ,地图和传感器处理清参考前面的文章。