123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- #pragma once
- #include <AP_Param/AP_Param.h>
- #include <AP_Common/AP_Common.h>
- #include <AP_Relay/AP_Relay.h>
- #define AP_PARACHUTE_TRIGGER_TYPE_RELAY_0 0
- #define AP_PARACHUTE_TRIGGER_TYPE_RELAY_1 1
- #define AP_PARACHUTE_TRIGGER_TYPE_RELAY_2 2
- #define AP_PARACHUTE_TRIGGER_TYPE_RELAY_3 3
- #define AP_PARACHUTE_TRIGGER_TYPE_SERVO 10
- #define AP_PARACHUTE_RELEASE_DELAY_MS 500
- #define AP_PARACHUTE_RELEASE_DURATION_MS 2000
- #define AP_PARACHUTE_SERVO_ON_PWM_DEFAULT 1300
- #define AP_PARACHUTE_SERVO_OFF_PWM_DEFAULT 1100
- #define AP_PARACHUTE_ALT_MIN_DEFAULT 10
- #define AP_PARACHUTE_CRITICAL_SINK_DEFAULT 0
- class AP_Parachute {
- public:
-
- AP_Parachute(AP_Relay &relay)
- : _relay(relay)
- {
-
- #if CONFIG_HAL_BOARD == HAL_BOARD_SITL
- if (_singleton != nullptr) {
- AP_HAL::panic("Rally must be singleton");
- }
- #endif
- _singleton = this;
- AP_Param::setup_object_defaults(this, var_info);
- }
-
- AP_Parachute(const AP_Parachute &other) = delete;
- AP_Parachute &operator=(const AP_Parachute&) = delete;
-
- void enabled(bool on_off);
-
- bool enabled() const { return _enabled; }
-
- void release();
-
- bool released() const { return _released; }
-
-
- bool release_initiated() const { return _release_initiated; }
-
- bool release_in_progress() const { return _release_in_progress; }
-
-
- void update();
-
-
- float critical_sink() const { return _critical_sink; }
-
-
- int16_t alt_min() const { return _alt_min; }
-
- void set_is_flying(const bool is_flying) { _is_flying = is_flying; }
-
- void set_sink_rate(float sink_rate) { _sink_rate = sink_rate; }
- static const struct AP_Param::GroupInfo var_info[];
-
- static AP_Parachute *get_singleton() { return _singleton; }
- private:
- static AP_Parachute *_singleton;
-
- AP_Int8 _enabled;
- AP_Int8 _release_type;
- AP_Int16 _servo_on_pwm;
- AP_Int16 _servo_off_pwm;
- AP_Int16 _alt_min;
- AP_Int16 _delay_ms;
- AP_Float _critical_sink;
-
- AP_Relay &_relay;
- uint32_t _release_time;
- bool _release_initiated:1;
- bool _release_in_progress:1;
- bool _released:1;
- bool _is_flying:1;
- float _sink_rate;
- uint32_t _sink_time;
- };
- namespace AP {
- AP_Parachute *parachute();
- };
|