Skip to content

Commit 69258bd

Browse files
authored
fix(autoware_mpc_lateral_controller): delete the zero speed constraint (#7673)
* delete steer rate limit when vel = 0 Signed-off-by: Zhe Shen <lucidshenzhe@gmail.com> * delete unnecessary variable Signed-off-by: Zhe Shen <lucidshenzhe@gmail.com> * pre-commit Signed-off-by: Zhe Shen <lucidshenzhe@gmail.com> --------- Signed-off-by: Zhe Shen <lucidshenzhe@gmail.com>
1 parent cd86f0a commit 69258bd

File tree

2 files changed

+7
-18
lines changed
  • control/autoware_mpc_lateral_controller

2 files changed

+7
-18
lines changed

control/autoware_mpc_lateral_controller/include/autoware/mpc_lateral_controller/mpc.hpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ class MPC
271271
*/
272272
std::pair<bool, VectorXd> executeOptimization(
273273
const MPCMatrix & mpc_matrix, const VectorXd & x0, const double prediction_dt,
274-
const MPCTrajectory & trajectory, const double current_velocity);
274+
const MPCTrajectory & trajectory);
275275

276276
/**
277277
* @brief Resample the trajectory with the MPC resampling time.
@@ -386,8 +386,7 @@ class MPC
386386
* @param reference_trajectory The reference trajectory.
387387
* @param current_velocity current velocity of ego.
388388
*/
389-
VectorXd calcSteerRateLimitOnTrajectory(
390-
const MPCTrajectory & trajectory, const double current_velocity) const;
389+
VectorXd calcSteerRateLimitOnTrajectory(const MPCTrajectory & trajectory) const;
391390

392391
//!< @brief logging with warn and return false
393392
template <typename... Args>

control/autoware_mpc_lateral_controller/src/mpc.cpp

+5-15
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,8 @@ bool MPC::calculateMPC(
7676
const auto mpc_matrix = generateMPCMatrix(mpc_resampled_ref_trajectory, prediction_dt);
7777

7878
// solve Optimization problem
79-
const auto [success_opt, Uex] = executeOptimization(
80-
mpc_matrix, x0_delayed, prediction_dt, mpc_resampled_ref_trajectory,
81-
current_kinematics.twist.twist.linear.x);
79+
const auto [success_opt, Uex] =
80+
executeOptimization(mpc_matrix, x0_delayed, prediction_dt, mpc_resampled_ref_trajectory);
8281
if (!success_opt) {
8382
return fail_warn_throttle("optimization failed. Stop MPC.");
8483
}
@@ -544,8 +543,7 @@ MPCMatrix MPC::generateMPCMatrix(
544543
* [ -au_lim * dt ] < [uN-uN-1] < [ au_lim * dt ] (*N... DIM_U)
545544
*/
546545
std::pair<bool, VectorXd> MPC::executeOptimization(
547-
const MPCMatrix & m, const VectorXd & x0, const double prediction_dt, const MPCTrajectory & traj,
548-
const double current_velocity)
546+
const MPCMatrix & m, const VectorXd & x0, const double prediction_dt, const MPCTrajectory & traj)
549547
{
550548
VectorXd Uex;
551549

@@ -578,7 +576,7 @@ std::pair<bool, VectorXd> MPC::executeOptimization(
578576
VectorXd ub = VectorXd::Constant(DIM_U_N, m_steer_lim); // max steering angle
579577

580578
// steering angle rate limit
581-
VectorXd steer_rate_limits = calcSteerRateLimitOnTrajectory(traj, current_velocity);
579+
VectorXd steer_rate_limits = calcSteerRateLimitOnTrajectory(traj);
582580
VectorXd ubA = steer_rate_limits * prediction_dt;
583581
VectorXd lbA = -steer_rate_limits * prediction_dt;
584582
ubA(0) = m_raw_steer_cmd_prev + steer_rate_limits(0) * m_ctrl_period;
@@ -730,8 +728,7 @@ double MPC::calcDesiredSteeringRate(
730728
return steer_rate;
731729
}
732730

733-
VectorXd MPC::calcSteerRateLimitOnTrajectory(
734-
const MPCTrajectory & trajectory, const double current_velocity) const
731+
VectorXd MPC::calcSteerRateLimitOnTrajectory(const MPCTrajectory & trajectory) const
735732
{
736733
const auto interp = [&](const auto & steer_rate_limit_map, const auto & current) {
737734
std::vector<double> reference, limits;
@@ -765,13 +762,6 @@ VectorXd MPC::calcSteerRateLimitOnTrajectory(
765762
return reference.back();
766763
};
767764

768-
// when the vehicle is stopped, no steering rate limit.
769-
constexpr double steer_rate_lim = 5.0;
770-
const bool is_vehicle_stopped = std::fabs(current_velocity) < 0.01;
771-
if (is_vehicle_stopped) {
772-
return steer_rate_lim * VectorXd::Ones(m_param.prediction_horizon);
773-
}
774-
775765
// calculate steering rate limit
776766
VectorXd steer_rate_limits = VectorXd::Zero(m_param.prediction_horizon);
777767
for (int i = 0; i < m_param.prediction_horizon; ++i) {

0 commit comments

Comments
 (0)