Skip to content

Commit d3278b4

Browse files
committed
member attribute added.
Signed-off-by: Zhe Shen <lucidshenzhe@gmail.com>
1 parent d278c64 commit d3278b4

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

control/mpc_lateral_controller/include/mpc_lateral_controller/mpc_lateral_controller.hpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,15 @@ class MpcLateralController : public trajectory_follower::LateralControllerBase
8989
// Flag indicating whether to keep the steering control until it converges.
9090
bool m_keep_steer_control_until_converged;
9191

92+
// MPC colver checker.
93+
bool m_is_mpc_solved{true};
94+
9295
// trajectory buffer for detecting new trajectory
9396
std::deque<Trajectory> m_trajectory_buffer;
9497

9598
diagnostic_updater::Updater diag_updater_{this}; // Diagnostic updater for publishing diagnostic data.
9699

97-
void setStatus(diagnostic_updater::DiagnosticStatusWrapper & stat, const bool & m_MPC_failed);
100+
void setStatus(diagnostic_updater::DiagnosticStatusWrapper & stat, const bool & m_is_mpc_solved);
98101

99102
void setupDiag();
100103

control/mpc_lateral_controller/src/mpc_lateral_controller.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,9 @@ std::shared_ptr<SteeringOffsetEstimator> MpcLateralController::createSteerOffset
230230
}
231231

232232
void MpcLateralController::setStatus(
233-
diagnostic_updater::DiagnosticStatusWrapper & stat, const bool & is_mpc_solved)
233+
diagnostic_updater::DiagnosticStatusWrapper & stat, const bool & m_is_mpc_solved)
234234
{
235-
if (is_mpc_solved) {
235+
if (m_is_mpc_solved) {
236236
stat.summary(diagnostic_msgs::msg::DiagnosticStatus::OK, "MPC succeeded.");
237237
} else {
238238
const std::string & error_msg = "The MPC solver failed. Call MRM to stop the car.";
@@ -247,7 +247,7 @@ void MpcLateralController::setupDiag()
247247

248248
d.add("MPC_solve_checker", [&](auto & stat) {
249249
setStatus(
250-
stat, is_mpc_solved);
250+
stat, m_is_mpc_solved);
251251
});
252252
}
253253

@@ -279,6 +279,8 @@ trajectory_follower::LateralOutput MpcLateralController::run(
279279
const bool is_mpc_solved = m_mpc->calculateMPC(
280280
m_current_steering, m_current_kinematic_state, ctrl_cmd, predicted_traj, debug_values);
281281

282+
m_is_mpc_solved = is_mpc_solved; // for diagnostic updater
283+
282284
diag_updater_.force_update();
283285

284286
// reset previous MPC result

0 commit comments

Comments
 (0)