Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(avoidance): don't reset registered shift lines if the base offset is not zero (#3971) #579

Merged
merged 1 commit into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -311,17 +311,34 @@ class AvoidanceModule : public SceneModuleInterface

void insertYieldVelocity(ShiftedPath & shifted_path) const;

void removeAllRegisteredShiftPoints(PathShifter & path_shifter)
/**
* @brief reset registered shift lines.
* @details reset only when the base offset is zero. Otherwise, sudden steering will be caused;
*/
void removeRegisteredShiftLines()
{
constexpr double THRESHOLD = 0.1;
if (std::abs(path_shifter_.getBaseOffset()) > THRESHOLD) {
RCLCPP_INFO(getLogger(), "base offset is not zero. can't reset registered shift lines.");
return;
}

initRTCStatus();
unlockNewModuleLaunch();

current_raw_shift_lines_.clear();
registered_raw_shift_lines_.clear();
path_shifter.setShiftLines(ShiftLineArray{});
path_shifter_.setShiftLines(ShiftLineArray{});
}

void postProcess(PathShifter & path_shifter) const
/**
* @brief remove behind shift lines.
* @param path shifter.
*/
void postProcess()
{
const size_t nearest_idx = planner_data_->findEgoIndex(path_shifter.getReferencePath().points);
path_shifter.removeBehindShiftLineAndSetBaseOffset(nearest_idx);
const size_t idx = planner_data_->findEgoIndex(path_shifter_.getReferencePath().points);
path_shifter_.removeBehindShiftLineAndSetBaseOffset(idx);
}

boost::optional<double> getFeasibleDecelDistance(const double target_velocity) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,9 +575,7 @@ void AvoidanceModule::updateEgoBehavior(const AvoidancePlanningData & data, Shif
case AvoidanceState::YIELD: {
insertYieldVelocity(path);
insertWaitPoint(parameters_->use_constraints_for_decel, path);
initRTCStatus();
removeAllRegisteredShiftPoints(path_shifter_);
unlockNewModuleLaunch();
removeRegisteredShiftLines();
break;
}
case AvoidanceState::AVOID_PATH_NOT_READY: {
Expand Down Expand Up @@ -2818,7 +2816,7 @@ BehaviorModuleOutput AvoidanceModule::plan()

// post processing
{
postProcess(path_shifter_); // remove old shift points
postProcess(); // remove old shift points
prev_output_ = avoidance_path;
prev_linear_shift_path_ = utils::avoidance::toShiftedPath(avoidance_data_.reference_path);
path_shifter_.generate(&prev_linear_shift_path_, true, SHIFT_TYPE::LINEAR);
Expand Down Expand Up @@ -3084,7 +3082,7 @@ AvoidLineArray AvoidanceModule::findNewShiftLine(
// this value should be larger than -eps consider path shifter calculation error.
const double eps = 0.01;
if (candidate.start_longitudinal < -eps) {
continue;
break;
}

// TODO(Horibe): this code prohibits the changes on ego pose. Think later.
Expand Down