提交 e5ad41b8 编写于 作者: J jmtao 提交者: Xiangquan Xiao

planning: remove static member variable in BareIntersection stage for multil-ADC RL

上级 e950825d
......@@ -15,6 +15,7 @@ import "modules/routing/proto/routing.proto";
message BareIntersectionStatus {
optional string current_pnc_junction_overlap_id = 1;
optional string done_pnc_junction_overlap_id = 2;
optional uint32 clear_counter = 3;
}
message ChangeLaneStatus {
......
......@@ -37,8 +37,6 @@ namespace bare_intersection {
using apollo::common::TrajectoryPoint;
using apollo::hdmap::PathOverlap;
uint32_t BareIntersectionUnprotectedStageApproach::clear_counter_ = 0;
Stage::StageStatus BareIntersectionUnprotectedStageApproach::Process(
const TrajectoryPoint& planning_init_point, Frame* frame) {
ADEBUG << "stage: Approach";
......@@ -93,12 +91,60 @@ Stage::StageStatus BareIntersectionUnprotectedStageApproach::Process(
AERROR << "BareIntersectionUnprotectedStageApproach planning error";
}
std::vector<std::string> wait_for_obstacle_ids;
bool clear = CheckClear(reference_line_info, &wait_for_obstacle_ids);
if (scenario_config_.enable_explicit_stop()) {
bool stop = false;
static constexpr double kCheckClearDistance = 5.0; // meter
static constexpr double kStartWatchDistance = 2.0; // meter
if (distance_adc_to_pnc_junction <= kCheckClearDistance &&
distance_adc_to_pnc_junction >= kStartWatchDistance && !clear) {
stop = true;
} else if (distance_adc_to_pnc_junction < kStartWatchDistance) {
// creeping area
auto* bare_intersection_status = injector_->planning_context()
->mutable_planning_status()
->mutable_bare_intersection();
int clear_counter = bare_intersection_status->clear_counter();
clear_counter = clear ? clear_counter + 1 : 0;
if (clear_counter >= 5) {
clear_counter = 0; // reset
} else {
stop = true;
}
// use PlanningContext instead of static counter for multi-ADC
bare_intersection_status->set_clear_counter(clear_counter);
}
if (stop) {
// build stop decision
ADEBUG << "BuildStopDecision: bare pnc_junction["
<< pnc_junction_overlap_id << "] start_s["
<< current_pnc_junction->start_s << "]";
const std::string virtual_obstacle_id =
"PNC_JUNCTION_" + current_pnc_junction->object_id;
planning::util::BuildStopDecision(
virtual_obstacle_id, current_pnc_junction->start_s,
scenario_config_.stop_distance(),
StopReasonCode::STOP_REASON_STOP_SIGN, wait_for_obstacle_ids,
"bare intersection", frame,
&(frame->mutable_reference_line_info()->front()));
}
}
return Stage::RUNNING;
}
bool BareIntersectionUnprotectedStageApproach::CheckClear(
const ReferenceLineInfo& reference_line_info,
std::vector<std::string>* wait_for_obstacle_ids) {
// TODO(all): move to conf
static constexpr double kConf_min_boundary_t = 6.0; // second
static constexpr double kConf_ignore_max_st_min_t = 0.1; // second
static constexpr double kConf_ignore_min_st_min_s = 15.0; // meter
std::vector<std::string> wait_for_obstacle_ids;
bool all_far_away = true;
for (auto* obstacle :
reference_line_info.path_decision().obstacles().Items()) {
......@@ -126,51 +172,11 @@ Stage::StageStatus BareIntersectionUnprotectedStageApproach::Process(
continue;
}
wait_for_obstacle_ids.push_back(obstacle->Id());
wait_for_obstacle_ids->push_back(obstacle->Id());
all_far_away = false;
}
}
if (scenario_config_.enable_explicit_stop()) {
clear_counter_ = all_far_away ? clear_counter_ + 1 : 0;
bool stop = false;
static constexpr double kCheckClearDistance = 5.0; // meter
static constexpr double kStartWatchDistance = 2.0; // meter
if (distance_adc_to_pnc_junction <= kCheckClearDistance &&
distance_adc_to_pnc_junction >= kStartWatchDistance && !all_far_away) {
clear_counter_ = 0; // reset
stop = true;
} else if (distance_adc_to_pnc_junction < kStartWatchDistance) {
// creeping area
if (clear_counter_ >= 5) {
clear_counter_ = 0; // reset
return FinishStage(frame);
} else {
stop = true;
}
}
if (stop) {
// build stop decision
ADEBUG << "BuildStopDecision: bare pnc_junction["
<< pnc_junction_overlap_id << "] start_s["
<< current_pnc_junction->start_s << "]";
const std::string virtual_obstacle_id =
"PNC_JUNCTION_" + current_pnc_junction->object_id;
planning::util::BuildStopDecision(
virtual_obstacle_id, current_pnc_junction->start_s,
scenario_config_.stop_distance(),
StopReasonCode::STOP_REASON_STOP_SIGN, wait_for_obstacle_ids,
"bare intersection", frame,
&(frame->mutable_reference_line_info()->front()));
}
} else if (distance_adc_to_pnc_junction <= 0) {
// rely on st-graph
return FinishStage(frame);
}
return Stage::RUNNING;
return all_far_away;
}
Stage::StageStatus BareIntersectionUnprotectedStageApproach::FinishStage(
......
......@@ -22,6 +22,7 @@
#include <memory>
#include <string>
#include <vector>
#include "modules/planning/scenarios/bare_intersection/unprotected/bare_intersection_unprotected_scenario.h"
#include "modules/planning/scenarios/stage.h"
......@@ -47,12 +48,13 @@ class BareIntersectionUnprotectedStageApproach : public Stage {
return GetContextAs<BareIntersectionUnprotectedContext>();
}
private:
bool CheckClear(const ReferenceLineInfo& reference_line_info,
std::vector<std::string>* wait_for_obstacle_ids);
Stage::StageStatus FinishStage(Frame* frame);
private:
ScenarioBareIntersectionUnprotectedConfig scenario_config_;
static uint32_t clear_counter_;
};
} // namespace bare_intersection
......
......@@ -190,8 +190,10 @@ bool CreepDecider::CheckCreepDone(const Frame& frame,
creep_clear_counter = 0; // reset
creep_done = true;
}
// use PlanningContext instead of static counter for multi-ADC
creep_decider_status->set_creep_clear_counter(creep_clear_counter);
}
return creep_done;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册