百度ApolloPlanning模块理解,以自动泊车为例
版本:apollo5.0以上
1、模块理解
首先需要理解Planning模块是基于Scenario、Stage、Task这样的层次来进行的,即:场景->步骤->具体的决策方法。Apollo可以应对自动驾驶所面临的不同道路场景,都是通过Scenario统一注册与管理。Scenario通过一个有限状态机来判断选择当前行车场景,每个Scenario下又有多个Stage,指当前场景下需要执行的粗略步骤,例如泊车分为两个Stage:泊车前的制动停车、车辆停止之后开始泊车。Task会列出该Stage的具体方法。
2、代码示例
现在看代码,首先是场景的判断
apollo-master\modules\planning\scenarios\scenario_manager.cc
首先调用ValetParkingScenario::IsTransferable函数对场景进行条件判断,如果条件满足才会调用VALET_PARKING 的Scenario泊车场景。
ScenarioConfig::ScenarioType ScenarioManager::SelectValetParkingScenario(const Frame& frame) {const auto& scenario_config =config_map_[ScenarioConfig::VALET_PARKING].valet_parking_config();// TODO(All) trigger valet parking by route message definition as of nowdouble parking_spot_range_to_start =scenario_config.parking_spot_range_to_start();if (scenario::valet_parking::ValetParkingScenario::IsTransferable(frame, parking_spot_range_to_start)) {return ScenarioConfig::VALET_PARKING;}return default_scenario_type_;
}
ValetParkingScenario::IsTransferable函数位于
apollo-master\modules\planning\scenarios\park\valet_parking\valet_parking_scenario.cc
这里面通过高精地图的路由信息判断是否有停车场、停车位ID。
bool ValetParkingScenario::IsTransferable(const Frame& frame,const double parking_start_range) {// TODO(all) Implement available parking spot detection by preception resultsstd::string target_parking_spot_id;if (frame.local_view().routing->routing_request().has_parking_info() &&frame.local_view().routing->routing_request().parking_info().has_parking_space_id()) {target_parking_spot_id = frame.local_view().routing->routing_request().parking_info().parking_space_id();} else {ADEBUG << "No parking space id from routing";return false;}if (target_parking_spot_id.empty()) {return false;}const auto& nearby_path =frame.reference_line_info().front().reference_line().map_path();PathOverlap parking_space_overlap;const auto& vehicle_state = frame.vehicle_state();if (!SearchTargetParkingSpotOnPath(nearby_path, target_parking_spot_id,&parking_space_overlap)) {ADEBUG << "No such parking spot found after searching all path forward ""possible"<< target_parking_spot_id;return false;}if (!CheckDistanceToParkingSpot(frame, vehicle_state, nearby_path,parking_start_range, parking_space_overlap)) {ADEBUG << "target parking spot found, but too far, distance larger than ""pre-defined distance"<< target_parking_spot_id;return false;}return true;
}
当以上条件通过,程序会进入VALET_PARKING 的Scenario泊车场景,在该场景下包含两个Stage:VALET_PARKING_APPROACHING_PARKING_SPOT和VALET_PARKING_PARKING,可在下面路径文件中查看。
apollo-master\modules\planning\conf\scenario\valet_parking_config.pb.txt
为了方便讲解,我给代码加上序号:
1-2 是场景下的两个stage,即前文所述泊车前的制动停车、车辆停止之后开始泊车。
4-19为第一个stage:VALET_PARKING_APPROACHING_PARKING_SPOT调用的task,可以看到第一个task为车辆预停操作,该task会在车辆到达停车位前生成一个空气墙,让车辆停止。这里篇幅有限不列出第二个stage。
20-25为第一个task的相关参数,task我目前没有深入研究,希望大家指点一下。
1 stage_type: VALET_PARKING_APPROACHING_PARKING_SPOT
2 stage_type: VALET_PARKING_PARKING
3
4 stage_config: {
5 stage_type: VALET_PARKING_APPROACHING_PARKING_SPOT
6 enabled: true
7 task_type: OPEN_SPACE_PRE_STOP_DECIDER
8 task_type: PATH_LANE_BORROW_DECIDER
9 task_type: PATH_BOUNDS_DECIDER
10 task_type: PIECEWISE_JERK_PATH_OPTIMIZER
11 task_type: PATH_ASSESSMENT_DECIDER
12 task_type: PATH_DECIDER
13 task_type: RULE_BASED_STOP_DECIDER
14 task_type: ST_BOUNDS_DECIDER
15 task_type: SPEED_BOUNDS_PRIORI_DECIDER
16 task_type: SPEED_HEURISTIC_OPTIMIZER
17 task_type: SPEED_DECIDER
18 task_type: SPEED_BOUNDS_FINAL_DECIDER
19 task_type: PIECEWISE_JERK_SPEED_OPTIMIZER
20 task_config: {
21 task_type: OPEN_SPACE_PRE_STOP_DECIDER
22 open_space_pre_stop_decider_config {
23 stop_type: PARKING
24 }
25 }
26 }
在该路径下也包含了很多其他场景的配置文件,具体可以自行去查看。
相关文章
Planning的结构与调用:
https://zhuanlan.zhihu.com/p/100488133
规划算法Hybrid A*:
https://blog.csdn.net/linxigjs/article/details/103419697
场景选择:
https://mp.weixin.qq.com/s/yv-tbk45HkcGDkoSfMridg
相关Issues:
https://github.com/ApolloAuto/apollo/issues/13215
https://github.com/ApolloAuto/apollo/issues/13105
https://github.com/ApolloAuto/apollo/issues/13571
https://github.com/ApolloAuto/apollo/issues/13950
以上。
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
