From 005ec5cd4d3b316143cc4babdfd7b5d3b979a2e1 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Sat, 2 Feb 2019 08:48:19 +1100 Subject: [PATCH] AP_Parachute: move responsibility for parachute deployment up --- libraries/AP_Parachute/AP_Parachute.cpp | 19 +++++++++++++++++++ libraries/AP_Parachute/AP_Parachute.h | 14 ++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/libraries/AP_Parachute/AP_Parachute.cpp b/libraries/AP_Parachute/AP_Parachute.cpp index c2f1606fac9..e792571f147 100644 --- a/libraries/AP_Parachute/AP_Parachute.cpp +++ b/libraries/AP_Parachute/AP_Parachute.cpp @@ -5,6 +5,8 @@ #include #include #include +#include +#include extern const AP_HAL::HAL& hal; @@ -70,6 +72,8 @@ void AP_Parachute::enabled(bool on_off) // clear release_time _release_time = 0; + + AP::logger().Write_Event(_enabled ? DATA_PARACHUTE_ENABLED : DATA_PARACHUTE_DISABLED); } /// release - release parachute @@ -80,6 +84,9 @@ void AP_Parachute::release() return; } + gcs().send_text(MAV_SEVERITY_INFO,"Parachute: Released"); + AP::logger().Write_Event(DATA_PARACHUTE_RELEASED); + // set release time to current system time if (_release_time == 0) { _release_time = AP_HAL::millis(); @@ -131,3 +138,15 @@ void AP_Parachute::update() AP_Notify::flags.parachute_release = 0; } } + +// singleton instance +AP_Parachute *AP_Parachute::_singleton; + +namespace AP { + +AP_Parachute *parachute() +{ + return AP_Parachute::get_singleton(); +} + +} diff --git a/libraries/AP_Parachute/AP_Parachute.h b/libraries/AP_Parachute/AP_Parachute.h index 38b4cd82de3..7d4378112f4 100644 --- a/libraries/AP_Parachute/AP_Parachute.h +++ b/libraries/AP_Parachute/AP_Parachute.h @@ -30,6 +30,12 @@ public: : _relay(relay) { // setup parameter defaults +#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); } @@ -64,7 +70,11 @@ public: static const struct AP_Param::GroupInfo var_info[]; + // get singleton instance + static AP_Parachute *get_singleton() { return _singleton; } + private: + static AP_Parachute *_singleton; // Parameters AP_Int8 _enabled; // 1 if parachute release is enabled AP_Int8 _release_type; // 0:Servo,1:Relay @@ -80,3 +90,7 @@ private: bool _release_in_progress:1; // true if the parachute release is in progress bool _released:1; // true if the parachute has been released }; + +namespace AP { + AP_Parachute *parachute(); +};