@@ -73,10 +73,6 @@ bool MPC::calculateMPC(
73
73
return fail_warn_throttle (" trajectory resampling failed. Stop MPC." );
74
74
}
75
75
76
- // get the diagnostic data
77
- const auto [success_data_for_diagnostic, mpc_data_for_diagnostic] =
78
- getData (mpc_resampled_ref_trajectory, current_steer, current_kinematics);
79
-
80
76
// get the diagnostic data w.r.t. the original trajectory
81
77
const auto [success_data_traj_raw, mpc_data_traj_raw] =
82
78
getData (m_mpc_traj_raw, current_steer, current_kinematics);
@@ -118,16 +114,16 @@ bool MPC::calculateMPC(
118
114
119
115
// prepare diagnostic message
120
116
diagnostic = generateDiagData (
121
- mpc_resampled_ref_trajectory , mpc_data_traj_raw, mpc_data_for_diagnostic , mpc_matrix, ctrl_cmd,
122
- Uex, current_kinematics, success_data_for_diagnostic, success_data_traj_raw);
117
+ reference_trajectory , mpc_data_traj_raw, mpc_data , mpc_matrix, ctrl_cmd,
118
+ Uex, current_kinematics, success_data_traj_raw);
123
119
124
120
return true ;
125
121
}
126
122
127
123
Float32MultiArrayStamped MPC::generateDiagData (
128
124
const MPCTrajectory & reference_trajectory, const MPCData & mpc_data_traj_raw,
129
125
const MPCData & mpc_data, const MPCMatrix & mpc_matrix, const AckermannLateralCommand & ctrl_cmd,
130
- const VectorXd & Uex, const Odometry & current_kinematics, bool success_data_for_diagnostic,
126
+ const VectorXd & Uex, const Odometry & current_kinematics,
131
127
bool success_data_traj_raw) const
132
128
{
133
129
Float32MultiArrayStamped diagnostic;
@@ -151,38 +147,21 @@ Float32MultiArrayStamped MPC::generateDiagData(
151
147
append_diag (ctrl_cmd.steering_tire_angle ); // [0] final steering command (MPC + LPF)
152
148
append_diag (Uex (0 )); // [1] mpc calculation result
153
149
append_diag (mpc_matrix.Uref_ex (0 )); // [2] feed-forward steering value
154
- append_diag (
155
- success_data_for_diagnostic ? std::atan (nearest_smooth_k * wb)
156
- : -1.0 ); // [3] feed-forward steering value raw
157
- append_diag (success_data_for_diagnostic ? mpc_data.steer : -1.0 ); // [4] current steering angle
158
- append_diag (
159
- success_data_for_diagnostic ? mpc_data.lateral_err
160
- : -1.0 ); // [5] lateral error (the actual error used for MPC)
150
+ append_diag (std::atan (nearest_smooth_k * wb)); // [3] feed-forward steering value raw
151
+ append_diag (mpc_data.steer ); // [4] current steering angle
152
+ append_diag (mpc_data.lateral_err ); // [5] lateral error (the actual error used for MPC)
161
153
append_diag (tf2::getYaw (current_kinematics.pose .pose .orientation )); // [6] current_pose yaw
162
- append_diag (
163
- success_data_for_diagnostic ? tf2::getYaw (mpc_data.nearest_pose .orientation )
164
- : -1.0 ); // [7] nearest_pose yaw
165
- append_diag (success_data_for_diagnostic ? mpc_data.yaw_err : -1.0 ); // [8] yaw error
166
- append_diag (
167
- success_data_for_diagnostic ? reference_trajectory.vx .at (mpc_data.nearest_idx )
168
- : -1.0 ); // [9] reference velocity
154
+ append_diag (tf2::getYaw (mpc_data.nearest_pose .orientation )); // [7] nearest_pose yaw
155
+ append_diag (mpc_data.yaw_err ); // [8] yaw error
156
+ append_diag (reference_trajectory.vx .at (mpc_data.nearest_idx )); // [9] reference velocity
169
157
append_diag (current_velocity); // [10] measured velocity
170
158
append_diag (wz_command); // [11] angular velocity from steer command
171
- append_diag (
172
- success_data_for_diagnostic ? wz_measured : -1.0 ); // [12] angular velocity from measured steer
173
- append_diag (
174
- success_data_for_diagnostic ? current_velocity * nearest_smooth_k
175
- : -1.0 ); // [13] angular velocity from path curvature
176
- append_diag (
177
- success_data_for_diagnostic ? nearest_smooth_k
178
- : -1.0 ); // [14] nearest path curvature (used for feed-forward)
179
- append_diag (
180
- success_data_for_diagnostic ? nearest_k : -1.0 ); // [15] nearest path curvature (not smoothed)
181
- append_diag (
182
- success_data_for_diagnostic ? mpc_data.predicted_steer : -1.0 ); // [16] predicted steer
183
- append_diag (
184
- success_data_for_diagnostic ? wz_predicted
185
- : -1.0 ); // [17] angular velocity from predicted steer
159
+ append_diag (wz_measured); // [12] angular velocity from measured steer
160
+ append_diag (current_velocity * nearest_smooth_k); // [13] angular velocity from path curvature
161
+ append_diag (nearest_smooth_k); // [14] nearest path curvature (used for feed-forward)
162
+ append_diag (nearest_k); // [15] nearest path curvature (not smoothed)
163
+ append_diag (mpc_data.predicted_steer ); // [16] predicted steer
164
+ append_diag (wz_predicted); // [17] angular velocity from predicted steer
186
165
append_diag (iteration_num); // [18] iteration number
187
166
append_diag (runtime); // [19] runtime of the latest problem solved
188
167
append_diag (objective_value); // [20] objective value of the latest problem solved
0 commit comments