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(mpc): use optimization result when polish failed (#4673) #951

Merged
merged 1 commit into from
Oct 17, 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
10 changes: 4 additions & 6 deletions control/mpc_lateral_controller/src/qp_solver/qp_solver_osqp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,10 @@ bool QPSolverOSQP::solve(

// polish status: successful (1), unperformed (0), (-1) unsuccessful
int status_polish = std::get<2>(result);
if (status_polish == -1) {
RCLCPP_WARN(logger_, "osqp status_polish = %d (unsuccessful)", status_polish);
return false;
}
if (status_polish == 0) {
RCLCPP_WARN(logger_, "osqp status_polish = %d (unperformed)", status_polish);
if (status_polish == -1 || status_polish == 0) {
const auto s = (status_polish == 0) ? "Polish process is not performed in osqp."
: "Polish process failed in osqp.";
RCLCPP_INFO(logger_, "%s The required accuracy is met, but the solution can be inaccurate.", s);
return true;
}
return true;
Expand Down
3 changes: 1 addition & 2 deletions control/mpc_lateral_controller/test/test_mpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,8 @@ TEST_F(MPCTest, OsqpCalculate)
AckermannLateralCommand ctrl_cmd;
Trajectory pred_traj;
Float32MultiArrayStamped diag;
// with OSQP this function returns false despite finding correct solutions
const auto odom = makeOdometry(pose_zero, default_velocity);
EXPECT_FALSE(mpc.calculateMPC(neutral_steer, odom, ctrl_cmd, pred_traj, diag));
EXPECT_TRUE(mpc.calculateMPC(neutral_steer, odom, ctrl_cmd, pred_traj, diag));
EXPECT_EQ(ctrl_cmd.steering_tire_angle, 0.0f);
EXPECT_EQ(ctrl_cmd.steering_tire_rotation_rate, 0.0f);
}
Expand Down
Loading