Skip to content

Commit dc98701

Browse files
committed
remove the mpc_data_for_diag
Signed-off-by: Zhe Shen <lucidshenzhe@gmail.com>
1 parent f46c980 commit dc98701

File tree

2 files changed

+16
-37
lines changed
  • control/mpc_lateral_controller

2 files changed

+16
-37
lines changed

control/mpc_lateral_controller/include/mpc_lateral_controller/mpc.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ class MPC
380380
const MPCTrajectory & reference_trajectory, const MPCData & mpc_data_traj_raw,
381381
const MPCData & mpc_data, const MPCMatrix & mpc_matrix,
382382
const AckermannLateralCommand & ctrl_cmd, const VectorXd & Uex,
383-
const Odometry & current_kinematics, bool success_data_for_diagnostic,
383+
const Odometry & current_kinematics,
384384
bool success_data_traj_raw) const;
385385

386386
/**

control/mpc_lateral_controller/src/mpc.cpp

+15-36
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,6 @@ bool MPC::calculateMPC(
7373
return fail_warn_throttle("trajectory resampling failed. Stop MPC.");
7474
}
7575

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-
8076
// get the diagnostic data w.r.t. the original trajectory
8177
const auto [success_data_traj_raw, mpc_data_traj_raw] =
8278
getData(m_mpc_traj_raw, current_steer, current_kinematics);
@@ -118,16 +114,16 @@ bool MPC::calculateMPC(
118114

119115
// prepare diagnostic message
120116
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);
123119

124120
return true;
125121
}
126122

127123
Float32MultiArrayStamped MPC::generateDiagData(
128124
const MPCTrajectory & reference_trajectory, const MPCData & mpc_data_traj_raw,
129125
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,
131127
bool success_data_traj_raw) const
132128
{
133129
Float32MultiArrayStamped diagnostic;
@@ -151,38 +147,21 @@ Float32MultiArrayStamped MPC::generateDiagData(
151147
append_diag(ctrl_cmd.steering_tire_angle); // [0] final steering command (MPC + LPF)
152148
append_diag(Uex(0)); // [1] mpc calculation result
153149
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)
161153
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
169157
append_diag(current_velocity); // [10] measured velocity
170158
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
186165
append_diag(iteration_num); // [18] iteration number
187166
append_diag(runtime); // [19] runtime of the latest problem solved
188167
append_diag(objective_value); // [20] objective value of the latest problem solved

0 commit comments

Comments
 (0)