From a3657c13968bc3fc53e536ad29b0882c9f899592 Mon Sep 17 00:00:00 2001 From: Pernilla Date: Fri, 4 Apr 2025 12:05:57 +0200 Subject: [PATCH] Allow user to set choke position through parameter --- .../InternalCombustionEngineControl.cpp | 11 ++++++----- .../InternalCombustionEngineControl.hpp | 3 ++- .../internal_combustion_engine_control/module.yaml | 11 +++++++++++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.cpp b/src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.cpp index 1e8a1b1a35..8907374d44 100644 --- a/src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.cpp +++ b/src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.cpp @@ -319,7 +319,8 @@ void InternalCombustionEngineControl::controlEngineStartup(const hrt_abstime now _ignition_on = true; _throttle_control = _param_ice_strt_thr.get(); - _choke_control = now < _state_start_time + (choke_duration + ignition_delay) * 1_s ? 1.f : 0.f; + _choke_control = now < _state_start_time + (choke_duration + ignition_delay) * 1_s ? math::constrain( + _param_ice_strt_choke.get(), 0.f, 1.f) : 0.f; _starter_engine_control = now > _state_start_time + (ignition_delay * 1_s) ? 1.f : 0.f; const hrt_abstime cycle_timeout_duration = (ignition_delay + choke_duration + starter_duration) * 1_s; @@ -355,7 +356,7 @@ int InternalCombustionEngineControl::print_usage(const char *reason) PRINT_MODULE_DESCRIPTION( R"DESCR_STR( ### Description - + The module controls internal combustion engine (ICE) features including: ignition (on/off), throttle and choke level, starter engine delay, and user request. @@ -389,18 +390,18 @@ The ICE is implemented with a (4) state machine: ![Architecture](../../assets/hardware/ice/ice_control_state_machine.png) The state machine: - + - Checks if [Rpm.msg](../msg_docs/Rpm.md) is updated to know if the engine is running - Allows for user inputs from: - AUX{N} - Arming state in [VehicleStatus.msg](../msg_docs/VehicleStatus.md) The module publishes [InternalCombustionEngineControl.msg](../msg_docs/InternalCombustionEngineControl.md). - + The architecture is as shown below: ![Architecture](../../assets/hardware/ice/ice_control_diagram.png) - + )DESCR_STR"); diff --git a/src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.hpp b/src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.hpp index 01884e4967..46117cab3a 100644 --- a/src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.hpp +++ b/src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.hpp @@ -152,7 +152,8 @@ private: (ParamFloat) _param_ice_strt_thr, (ParamInt) _param_ice_stop_choke, (ParamFloat) _param_ice_thr_slew, - (ParamFloat) _param_ice_ign_delay + (ParamFloat) _param_ice_ign_delay, + (ParamFloat) _param_ice_strt_choke ) }; diff --git a/src/modules/internal_combustion_engine_control/module.yaml b/src/modules/internal_combustion_engine_control/module.yaml index 517fc89fee..7877fdff2c 100644 --- a/src/modules/internal_combustion_engine_control/module.yaml +++ b/src/modules/internal_combustion_engine_control/module.yaml @@ -118,3 +118,14 @@ parameters: decimal: 1 increment: 0.1 default: 0 + + ICE_STRT_CHOKE: + description: + short: Choke position during startup, 1 for fully choked. + type: float + unit: norm + min: 0 + max: 1 + decimal: 0 + increment: 0.01 + default: 0.8