Apollo源码分析:路径规划(v5.5)

更新时间:2023-07-09 11:01:32 阅读: 评论:0

Apollo源码分析:路径规划(v5.5)
本⽂主要讲解Apollo/modules/planning中的路径规划的架构和算法。
第⼀章架构设计与实现
⼀、架构设计与实现
Apollo FSM(finite state machine):⼀个有限状态机,与⾼清地图确定车辆状态给定其位置和路线。
----------------------------------------------------------------------------------------------------------------------------------------
Planning模块整体框架:
1. 可执⾏程序层: Planning Dispatcher根据车辆的状态和其他相关信息,调⽤合适的Planner。Planner实现获取所需的上下⽂数据和其他信息,确定相应的车辆意图,执⾏该意图所需的规划任务并⽣成规划轨迹。它还将更新未来作业的上下⽂。根据⼯作模式不同将规划任务分成不同的Planner模式(LatticePlanner\NaviPlanner\PublicRoadPlanner\RTKReplayPlanner)。
2.app层:每种Planner分成多个场景Scenario(BareInterctionUnprotectedScenario、EmergencyPullOverScenario、EmergencyStopScenario、LaneFollowScenario、TestLearningModelScenario、NarrowStreetUTurnScenario、PullOverScenario、ValetParkingScenario、ParkAndGoScenario、StopSignUnprotectedScenario、TrafficLightProtectedScenario、TrafficLightUnprotectedLeftTurnScenario、TrafficLightUnprotectedRightTurnScenario、YieldSignScenario)-》每个场景⼜分解成多个Stage(例如ValetParkingScenario包含StageApproachingParkingSpot和StageParking两个Stage)
3.lib层:每个Stage⼜分解成可执⾏的Task(包括不同的Deciders & Optimizers库),Task是Deciders & Optimizers :⼀组实现决策任务和各种优化的⽆状态库。优化器特别优化车辆的轨迹和速度。决策者是基于规则的分类决策者,他们建议何时换车道、何时停车、何时爬⾏(慢速⾏进)或爬⾏何时完成。
-------------------------------------------------------------------------------------------------------------------------------------------
Planning Context: 作业的上下⽂。
这种 可执⾏程序层-》app层 -》lib层 的三层分级架构实质与视觉感知模块类似。
视觉感知模块中更像是⾃下⽽上地设计出这种三层结构的,因此,我们也⾃下⽽上地讲解了这个结构;
路径规划模块更像是⾃上⽽下设计出这种架构的,因此,我们也⾃上⽽下地讲解这个结构。
视觉感知模块命名更直⽩。
路径规划模块把接⼝分散放⼊各个层的模块中了,没有集中放在⼀个⽂件夹。
1. 可执⾏程序层--planning/planner
定义抽象基类PlannerDispatcher,包含了Planner类型的数据成员;
class PlannerDispatcher {
public:
virtual std::unique_ptr<Planner> DispatchPlanner() = 0;
protected:
common::util::Factory<PlannerType, Planner> planner_factory_;
};
NaviPlannerDispatcher和OnLanePlannerDispatcher继承⾃PlannerDispatcher,覆盖了抽象基类中的virtual std::unique_ptr<Planner> DispatchPlanner()⽅法,实现通过⼯⼚模式创建配置⽂件中指定的Planner对象。
以 NaviPlannerDispatcher为例:
std::unique_ptr<Planner> NaviPlannerDispatcher::DispatchPlanner() {
PlanningConfig planning_config;
if (!apollo::cyber::common::GetProtoFromFile(FLAGS_planning_config_file,字母大小写转换
&planning_config)) {
return nullptr;
}
auto planner_type = PlannerType::NAVI;
if (planning_config.has_navigation_planning_config()) {
planner_type = planning_config.navigation_planning_config().planner_type(0);
}
return planner_factory_.CreateObject(planner_type);
}
Planner为定义的基类接⼝,Planner中包含了scenario。
class Planner {
protected:
scenario::ScenarioManager scenario_manager_;
scenario::Scenario* scenario_ = nullptr;
};
PlannerWithReferenceLine继承⾃ Planner,做了⼀层抽象:
class PlannerWithReferenceLine : public Planner {};
根据不同的⼯作模式定义了4种Planner:
class LatticePlanner : public PlannerWithReferenceLine {};
/**
* @class NaviPlannerskinner
* @brief NaviPlanner is a planner bad on real-time relative maps. It us the
* vehicle's FLU (Front-Left-Up) coordinate system to accomplish tasks such as
* cruising, following, overtaking, nudging, changing lanes and stopping.
* Note that NaviPlanner is only ud in navigation mode (turn on navigation
* mode by tting "FLAGS_u_navigation_mode" to "true") and do not u it in
* standard mode.
*/
class NaviPlanner : public PlannerWithReferenceLine {};
/**
* @class PublicRoadPlanner
solid* @brief PublicRoadPlanner is an expectation maximization planner.
*/
class PublicRoadPlanner : public PlannerWithReferenceLine{};
/**
* @class RTKReplayPlanner
* @brief RTKReplayPlanner is a derived class of Planner.
*        It reads a recorded trajectory from a trajectory file and
*        outputs proper gment of the trajectory according to vehicle
* position.
*/
class RTKReplayPlanner : public PlannerWithReferenceLine{};
2. app层--planning/scenarios
前⾯讲到Planner中包含scenario::ScenarioManager scenario_manager_和scenario::Scenario* scenario_ = nullptr数据成员,
class Scenario {
public:
/**
* Each scenario should define its own stages object's creation
* scenario will call stage's Stage::Process function following a configured
* order, The return value of Stage::Process function determines the
* transition from one stage to another.
*/
virtual std::unique_ptr<Stage> CreateStage(
happiness是什么意思const ScenarioConfig::StageConfig& stage_config) = 0;
// Each scenario should define its own transfer condition, i.e., when it
// should allow to transfer from other scenario to itlf.
virtual bool IsTransferable(const Scenario& other_scenario,
const Frame& frame) {
return true;
}
protected:
std::unique_ptr<Stage> current_stage_;
};
基于scenario派⽣出BareInterctionUnprotectedScenario、EmergencyPullOverScenario、Emergen
cyStopScenario、LaneFollowScenario、TestLearningModelScenario、NarrowStreetUTurnScenario、PullOverScenario、ValetParkingScenario、ParkAndGoScenario、StopSignUnprotectedScenario、TrafficLightProtectedScenario、TrafficLightUnprotectedLeftTurnScenario、TrafficLightUnprotectedRightTurnScenario、YieldSignScenario;
Scenario类型中⼜包含Stage类型的数据成员。⼀个Scenario分解成多个Stage,不同Stage可能是基于不同规划算法实现的。例如:泊车场景中(Apollo/modules/planning/scenarios/park/valet_parking),划分成了StageApproachingParkingSpot和StageParking 两个Stage。
Stage中包含Task类型的数据成员,依次执⾏Tasklilst上的Task,相当于将多个lib串联起来实现⼀定功能的app:
class Stage {
public:
/**
* @brief Each stage does its business logic inside Process function.
* If the stage want to transit to a different stage after finish,
* it should t the type of 'next_stage_'.
*/教育学考研培训
virtual StageStatus Process(
const common::TrajectoryPoint& planning_init_point, Frame* frame) = 0;
/**
* @brief The quence of tasks inside the stage. The tasks usually will be
* executed in order.
*/
const std::vector<Task*>& TaskList() const { return task_list_; }
protected:
std::map<TaskConfig::TaskType, std::unique_ptr<Task>> tasks_;
std::vector<Task*> task_list_;
一般过去时的构成};
3. lib层--planning/tasks
决策任务deciders和各种优化optimizers的⽆状态库,都是基于Task基类派⽣。
决策者是基于规则的分类决策者,他们建议何时换车道、何时停车、何时爬⾏(慢速⾏进)或爬⾏何时完成。
class Decider : public Task {};
Decider⼜派⽣出:CreepDecider、LaneChangeDecider、OpenSpaceFallbackDecider、OpenSpacePreStopDecider、OpenSpaceRoiDecider、PathAsssmentDecider、PathBoundsDecider、PathDecider、PathLaneBorrowDecider、PathReuDecider、RssDecider、
RuleBadStopDecider、SpeedBoundsDecider、SpeedLimitDecider、SpeedDecider、STBoundsDecider
优化器特别优化车辆的轨迹和速度。
class PathOptimizer : public Task {};
class SpeedOptimizer : public Task {};
class TrajectoryOptimizer : public Task{};
具体包括:
class OpenSpaceTrajectoryProvider : public TrajectoryOptimizer{};
mobile是什么意思class OpenSpaceTrajectoryPartition : public TrajectoryOptimizer{};
class PathTimeHeuristicOptimizer : public SpeedOptimizer {};
class PiecewiJerkPathOptimizer : public PathOptimizer{};
class PiecewiJerkSpeedNonlinearOptimizer : public SpeedOptimizer{};
class PiecewiJerkSpeedOptimizer : public SpeedOptimizer{};
第⼆章设计模式
⼀、简单⼯⼚模式
Apollo/modules/planning/scenarios/scenario_manager
std::unique_ptr<Scenario> ScenarioManager::CreateScenario(
ScenarioConfig::ScenarioType scenario_type) {
std::unique_ptr<Scenario> ptr;js培训
switch (scenario_type) {
ca ScenarioConfig::BARE_INTERSECTION_UNPROTECTED:
<(
new scenario::bare_interction::BareInterctionUnprotectedScenario(              config_map_[scenario_type], &scenario_context_));
break;
ca ScenarioConfig::EMERGENCY_PULL_OVER:
<(new emergency_pull_over::EmergencyPullOverScenario(
config_map_[scenario_type], &scenario_context_));
break;
ca ScenarioConfig::EMERGENCY_STOP:
<(new emergency_stop::EmergencyStopScenario(
config_map_[scenario_type], &scenario_context_));
break;
ca ScenarioConfig::LANE_FOLLOW:
<(new lane_follow::LaneFollowScenario(config_map_[scenario_type],                                                    &scenario_context_));
break;
ca ScenarioConfig::PARK_AND_GO:
<(new scenario::park_and_go::ParkAndGoScenario(
config_map_[scenario_type], &scenario_context_));
break;
ca ScenarioConfig::PULL_OVER:
<(new scenario::pull_over::PullOverScenario(
config_map_[scenario_type], &scenario_context_));
break;
ca ScenarioConfig::STOP_SIGN_UNPROTECTED:
<(new scenario::stop_sign::StopSignUnprotectedScenario(
config_map_[scenario_type], &scenario_context_));
break;
ca ScenarioConfig::TEST_LEARNING_MODEL:
<(new scenario::TestLearningModelScenario(
config_map_[scenario_type], &scenario_context_));
break;
ca ScenarioConfig::TRAFFIC_LIGHT_PROTECTED:
<(new scenario::traffic_light::TrafficLightProtectedScenario(
config_map_[scenario_type], &scenario_context_));
break;
ca ScenarioConfig::TRAFFIC_LIGHT_UNPROTECTED_LEFT_TURN:
<(
new scenario::traffic_light::TrafficLightUnprotectedLeftTurnScenario(
config_map_[scenario_type], &scenario_context_));
break;
ca ScenarioConfig::TRAFFIC_LIGHT_UNPROTECTED_RIGHT_TURN:
<(
new scenario::traffic_light::TrafficLightUnprotectedRightTurnScenario(
ait
config_map_[scenario_type], &scenario_context_));
break;
ca ScenarioConfig::VALET_PARKING:
<(new scenario::valet_parking::ValetParkingScenario(
config_map_[scenario_type], &scenario_context_));
break;
俄语网站建设
ca ScenarioConfig::YIELD_SIGN:
<(new scenario::yield_sign::YieldSignScenario(
config_map_[scenario_type], &scenario_context_));

本文发布于:2023-07-09 11:01:32,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/90/171893.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:规划   模块   实现
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图