diff --git a/ArduCopter/crash_check.cpp b/ArduCopter/crash_check.cpp index 0a377419afa22a..c97fb7f04ada83 100644 --- a/ArduCopter/crash_check.cpp +++ b/ArduCopter/crash_check.cpp @@ -232,7 +232,6 @@ void Copter::yaw_imbalance_check() #if PARACHUTE == ENABLED // Code to detect a crash main ArduCopter code -#define PARACHUTE_CHECK_TRIGGER_SEC 1 // 1 second of loss of control triggers the parachute #define PARACHUTE_CHECK_ANGLE_DEVIATION_DEG 30.0f // 30 degrees off from target indicates a loss of control // parachute_check - disarms motors and triggers the parachute if serious loss of control has been detected @@ -302,7 +301,7 @@ void Copter::parachute_check() } // increment counter - if (control_loss_count < (PARACHUTE_CHECK_TRIGGER_SEC*scheduler.get_loop_rate_hz())) { + if (control_loss_count < (parachute.get_chute_timeout()*scheduler.get_loop_rate_hz())) { control_loss_count++; } @@ -317,8 +316,8 @@ void Copter::parachute_check() // To-Do: add check that the vehicle is actually falling - // check if loss of control for at least 1 second - } else if (control_loss_count >= (PARACHUTE_CHECK_TRIGGER_SEC*scheduler.get_loop_rate_hz())) { + // check if loss of control for at least time defined in CHUTE_TIMEOUT parameter + } else if (control_loss_count >= (parachute.get_chute_timeout()*scheduler.get_loop_rate_hz())) { // reset control loss counter control_loss_count = 0; LOGGER_WRITE_ERROR(LogErrorSubsystem::CRASH_CHECK, LogErrorCode::CRASH_CHECK_LOSS_OF_CONTROL); diff --git a/libraries/AP_Parachute/AP_Parachute.cpp b/libraries/AP_Parachute/AP_Parachute.cpp index ad45fed687042b..c08e1a500dad15 100644 --- a/libraries/AP_Parachute/AP_Parachute.cpp +++ b/libraries/AP_Parachute/AP_Parachute.cpp @@ -83,6 +83,14 @@ const AP_Param::GroupInfo AP_Parachute::var_info[] = { // @User: Standard AP_GROUPINFO("OPTIONS", 7, AP_Parachute, _options, AP_PARACHUTE_OPTIONS_DEFAULT), + // @Param: TIMEOUT + // @DisplayName: Parachute timeout + // @Description: Triggers the parachute if the loss of control lasts for the time specified by this parameter + // @Units: s + // @Range: 0.5 5.0 + // @User: Advanced + AP_GROUPINFO("TIMEOUT", 8, AP_Parachute, _timeout, AP_PARACHUTE_TIMEOUT_DEFAULT), + AP_GROUPEND }; diff --git a/libraries/AP_Parachute/AP_Parachute.h b/libraries/AP_Parachute/AP_Parachute.h index b37f20051a97a8..eba5cc3bff5cf9 100644 --- a/libraries/AP_Parachute/AP_Parachute.h +++ b/libraries/AP_Parachute/AP_Parachute.h @@ -21,6 +21,7 @@ #define AP_PARACHUTE_CRITICAL_SINK_DEFAULT 0 // default critical sink speed in m/s to trigger emergency parachute #define AP_PARACHUTE_OPTIONS_DEFAULT 0 // default parachute options: enabled disarm after parachute release +#define AP_PARACHUTE_TIMEOUT_DEFAULT 1.0f // default parachute control loss timeout #ifndef HAL_PARACHUTE_ENABLED // default to parachute enabled to match previous configs @@ -90,6 +91,9 @@ class AP_Parachute { // Return the relay index that would be used for param conversion to relay functions bool get_legacy_relay_index(int8_t &index) const; + // Return the CHUTE_TIMEOUT parameter value + float get_chute_timeout() const { return _timeout; } + static const struct AP_Param::GroupInfo var_info[]; // get singleton instance @@ -105,6 +109,8 @@ class AP_Parachute { AP_Int16 _alt_min; // min altitude the vehicle should have before parachute is released AP_Int16 _delay_ms; // delay before chute release for motors to stop AP_Float _critical_sink; // critical sink rate to trigger emergency parachute + AP_Int32 _options; // optional behaviour for parachute bitmask + AP_Float _timeout; // loss of control timeout value in seconds // internal variables uint32_t _release_time; // system time that parachute is ordered to be released (actual release will happen 0.5 seconds later) @@ -118,8 +124,6 @@ class AP_Parachute { HoldOpen = (1U<<0), SkipDisarmBeforeParachuteRelease = (1U<<1), }; - - AP_Int32 _options; }; namespace AP {