Skip to content

Commit

Permalink
use the flag input_data.current_operation_mode.is_autoware_control_en…
Browse files Browse the repository at this point in the history
…abled

Signed-off-by: Zhe Shen <[email protected]>
  • Loading branch information
HansOersted committed Jun 5, 2024
1 parent 2156a9c commit 7e170bf
Showing 1 changed file with 1 addition and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,6 @@ trajectory_follower::LateralOutput MpcLateralController::run(
m_is_ctrl_cmd_prev_initialized = true;
}

const bool is_driving_manually = input_data.current_operation_mode.mode == autoware_adapi_v1_msgs::msg::OperationModeState::LOCAL ||
input_data.current_operation_mode.mode == autoware_adapi_v1_msgs::msg::OperationModeState::REMOTE ||
input_data.current_operation_mode.mode == autoware_adapi_v1_msgs::msg::OperationModeState::STOP;

const bool is_mpc_solved = m_mpc->calculateMPC(
m_current_steering, m_current_kinematic_state, ctrl_cmd, predicted_traj, debug_values);

Expand All @@ -264,7 +260,7 @@ trajectory_follower::LateralOutput MpcLateralController::run(
// the vehicle will return to the path by re-planning the trajectory or external operation.
// After the recovery, the previous value of the optimization may deviate greatly from
// the actual steer angle, and it may make the optimization result unstable.
if (!is_mpc_solved||is_driving_manually) {
if (!is_mpc_solved||!input_data.current_operation_mode.is_autoware_control_enabled) {

Check warning on line 263 in control/mpc_lateral_controller/src/mpc_lateral_controller.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Complex Method

MpcLateralController::run increases in cyclomatic complexity from 12 to 13, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
m_mpc->resetPrevResult(m_current_steering);
} else {
setSteeringToHistory(ctrl_cmd);
Expand Down

0 comments on commit 7e170bf

Please sign in to comment.