diff --git a/msg/InternalCombustionEngineControl.msg b/msg/InternalCombustionEngineControl.msg index d1ea4959982..71a93317a94 100644 --- a/msg/InternalCombustionEngineControl.msg +++ b/msg/InternalCombustionEngineControl.msg @@ -5,4 +5,4 @@ float32 throttle_control # setpoint for throttle actuator, with slew rate if en float32 choke_control # setpoint for choke actuator, 1: fully closed [norm] [@range 0,1] float32 starter_engine_control # setpoint for (electric) starter motor [norm] [@range 0,1] -uint8 user_request # user intent for the ICE being on/off +bool user_request_motor_on # user intent for the ICE being on/off diff --git a/src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.cpp b/src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.cpp index 280530070a8..b48ff195fe4 100644 --- a/src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.cpp +++ b/src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.cpp @@ -123,34 +123,33 @@ void InternalCombustionEngineControl::Run() switch (static_cast(_param_ice_on_source.get())) { case ICESource::ArmingState: { - _user_request = vehicle_status.arming_state == vehicle_status_s::ARMING_STATE_ARMED ? UserOnOffRequest::On : - UserOnOffRequest::Off; + _user_request_motor_on = vehicle_status.arming_state == vehicle_status_s::ARMING_STATE_ARMED; } break; case ICESource::Aux1: { if (manual_control_setpoint.aux1 > 0.5f) { - _user_request = UserOnOffRequest::On; + _user_request_motor_on = true; } else if (manual_control_setpoint.aux1 < -0.5f) { - _user_request = UserOnOffRequest::Off; + _user_request_motor_on = false; } } break; case ICESource::Aux2: { if (manual_control_setpoint.aux2 > 0.5f) { - _user_request = UserOnOffRequest::On; + _user_request_motor_on = true; } else if (manual_control_setpoint.aux2 < -0.5f) { - _user_request = UserOnOffRequest::Off; + _user_request_motor_on = false; } } break; case ICESource::VtolStatus: { - _user_request = (vehicle_status.vehicle_type == vehicle_status_s::VEHICLE_TYPE_FIXED_WING - || vehicle_status.in_transition_to_fw) ? UserOnOffRequest::On : UserOnOffRequest::Off; + _user_request_motor_on = vehicle_status.vehicle_type == vehicle_status_s::VEHICLE_TYPE_FIXED_WING + || vehicle_status.in_transition_to_fw; } break; } @@ -159,7 +158,7 @@ void InternalCombustionEngineControl::Run() case State::Stopped: { controlEngineStop(); - if (_user_request == UserOnOffRequest::On && !maximumAttemptsReached()) { + if (_user_request_motor_on && !maximumAttemptsReached()) { _state = State::Starting; _state_start_time = now; @@ -170,7 +169,7 @@ void InternalCombustionEngineControl::Run() case State::Starting: { - if (_user_request == UserOnOffRequest::Off) { + if (!_user_request_motor_on) { _state = State::Stopped; _starting_retry_cycle = 0; PX4_INFO("ICE: Stopped"); @@ -241,7 +240,7 @@ void InternalCombustionEngineControl::Run() controlEngineRunning(throttle_in); } - if (_user_request == UserOnOffRequest::Off) { + if (!_user_request_motor_on) { _state = State::Stopped; _starting_retry_cycle = 0; PX4_INFO("ICE: Stopped"); @@ -262,7 +261,7 @@ void InternalCombustionEngineControl::Run() case State::Fault: { - if (_user_request == UserOnOffRequest::Off) { + if (!_user_request_motor_on) { _state = State::Stopped; _starting_retry_cycle = 0; PX4_INFO("ICE: Stopped"); @@ -299,7 +298,7 @@ void InternalCombustionEngineControl::publishControl(const hrt_abstime now) ice_control.ignition_on = _ignition_on; ice_control.starter_engine_control = _starter_engine_control; ice_control.throttle_control = _throttle_control; - ice_control.user_request = static_cast(_user_request); + ice_control.user_request_motor_on = _user_request_motor_on; _internal_combustion_engine_control_pub.publish(ice_control); internal_combustion_engine_status_s ice_status{}; diff --git a/src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.hpp b/src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.hpp index f97888ce211..14fad215f1e 100644 --- a/src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.hpp +++ b/src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.hpp @@ -103,11 +103,6 @@ private: Rest }; - enum class UserOnOffRequest { - Off, - On - } _user_request{UserOnOffRequest::Off}; - enum class ICESource { ArmingState, Aux1, @@ -119,6 +114,7 @@ private: hrt_abstime _last_time_run{0}; hrt_abstime _rpm_timestamp{0}; + bool _user_request_motor_on{false}; bool _ignition_on{false}; bool _is_engine_running{false}; bool _idle_control_active{false};