mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 06:53:35 +08:00
PWM automatic trigger system (ATS) for parachutes (#13726)
* parameter and logic to commander for triggering failsafe from external automatic trigger system. * logic to startup script for enabling ATS. Added uORB publishing to pwm_input module. * Refactored out CDev usage from pwm_input and ll40ls. Refactored out ll40ls specifics from pwm_input and cleaned up dead code.
This commit is contained in:
@@ -40,6 +40,8 @@
|
||||
|
||||
#include "FailureDetector.hpp"
|
||||
|
||||
using namespace time_literals;
|
||||
|
||||
FailureDetector::FailureDetector(ModuleParams *parent) :
|
||||
ModuleParams(parent)
|
||||
{
|
||||
@@ -61,6 +63,10 @@ FailureDetector::update(const vehicle_status_s &vehicle_status)
|
||||
if (isAttitudeStabilized(vehicle_status)) {
|
||||
updated = updateAttitudeStatus();
|
||||
|
||||
if (_param_fd_ext_ats_en.get()) {
|
||||
updated |= updateExternalAtsStatus();
|
||||
}
|
||||
|
||||
} else {
|
||||
updated = resetStatus();
|
||||
}
|
||||
@@ -111,8 +117,8 @@ FailureDetector::updateAttitudeStatus()
|
||||
hrt_abstime time_now = hrt_absolute_time();
|
||||
|
||||
// Update hysteresis
|
||||
_roll_failure_hysteresis.set_hysteresis_time_from(false, (hrt_abstime)(1e6f * _param_fd_fail_r_ttri.get()));
|
||||
_pitch_failure_hysteresis.set_hysteresis_time_from(false, (hrt_abstime)(1e6f * _param_fd_fail_p_ttri.get()));
|
||||
_roll_failure_hysteresis.set_hysteresis_time_from(false, (hrt_abstime)(1_s * _param_fd_fail_r_ttri.get()));
|
||||
_pitch_failure_hysteresis.set_hysteresis_time_from(false, (hrt_abstime)(1_s * _param_fd_fail_p_ttri.get()));
|
||||
_roll_failure_hysteresis.set_state_and_update(roll_status, time_now);
|
||||
_pitch_failure_hysteresis.set_state_and_update(pitch_status, time_now);
|
||||
|
||||
@@ -132,3 +138,30 @@ FailureDetector::updateAttitudeStatus()
|
||||
|
||||
return updated;
|
||||
}
|
||||
|
||||
bool
|
||||
FailureDetector::updateExternalAtsStatus()
|
||||
{
|
||||
pwm_input_s pwm_input;
|
||||
bool updated = _sub_pwm_input.update(&pwm_input);
|
||||
|
||||
if (updated) {
|
||||
|
||||
uint32_t pulse_width = pwm_input.pulse_width;
|
||||
bool ats_trigger_status = (pulse_width >= (uint32_t)_param_fd_ext_ats_trig.get()) && (pulse_width < 3_ms);
|
||||
|
||||
hrt_abstime time_now = hrt_absolute_time();
|
||||
|
||||
// Update hysteresis
|
||||
_ext_ats_failure_hysteresis.set_hysteresis_time_from(false, 100_ms); // 5 consecutive pulses at 50hz
|
||||
_ext_ats_failure_hysteresis.set_state_and_update(ats_trigger_status, time_now);
|
||||
|
||||
_status &= ~FAILURE_EXT;
|
||||
|
||||
if (_ext_ats_failure_hysteresis.get_state()) {
|
||||
_status |= FAILURE_EXT;
|
||||
}
|
||||
}
|
||||
|
||||
return updated;
|
||||
}
|
||||
@@ -48,17 +48,20 @@
|
||||
#include <px4_platform_common/module_params.h>
|
||||
#include <hysteresis/hysteresis.h>
|
||||
|
||||
|
||||
// subscriptions
|
||||
#include <uORB/Subscription.hpp>
|
||||
#include <uORB/topics/vehicle_attitude_setpoint.h>
|
||||
#include <uORB/topics/vehicle_attitude.h>
|
||||
#include <uORB/topics/vehicle_status.h>
|
||||
#include <uORB/topics/pwm_input.h>
|
||||
|
||||
typedef enum {
|
||||
FAILURE_NONE = vehicle_status_s::FAILURE_NONE,
|
||||
FAILURE_ROLL = vehicle_status_s::FAILURE_ROLL,
|
||||
FAILURE_PITCH = vehicle_status_s::FAILURE_PITCH,
|
||||
FAILURE_ALT = vehicle_status_s::FAILURE_ALT,
|
||||
FAILURE_EXT = vehicle_status_s::FAILURE_EXT,
|
||||
} failure_detector_bitmak;
|
||||
|
||||
using uORB::SubscriptionData;
|
||||
@@ -79,18 +82,24 @@ private:
|
||||
(ParamInt<px4::params::FD_FAIL_P>) _param_fd_fail_p,
|
||||
(ParamInt<px4::params::FD_FAIL_R>) _param_fd_fail_r,
|
||||
(ParamFloat<px4::params::FD_FAIL_R_TTRI>) _param_fd_fail_r_ttri,
|
||||
(ParamFloat<px4::params::FD_FAIL_P_TTRI>) _param_fd_fail_p_ttri
|
||||
(ParamFloat<px4::params::FD_FAIL_P_TTRI>) _param_fd_fail_p_ttri,
|
||||
(ParamBool<px4::params::FD_EXT_ATS_EN>) _param_fd_ext_ats_en,
|
||||
(ParamInt<px4::params::FD_EXT_ATS_TRIG>) _param_fd_ext_ats_trig
|
||||
)
|
||||
|
||||
// Subscriptions
|
||||
uORB::Subscription _sub_vehicule_attitude{ORB_ID(vehicle_attitude)};
|
||||
uORB::Subscription _sub_pwm_input{ORB_ID(pwm_input)};
|
||||
|
||||
|
||||
uint8_t _status{FAILURE_NONE};
|
||||
|
||||
systemlib::Hysteresis _roll_failure_hysteresis{false};
|
||||
systemlib::Hysteresis _pitch_failure_hysteresis{false};
|
||||
systemlib::Hysteresis _ext_ats_failure_hysteresis{false};
|
||||
|
||||
bool resetStatus();
|
||||
bool isAttitudeStabilized(const vehicle_status_s &vehicle_status);
|
||||
bool updateAttitudeStatus();
|
||||
bool updateExternalAtsStatus();
|
||||
};
|
||||
|
||||
@@ -103,3 +103,27 @@ PARAM_DEFINE_FLOAT(FD_FAIL_R_TTRI, 0.3);
|
||||
* @group Failure Detector
|
||||
*/
|
||||
PARAM_DEFINE_FLOAT(FD_FAIL_P_TTRI, 0.3);
|
||||
|
||||
/**
|
||||
* Enable PWM input on AUX5 or MAIN5 (depending on board) for engaging failsafe from an external
|
||||
* automatic trigger system (ATS).
|
||||
*
|
||||
* External ATS is required by ASTM F3322-18.
|
||||
*
|
||||
* @boolean
|
||||
* @reboot_required true
|
||||
* @group Failure Detector
|
||||
*/
|
||||
PARAM_DEFINE_INT32(FD_EXT_ATS_EN, 0);
|
||||
|
||||
/**
|
||||
* The PWM threshold from external automatic trigger system for engaging failsafe.
|
||||
*
|
||||
* External ATS is required by ASTM F3322-18.
|
||||
*
|
||||
* @unit microseconds
|
||||
* @decimal 2
|
||||
*
|
||||
* @group Failure Detector
|
||||
*/
|
||||
PARAM_DEFINE_INT32(FD_EXT_ATS_TRIG, 1900);
|
||||
|
||||
Reference in New Issue
Block a user