From 76999e2ea5e400a640c8aadb3480876481bcf1cc Mon Sep 17 00:00:00 2001 From: Andy Piper Date: Tue, 17 Mar 2026 10:29:55 +0000 Subject: [PATCH] RC_Channel: add EKF_RESET aux function for bootstrap reset Add RCx_OPTION=187 (EKF_RESET) aux function that triggers a full EKF bootstrap reset on HIGH, gated to fire only on state transition. Sends GCS status message indicating whether the reset succeeded or failed. Available for all vehicle types. Gated by AP_AHRS_EKF_RESET_ENABLED compile-time option. --- libraries/RC_Channel/RC_Channel.cpp | 20 ++++++++++++++++++-- libraries/RC_Channel/RC_Channel.h | 3 +++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/libraries/RC_Channel/RC_Channel.cpp b/libraries/RC_Channel/RC_Channel.cpp index be3480ed157..359f5d3c147 100644 --- a/libraries/RC_Channel/RC_Channel.cpp +++ b/libraries/RC_Channel/RC_Channel.cpp @@ -250,8 +250,9 @@ const AP_Param::GroupInfo RC_Channel::var_info[] = { // @Values{Copter}: 182: AHRS AutoTrim // @Values{Plane}: 183: AUTOLAND mode // @Values{Plane}: 184: System ID Chirp - // @Values{Copter, Rover, Plane, Blimp, Sub}: 185:Mount Roll/Pitch Lock - // @Values{Copter, Rover, Plane, Blimp, Sub}: 186:Mount POI Lock + // @Values{Copter, Rover, Plane, Blimp, Sub}: 185:Mount Roll/Pitch Lock + // @Values{Copter, Rover, Plane, Blimp, Sub}: 186:Mount POI Lock + // @Values{Copter, Rover, Plane, Blimp, Sub}: 187:EKF Reset // @Values{Rover}: 201:Roll // @Values{Rover}: 202:Pitch // @Values{Rover}: 207:MainSail @@ -697,6 +698,9 @@ void RC_Channel::init_aux_function(const AUX_FUNC ch_option, const AuxSwitchPos case AUX_FUNC::EKF_LANE_SWITCH: case AUX_FUNC::EKF_YAW_RESET: #endif +#if AP_AHRS_EKF_RESET_ENABLED + case AUX_FUNC::EKF_RESET: +#endif #if HAL_GENERATOR_ENABLED case AUX_FUNC::GENERATOR: // don't turn generator on or off initially #endif @@ -1926,6 +1930,18 @@ bool RC_Channel::do_aux_function(const AuxFuncTrigger &trigger) AP::ahrs().request_yaw_reset(); break; +#if AP_AHRS_EKF_RESET_ENABLED + case AUX_FUNC::EKF_RESET: + if (ch_flag == AuxSwitchPos::HIGH) { + if (AP::ahrs().reset_configured_backend() && hal.util->get_soft_armed()) { + GCS_SEND_TEXT(MAV_SEVERITY_WARNING, "EKF bootstrap reset performed"); + } else { + GCS_SEND_TEXT(MAV_SEVERITY_WARNING, "EKF bootstrap reset failed"); + } + } + break; +#endif // AP_AHRS_EKF_RESET_ENABLED + case AUX_FUNC::AHRS_TYPE: { #if HAL_NAVEKF3_AVAILABLE && AP_EXTERNAL_AHRS_ENABLED AP::ahrs().set_ekf_type(ch_flag==AuxSwitchPos::HIGH? AP_AHRS::EKFType::EXTERNAL : AP_AHRS::EKFType::THREE); diff --git a/libraries/RC_Channel/RC_Channel.h b/libraries/RC_Channel/RC_Channel.h index e4809436abf..74ea99052b3 100644 --- a/libraries/RC_Channel/RC_Channel.h +++ b/libraries/RC_Channel/RC_Channel.h @@ -372,6 +372,9 @@ public: #if AP_MOUNT_POI_LOCK_ENABLED MOUNT_POI_LOCK = 186, // Lock mount target to current ROI seen and switch mount to GPS Targeting mode #endif // AP_MOUNT_POI_LOCK_ENABLED +#if AP_AHRS_EKF_RESET_ENABLED + EKF_RESET = 187, // trigger full EKF bootstrap reset +#endif // AP_AHRS_EKF_RESET_ENABLED // inputs from 200 will eventually used to replace RCMAP ROLL = 201, // roll input PITCH = 202, // pitch input