|
|
|
@ -43,6 +43,7 @@
@@ -43,6 +43,7 @@
|
|
|
|
|
|
|
|
|
|
#pragma once |
|
|
|
|
|
|
|
|
|
#include <lib/mathlib/math/filter/AlphaFilter.hpp> |
|
|
|
|
#include <matrix/matrix/math.hpp> |
|
|
|
|
#include <mathlib/mathlib.h> |
|
|
|
|
#include <px4_platform_common/module_params.h> |
|
|
|
@ -50,9 +51,11 @@
@@ -50,9 +51,11 @@
|
|
|
|
|
|
|
|
|
|
// subscriptions
|
|
|
|
|
#include <uORB/Subscription.hpp> |
|
|
|
|
#include <uORB/topics/sensor_selection.h> |
|
|
|
|
#include <uORB/topics/vehicle_attitude_setpoint.h> |
|
|
|
|
#include <uORB/topics/vehicle_attitude.h> |
|
|
|
|
#include <uORB/topics/vehicle_control_mode.h> |
|
|
|
|
#include <uORB/topics/vehicle_imu_status.h> |
|
|
|
|
#include <uORB/topics/vehicle_status.h> |
|
|
|
|
#include <uORB/topics/esc_status.h> |
|
|
|
|
#include <uORB/topics/pwm_input.h> |
|
|
|
@ -63,7 +66,10 @@ typedef enum {
@@ -63,7 +66,10 @@ typedef enum {
|
|
|
|
|
FAILURE_PITCH = vehicle_status_s::FAILURE_PITCH, |
|
|
|
|
FAILURE_ALT = vehicle_status_s::FAILURE_ALT, |
|
|
|
|
FAILURE_EXT = vehicle_status_s::FAILURE_EXT, |
|
|
|
|
FAILURE_ARM_ESCS = vehicle_status_s::FAILURE_ARM_ESC |
|
|
|
|
FAILURE_ARM_ESCS = vehicle_status_s::FAILURE_ARM_ESC, |
|
|
|
|
FAILURE_HIGH_WIND = vehicle_status_s::FAILURE_HIGH_WIND, |
|
|
|
|
FAILURE_BATTERY = vehicle_status_s::FAILURE_BATTERY, |
|
|
|
|
FAILURE_IMBALANCED_PROP = vehicle_status_s::FAILURE_IMBALANCED_PROP |
|
|
|
|
} failure_detector_bitmak; |
|
|
|
|
|
|
|
|
|
using uORB::SubscriptionData; |
|
|
|
@ -75,11 +81,13 @@ public:
@@ -75,11 +81,13 @@ public:
|
|
|
|
|
|
|
|
|
|
bool update(const vehicle_status_s &vehicle_status, const vehicle_control_mode_s &vehicle_control_mode); |
|
|
|
|
uint8_t getStatus() const { return _status; } |
|
|
|
|
float getImbalancedPropMetric() const { return _imbalanced_prop_lpf.getState(); } |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
void updateAttitudeStatus(); |
|
|
|
|
void updateExternalAtsStatus(); |
|
|
|
|
void updateEscsStatus(const vehicle_status_s &vehicle_status); |
|
|
|
|
void updateImbalancedPropStatus(); |
|
|
|
|
|
|
|
|
|
uint8_t _status{FAILURE_NONE}; |
|
|
|
|
|
|
|
|
@ -88,9 +96,16 @@ private:
@@ -88,9 +96,16 @@ private:
|
|
|
|
|
systemlib::Hysteresis _ext_ats_failure_hysteresis{false}; |
|
|
|
|
systemlib::Hysteresis _esc_failure_hysteresis{false}; |
|
|
|
|
|
|
|
|
|
static constexpr float _imbalanced_prop_lpf_time_constant{5.f}; |
|
|
|
|
AlphaFilter<float> _imbalanced_prop_lpf{}; |
|
|
|
|
uint32_t _selected_accel_device_id{0}; |
|
|
|
|
hrt_abstime _imu_status_timestamp_prev{0}; |
|
|
|
|
|
|
|
|
|
uORB::Subscription _vehicule_attitude_sub{ORB_ID(vehicle_attitude)}; |
|
|
|
|
uORB::Subscription _esc_status_sub{ORB_ID(esc_status)}; |
|
|
|
|
uORB::Subscription _pwm_input_sub{ORB_ID(pwm_input)}; |
|
|
|
|
uORB::Subscription _sensor_selection_sub{ORB_ID(sensor_selection)}; |
|
|
|
|
uORB::Subscription _vehicle_imu_status_sub{ORB_ID(vehicle_imu_status)}; |
|
|
|
|
|
|
|
|
|
DEFINE_PARAMETERS( |
|
|
|
|
(ParamInt<px4::params::FD_FAIL_P>) _param_fd_fail_p, |
|
|
|
@ -99,6 +114,7 @@ private:
@@ -99,6 +114,7 @@ private:
|
|
|
|
|
(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, |
|
|
|
|
(ParamInt<px4::params::FD_ESCS_EN>) _param_escs_en |
|
|
|
|
(ParamInt<px4::params::FD_ESCS_EN>) _param_escs_en, |
|
|
|
|
(ParamInt<px4::params::FD_IMB_PROP_THR>) _param_fd_imb_prop_thr |
|
|
|
|
) |
|
|
|
|
}; |
|
|
|
|