Skip to content

Commit

Permalink
planning: modified lane_change process() function to enable lane_chan…
Browse files Browse the repository at this point in the history
…ge task in ReferenceLanePlanner
  • Loading branch information
sjiang2018 authored and xiaoxq committed Nov 6, 2019
1 parent 7940189 commit 9ef8373
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ using apollo::common::util::StrCat;
LaneChangeDecider::LaneChangeDecider(const TaskConfig& config)
: Decider(config) {}

Status LaneChangeDecider::Process(Frame* frame) {
// added a dummy parameter to enable this task in ExecuteTaskOnReferenceLine
Status LaneChangeDecider::Process(
Frame* frame, ReferenceLineInfo* const current_reference_line_info) {
// Sanity checks.
CHECK_NOTNULL(frame);
std::list<ReferenceLineInfo>* reference_line_info =
Expand Down Expand Up @@ -63,6 +65,7 @@ Status LaneChangeDecider::Process(Frame* frame) {
}

bool has_change_lane = reference_line_info->size() > 1;
ADEBUG << "has_change_lane: " << has_change_lane;
if (!has_change_lane) {
const auto& path_id = reference_line_info->front().Lanes().Id();
if (prev_status->status() == ChangeLaneStatus::CHANGE_LANE_FINISHED) {
Expand All @@ -88,25 +91,30 @@ Status LaneChangeDecider::Process(Frame* frame) {
PrioritizeChangeLane(reference_line_info);
} else {
RemoveChangeLane(reference_line_info);
ADEBUG << "removed change lane.";
UpdateStatus(now, ChangeLaneStatus::CHANGE_LANE_FINISHED,
current_path_id);
}
return Status::OK();
} else if (prev_status->status() == ChangeLaneStatus::CHANGE_LANE_FAILED) {
if (now - prev_status->timestamp() < FLAGS_change_lane_fail_freeze_time) {
RemoveChangeLane(reference_line_info);
ADEBUG << "freezed after failed";
} else {
UpdateStatus(now, ChangeLaneStatus::IN_CHANGE_LANE, current_path_id);
ADEBUG << "change lane again after failed";
}
return Status::OK();
} else if (prev_status->status() ==
ChangeLaneStatus::CHANGE_LANE_FINISHED) {
if (now - prev_status->timestamp() <
FLAGS_change_lane_success_freeze_time) {
RemoveChangeLane(reference_line_info);
ADEBUG << "freezed after completed lane change";
} else {
PrioritizeChangeLane(reference_line_info);
UpdateStatus(now, ChangeLaneStatus::IN_CHANGE_LANE, current_path_id);
ADEBUG << "change lane again after success";
}
} else {
const std::string msg =
Expand Down Expand Up @@ -200,6 +208,10 @@ void LaneChangeDecider::PrioritizeChangeLane(

void LaneChangeDecider::RemoveChangeLane(
std::list<ReferenceLineInfo>* reference_line_info) const {
// TODO(SHU): fix core dump when removing change lane
return;
/* disable rest to avoid core dump */
ADEBUG << "removed change lane";
auto iter = reference_line_info->begin();
while (iter != reference_line_info->end()) {
if (iter->IsChangeLanePath()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class LaneChangeDecider : public Decider {
* @param search_beam_radius_intensity is the resolution of scanning
* @param search_range is the scanning range centering at ADV heading
* @param is_block_angle_threshold is the threshold to tell how big a block
* angle range is percption blocking
* angle range is perception blocking
*/
static bool IsPerceptionBlocked(const ReferenceLineInfo& reference_line_info,
const double search_beam_length,
Expand All @@ -65,7 +65,9 @@ class LaneChangeDecider : public Decider {
const ReferenceLineInfo* const reference_line_info);

private:
common::Status Process(Frame* frame) override;
common::Status Process(
Frame* frame,
ReferenceLineInfo* const current_reference_line_info) override;

static bool HysteresisFilter(const double obstacle_distance,
const double safe_distance,
Expand Down

0 comments on commit 9ef8373

Please sign in to comment.