1、ReferenceLineProvider介绍
参考: docs/08_Planning/
Apollo星火计划学习笔记——参考线平滑算法解析及实现(以U型弯道场景仿真调试为例)_apollo弯道参数配置-CSDN博客
参考线是planning规划算法的基础,ReferenceLineProvider根据车辆的实时位置,计算车辆前后一定范围内(几百米)的参考线信息,相对于全局路由线路来说,参考线是局部路线信息,但参考线中还附加了车辆周围的动态信息,如障碍物,交通灯等。
参考线相关重要的两个数据:
- ReferenceLine: 据全局路由线路生成的原始路径信息,包含地图上道路之间的静态关系,并且经过平滑之后的结果。
- ReferenceLineInfo:
ReferenceLine
的基础上添加了动态信息,如决策信息,ST图等,planning的规划操作基本都在这个数据结 构上进行。可以建立理解为ReferenceLine提供的是轨迹信息,而ReferenceLineInfo在ReferenceLine的基础上新添加了决策信息。
参考线生成的流程如下图所示:
其中 CreateRouteSegments
函数是将车辆附近范围内的全局路由线路转换成参考线的格式;SmoothRouteSegment函数是将原始的参考线进行平滑。
参考线一共有三种平滑方式,离散点的平滑(默认)、螺旋线的平滑以及样条曲线的平滑。
导航规划的路线一般由三个部分组成:Routing、参考线以及轨迹。
Routing: 全局路径规划的结果,一般规划出来的长度为几十公里甚至上百公里,若没有障碍物,车辆将会沿着这条路径一直行驶。若有障碍物,则会由Planning模块发布回Routing模块进行重新规划。
参考线: 决策规划模块根据车辆的实时位置进行计算。参考线的计算依赖于Routing的结果,但同时需要车辆周围的动态信息(障碍物、交通规则)。参考线相当于Routing结果里局部数据(车辆当前位置的一段Routing),距离通常只有几百米。参考线可能会有多条。
轨迹: 是规划决策模块的最终输出结果。轨迹的输入是参考线。轨迹不仅包含车辆的路径信息,也包括车辆的动态信息(速度、加速度等)。
2、ReferenceLineProvider 初始化
OnLanePlanning::Init(const PlanningConfig& config) 函数中
// instantiate reference line provider
const ReferenceLineConfig* reference_line_config = nullptr;
if (config_.has_reference_line_config()) {
reference_line_config = &config_.reference_line_config();
}
reference_line_provider_ = std::make_unique<ReferenceLineProvider>(
injector_->vehicle_state(), reference_line_config);
reference_line_provider_->Start();
初始化ReferenceLineProvider类并实例对象 ,然后通过Start()实现参考线生成线程,线程周期50mm
同时设定平滑算法用哪个 默认是离散点的平滑(默认) 路径modules/planning/planning_component/conf/planning.conf下
--smoother_config_filename=/apollo/modules/planning/planning_component/conf/discrete_points_smoother_config.pb.txt
另外两种:(暂时未用)
# --smoother_config_filename=/apollo/modules/planning/planning_component/conf/spiral_smoother_config.pb.txt
# --smoother_config_filename=/apollo/modules/planning/planning_component/conf/qp_spline_smoother_config.pb.txt
if (smoother_config_.has_qp_spline()) {
smoother_.reset(new QpSplineReferenceLineSmoother(smoother_config_));
} else if (smoother_config_.has_spiral()) {
smoother_.reset(new SpiralReferenceLineSmoother(smoother_config_));
} else if (smoother_config_.has_discrete_points()) {
smoother_.reset(new DiscretePointsReferenceLineSmoother(smoother_config_));
} else {
ACHECK(false) << "unknown smoother config "
<< smoother_config_.DebugString();
}