提交 65c02ac7 编写于 作者: J jmtao 提交者: PAN Jiacheng

planning: move path_decider status into PlanningStatus

上级 b6200138
......@@ -150,13 +150,8 @@ cc_library(
"-DMODULE_NAME=\\\"planning\\\"",
],
deps = [
":planning_gflags",
"//cyber/common:log",
"//modules/map/pnc_map:path",
"//cyber/common",
"//modules/planning/common/path:path_data",
"//modules/planning/proto:path_decider_info_proto",
"//modules/planning/proto:planning_config_proto",
"//modules/planning/proto:planning_proto",
"//modules/planning/proto:planning_status_proto",
"@eigen",
],
......
......@@ -22,7 +22,6 @@
#include "cyber/common/macros.h"
#include "modules/planning/proto/path_decider_info.pb.h"
#include "modules/planning/proto/planning_status.pb.h"
/**
......@@ -37,14 +36,15 @@ class PlanningContext {
void Clear();
void Init();
/*
* please put all status info inside PlanningStatus for easy maintenance.
* do NOT create new struct at this level.
* */
const PlanningStatus& planning_status() { return planning_status_; }
PlanningStatus* mutable_planning_status() { return &planning_status_; }
const PathDeciderInfo& path_decider_info() { return path_decider_info_; }
PathDeciderInfo* mutable_path_decider_info() { return &path_decider_info_; }
private:
PlanningStatus planning_status_;
PathDeciderInfo path_decider_info_;
// this is a singleton class
DECLARE_SINGLETON(PlanningContext)
......
......@@ -558,20 +558,6 @@ cc_proto_library(
],
)
cc_proto_library(
name = "path_decider_info_proto",
deps = [
":path_decider_info_proto_lib",
],
)
proto_library(
name = "path_decider_info_proto_lib",
srcs = [
"path_decider_info.proto",
],
)
cc_proto_library(
name = "rule_based_stop_decider_config_proto",
deps = [
......
syntax = "proto2";
package apollo.planning;
message PathDeciderInfo {
optional int32 front_static_obstacle_cycle_counter = 1 [default = 0];
optional int32 able_to_use_self_lane_counter = 2 [default = 0];
optional bool is_in_path_lane_borrow_scenario = 3 [default = false];
optional string front_static_obstacle_id = 4 [default = ""];
optional int32 decided_side_pass_direction = 5 [default = 0];
}
......@@ -53,6 +53,14 @@ message OpenSpaceStatus {
repeated string partitioned_trajectories_index_history = 1;
}
message PathDeciderStatus {
optional int32 front_static_obstacle_cycle_counter = 1 [default = 0];
optional int32 able_to_use_self_lane_counter = 2 [default = 0];
optional bool is_in_path_lane_borrow_scenario = 3 [default = false];
optional string front_static_obstacle_id = 4 [default = ""];
optional int32 decided_side_pass_direction = 5 [default = 0];
}
message PedestrianStatus {
repeated StopTime stop_time = 1;
}
......@@ -109,11 +117,12 @@ message PlanningStatus {
optional apollo.common.EngageAdvice engage_advice = 5;
optional OpenSpaceStatus open_space = 6;
optional PedestrianStatus pedestrian = 7;
optional PullOverStatus pull_over = 8;
optional ReroutingStatus rerouting = 9;
optional RightOfWayStatus right_of_way = 10;
optional ScenarioStatus scenario = 11;
optional SidePassStatus side_pass = 12;
optional StopSignStatus stop_sign = 13;
optional TrafficLightStatus traffic_light = 14;
optional PathDeciderStatus path_decider = 8;
optional PullOverStatus pull_over = 9;
optional ReroutingStatus rerouting = 10;
optional RightOfWayStatus right_of_way = 11;
optional ScenarioStatus scenario = 12;
optional SidePassStatus side_pass = 13;
optional StopSignStatus stop_sign = 14;
optional TrafficLightStatus traffic_light = 15;
}
......@@ -231,78 +231,55 @@ Status PathAssessmentDecider::Process(
new_candidate_path_data.push_back(curr_path_data);
}
}
reference_line_info->SetCandidatePathData(std::move(new_candidate_path_data));
reference_line_info->SetCandidatePathData(
std::move(new_candidate_path_data));
// 4. Update necessary info for lane-borrow decider's future uses.
// Update front static obstacle's info.
auto *mutable_path_decider_status = PlanningContext::Instance()
->mutable_planning_status()
->mutable_path_decider();
if (!(reference_line_info->GetBlockingObstacleId()).empty()) {
if (PlanningContext::Instance()
->path_decider_info()
.front_static_obstacle_cycle_counter() < 0) {
PlanningContext::Instance()
->mutable_path_decider_info()
->set_front_static_obstacle_cycle_counter(0);
int front_static_obstacle_cycle_counter =
mutable_path_decider_status->front_static_obstacle_cycle_counter();
if (front_static_obstacle_cycle_counter < 0) {
front_static_obstacle_cycle_counter = 0;
}
PlanningContext::Instance()
->mutable_path_decider_info()
->set_front_static_obstacle_id(
mutable_path_decider_status->set_front_static_obstacle_id(
reference_line_info->GetBlockingObstacleId());
PlanningContext::Instance()
->mutable_path_decider_info()
->set_front_static_obstacle_cycle_counter(
std::min(PlanningContext::Instance()
->path_decider_info()
.front_static_obstacle_cycle_counter() +
1,
10));
mutable_path_decider_status->set_front_static_obstacle_cycle_counter(
std::min(front_static_obstacle_cycle_counter + 1, 10));
} else {
PlanningContext::Instance()
->mutable_path_decider_info()
->set_front_static_obstacle_cycle_counter(0);
mutable_path_decider_status->set_front_static_obstacle_cycle_counter(0);
}
// Update self-lane usage info.
if (reference_line_info->path_data().path_label().find("self") !=
std::string::npos) {
// && std::get<1>(reference_line_info->path_data()
// .path_point_decision_guide()
// .front()) == PathData::PathPointType::IN_LANE) {
if (PlanningContext::Instance()
->path_decider_info()
.able_to_use_self_lane_counter() < 0) {
PlanningContext::Instance()
->mutable_path_decider_info()
->set_able_to_use_self_lane_counter(0);
int able_to_use_self_lane_counter =
mutable_path_decider_status->able_to_use_self_lane_counter();
if (able_to_use_self_lane_counter < 0) {
able_to_use_self_lane_counter = 0;
}
PlanningContext::Instance()
->mutable_path_decider_info()
->set_able_to_use_self_lane_counter(
std::min(PlanningContext::Instance()
->path_decider_info()
.able_to_use_self_lane_counter() +
1,
10));
mutable_path_decider_status->set_able_to_use_self_lane_counter(
std::min(able_to_use_self_lane_counter + 1, 10));
} else {
PlanningContext::Instance()
->mutable_path_decider_info()
->set_able_to_use_self_lane_counter(0);
mutable_path_decider_status->set_able_to_use_self_lane_counter(0);
}
// Update side-pass direction.
if (PlanningContext::Instance()
->path_decider_info()
.is_in_path_lane_borrow_scenario() &&
PlanningContext::Instance()
->path_decider_info()
.decided_side_pass_direction() == 0) {
if (mutable_path_decider_status->is_in_path_lane_borrow_scenario() &&
mutable_path_decider_status->decided_side_pass_direction() == 0) {
if (reference_line_info->path_data().path_label().find("left") !=
std::string::npos) {
PlanningContext::Instance()
->mutable_path_decider_info()
->set_decided_side_pass_direction(1);
mutable_path_decider_status->set_decided_side_pass_direction(1);
} else if (reference_line_info->path_data().path_label().find("right") !=
std::string::npos) {
PlanningContext::Instance()
->mutable_path_decider_info()
->set_decided_side_pass_direction(-1);
mutable_path_decider_status->set_decided_side_pass_direction(-1);
}
}
const auto& end_time4 = std::chrono::system_clock::now();
......
......@@ -138,9 +138,12 @@ Status PathBoundsDecider::Process(
std::vector<LaneBorrowInfo> lane_borrow_info_list;
if (reference_line_info->is_path_lane_borrow()) {
// Try borrowing from left and from right neighbor lane.
switch (PlanningContext::Instance()
->path_decider_info()
.decided_side_pass_direction()) {
const int decided_side_pass_direction =
PlanningContext::Instance()
->planning_status()
.path_decider()
.decided_side_pass_direction();
switch (decided_side_pass_direction) {
case 0:
lane_borrow_info_list = {LaneBorrowInfo::LEFT_BORROW,
LaneBorrowInfo::RIGHT_BORROW,
......
......@@ -114,7 +114,8 @@ bool PathDecider::MakeStaticObstacleDecision(
// - add STOP decision for blocking obstacles.
if (obstacle->Id() == blocking_obstacle_id &&
!PlanningContext::Instance()
->path_decider_info()
->planning_status()
.path_decider()
.is_in_path_lane_borrow_scenario()) {
// Add stop decision
ADEBUG << "Blocking obstacle = " << blocking_obstacle_id;
......
......@@ -52,44 +52,33 @@ Status PathLaneBorrowDecider::Process(
bool PathLaneBorrowDecider::IsNecessaryToBorrowLane(
const Frame& frame, const ReferenceLineInfo& reference_line_info) {
if (PlanningContext::Instance()
->path_decider_info()
.is_in_path_lane_borrow_scenario()) {
auto *mutable_path_decider_status = PlanningContext::Instance()
->mutable_planning_status()
->mutable_path_decider();
if (mutable_path_decider_status->is_in_path_lane_borrow_scenario()) {
// If originally borrowing neighbor lane:
if (PlanningContext::Instance()
->path_decider_info()
.able_to_use_self_lane_counter() >= 6) {
if (mutable_path_decider_status->able_to_use_self_lane_counter() >= 6) {
// If have been able to use self-lane for some time, then switch to
// non-lane-borrowing.
PlanningContext::Instance()
->mutable_path_decider_info()
->set_is_in_path_lane_borrow_scenario(false);
PlanningContext::Instance()
->mutable_path_decider_info()
->set_decided_side_pass_direction(0);
mutable_path_decider_status->set_is_in_path_lane_borrow_scenario(false);
mutable_path_decider_status->set_decided_side_pass_direction(0);
AINFO << "Switch from LANE-BORROW path to SELF-LANE path.";
}
} else {
// If originally not borrowing neighbor lane:
ADEBUG << "Blocking obstacle ID = "
<< PlanningContext::Instance()
->path_decider_info()
.front_static_obstacle_id();
ADEBUG << "Blocking obstacle ID["
<< mutable_path_decider_status->front_static_obstacle_id() << "]";
if (HasSingleReferenceLine(frame) && IsWithinSidePassingSpeedADC(frame) &&
IsBlockingObstacleFarFromIntersection(reference_line_info) &&
IsLongTermBlockingObstacle() &&
IsBlockingObstacleWithinDestination(reference_line_info) &&
IsSidePassableObstacle(reference_line_info)) {
// Satisfying the above condition will it switch to lane-borrowing.
PlanningContext::Instance()
->mutable_path_decider_info()
->set_is_in_path_lane_borrow_scenario(true);
mutable_path_decider_status->set_is_in_path_lane_borrow_scenario(true);
AINFO << "Switch from SELF-LANE path to LANE-BORROW path.";
}
}
return PlanningContext::Instance()
->path_decider_info()
.is_in_path_lane_borrow_scenario();
return mutable_path_decider_status->is_in_path_lane_borrow_scenario();
}
// This function is to prevent lane-borrowing during lane-changing.
......@@ -105,7 +94,8 @@ bool PathLaneBorrowDecider::IsWithinSidePassingSpeedADC(const Frame& frame) {
bool PathLaneBorrowDecider::IsLongTermBlockingObstacle() {
if (PlanningContext::Instance()
->path_decider_info()
->planning_status()
.path_decider()
.front_static_obstacle_cycle_counter() >=
FLAGS_long_term_blocking_obstacle_cycle_threhold) {
ADEBUG << "The blocking obstacle is long-term existing.";
......@@ -118,9 +108,10 @@ bool PathLaneBorrowDecider::IsLongTermBlockingObstacle() {
bool PathLaneBorrowDecider::IsBlockingObstacleWithinDestination(
const ReferenceLineInfo& reference_line_info) {
std::string blocking_obstacle_id = PlanningContext::Instance()
->path_decider_info()
.front_static_obstacle_id();
const auto &path_decider_status =
PlanningContext::Instance()->planning_status().path_decider();
const std::string blocking_obstacle_id =
path_decider_status.front_static_obstacle_id();
if (blocking_obstacle_id.empty()) {
ADEBUG << "There is no blocking obstacle.";
return true;
......@@ -149,9 +140,10 @@ bool PathLaneBorrowDecider::IsBlockingObstacleWithinDestination(
bool PathLaneBorrowDecider::IsBlockingObstacleFarFromIntersection(
const ReferenceLineInfo& reference_line_info) {
std::string blocking_obstacle_id = PlanningContext::Instance()
->path_decider_info()
.front_static_obstacle_id();
const auto &path_decider_status =
PlanningContext::Instance()->planning_status().path_decider();
const std::string blocking_obstacle_id =
path_decider_status.front_static_obstacle_id();
if (blocking_obstacle_id.empty()) {
ADEBUG << "There is no blocking obstacle.";
return true;
......@@ -203,9 +195,10 @@ bool PathLaneBorrowDecider::IsBlockingObstacleFarFromIntersection(
bool PathLaneBorrowDecider::IsSidePassableObstacle(
const ReferenceLineInfo& reference_line_info) {
std::string blocking_obstacle_id = PlanningContext::Instance()
->path_decider_info()
.front_static_obstacle_id();
const auto &path_decider_status =
PlanningContext::Instance()->planning_status().path_decider();
const std::string blocking_obstacle_id =
path_decider_status.front_static_obstacle_id();
if (blocking_obstacle_id.empty()) {
ADEBUG << "There is no blocking obstacle.";
return false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册