From cc708e0576cc5d4c5ca7eeaf31b1e1d68d93d56e Mon Sep 17 00:00:00 2001 From: Pradeep Date: Tue, 19 Mar 2024 14:53:17 +1100 Subject: [PATCH] AP_ICEngine: don't allow engine run with safety on Cherry-pick source: - AP_ICEngine: don't allow engine run with safety on : e0708489ad04a7d1fd402dc6273a51e377da7f32 - AP_EFI: fixed ignition while disarmed : 29568105fbbe82d0e6e16a7596f7de4b75283f79 Cherry-pick was not sufficient, since the code has changed since 4.3.25. This code is tested after changes. --- libraries/AP_EFI/AP_EFI_Serial_Hirth.cpp | 16 +++++++++++++++- libraries/AP_ICEngine/AP_ICEngine.cpp | 16 +++++++++++++++- libraries/AP_ICEngine/AP_ICEngine.h | 2 ++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/libraries/AP_EFI/AP_EFI_Serial_Hirth.cpp b/libraries/AP_EFI/AP_EFI_Serial_Hirth.cpp index b00a9090f9..6a2e4c94c0 100644 --- a/libraries/AP_EFI/AP_EFI_Serial_Hirth.cpp +++ b/libraries/AP_EFI/AP_EFI_Serial_Hirth.cpp @@ -165,7 +165,21 @@ void AP_EFI_Serial_Hirth::send_request() // check for change or timeout for throttle value if ((new_throttle != last_throttle) || (now - last_req_send_throttle_ms > 500)) { - request_was_sent = send_target_values(new_throttle); + bool allow_throttle = hal.util->get_soft_armed(); + if (!allow_throttle) { + const auto *ice = AP::ice(); + if (ice != nullptr) { + allow_throttle = ice->allow_throttle_disarmed(); + } + } + + if (allow_throttle) { + request_was_sent = send_target_values(new_throttle); + } + else { + request_was_sent = send_target_values(0); + } + last_throttle = new_throttle; last_req_send_throttle_ms = now; } else { diff --git a/libraries/AP_ICEngine/AP_ICEngine.cpp b/libraries/AP_ICEngine/AP_ICEngine.cpp index 88db95fc72..110148d6da 100644 --- a/libraries/AP_ICEngine/AP_ICEngine.cpp +++ b/libraries/AP_ICEngine/AP_ICEngine.cpp @@ -355,7 +355,12 @@ void AP_ICEngine::update(void) case ICE_STARTING: set_ignition(true); - set_starter(true); + + if (allow_throttle_disarmed()) { + set_starter(true); + } else { + set_starter(false); + } if (starter_start_time_ms == 0) { starter_start_time_ms = now; @@ -546,6 +551,15 @@ void AP_ICEngine::update_idle_governor(int8_t &min_throttle) min_throttle = roundf(idle_governor_integrator); } +/* + Allows throttle when disarmed and Safety Switch is not ON + */ +bool AP_ICEngine::allow_throttle_disarmed() const +{ + return option_set(Options::THROTTLE_WHILE_DISARMED) && + hal.util->safety_switch_state() != AP_HAL::Util::SAFETY_DISARMED; +} + /* set ignition state */ diff --git a/libraries/AP_ICEngine/AP_ICEngine.h b/libraries/AP_ICEngine/AP_ICEngine.h index 518eeb4913..d72bf083b8 100644 --- a/libraries/AP_ICEngine/AP_ICEngine.h +++ b/libraries/AP_ICEngine/AP_ICEngine.h @@ -69,6 +69,8 @@ class AP_ICEngine { static AP_ICEngine *get_singleton() { return _singleton; } + bool allow_throttle_disarmed() const; + private: static AP_ICEngine *_singleton;