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(vehicle_cmd_gate): fix slow start #4323

Merged
merged 2 commits into from
Jul 19, 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
2 changes: 2 additions & 0 deletions control/vehicle_cmd_gate/src/vehicle_cmd_filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class VehicleCmdFilter
void filterAll(
const double dt, const double current_steer_angle, AckermannControlCommand & input) const;

AckermannControlCommand getPrevCmd() { return prev_cmd_; }

private:
VehicleCmdFilterParam param_;
AckermannControlCommand prev_cmd_;
Expand Down
17 changes: 15 additions & 2 deletions control/vehicle_cmd_gate/src/vehicle_cmd_gate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <rclcpp/logging.hpp>
#include <tier4_api_utils/tier4_api_utils.hpp>

#include <algorithm>
#include <chrono>
#include <functional>
#include <memory>
Expand Down Expand Up @@ -504,10 +505,22 @@ AckermannControlCommand VehicleCmdGate::filterControlCommand(const AckermannCont
filter_on_transition_.filterAll(dt, current_steer_, out);
} else {
// When ego is stopped and the input command is not stopping,
// use the actual vehicle longitudinal state for the filtering
// use the higher of actual vehicle longitudinal state
// and previous longitudinal command for the filtering
// this is to prevent the jerk limits being applied and causing
// a delay when restarting the vehicle.
if (ego_is_stopped && !input_cmd_is_stopping) filter_.setPrevCmd(current_status_cmd);

if (ego_is_stopped && !input_cmd_is_stopping) {
auto prev_cmd = filter_.getPrevCmd();
prev_cmd.longitudinal.acceleration =
std::max(prev_cmd.longitudinal.acceleration, current_status_cmd.longitudinal.acceleration);
// consider reverse driving
prev_cmd.longitudinal.speed =
std::fabs(prev_cmd.longitudinal.speed) > std::fabs(current_status_cmd.longitudinal.speed)
? prev_cmd.longitudinal.speed
: current_status_cmd.longitudinal.speed;
filter_.setPrevCmd(prev_cmd);
}
filter_.filterAll(dt, current_steer_, out);
}

Expand Down