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

feat(pid_longitudinal_controller): transit to STOPPED even if the sign of the ego velocity goes opposite #926

Merged
merged 1 commit into from
Oct 18, 2023
Merged
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 @@ -493,9 +493,26 @@ void PidLongitudinalController::updateControlState(const ControlData & control_d
m_enable_keep_stopped_until_steer_convergence && !lateral_sync_data_.is_steer_converged;

const bool stopping_condition = stop_dist < p.stopping_state_stop_dist;
if (
std::fabs(current_vel) > p.stopped_state_entry_vel ||
std::fabs(current_acc) > p.stopped_state_entry_acc) {

const bool is_stopped = std::abs(current_vel) < p.stopped_state_entry_vel &&
std::abs(current_acc) < p.stopped_state_entry_acc;
// Case where the ego slips in the opposite direction of the gear due to e.g. a slope is also
// considered as a stop
const bool is_not_running = [&]() {
if (control_data.shift == Shift::Forward) {
if (is_stopped || current_vel < 0.0) {
// NOTE: Stopped or moving backward
return true;
}
} else {
if (is_stopped || 0.0 < current_vel) {
// NOTE: Stopped or moving forward
return true;
}
}
return false;
}();
if (!is_not_running) {
m_last_running_time = std::make_shared<rclcpp::Time>(node_->now());
}
const bool stopped_condition =
Expand Down