Browse Source

AP_Parachute: move responsibility for parachute deployment up

master
Peter Barker 6 years ago committed by Randy Mackay
parent
commit
005ec5cd4d
  1. 19
      libraries/AP_Parachute/AP_Parachute.cpp
  2. 14
      libraries/AP_Parachute/AP_Parachute.h

19
libraries/AP_Parachute/AP_Parachute.cpp

@ -5,6 +5,8 @@ @@ -5,6 +5,8 @@
#include <SRV_Channel/SRV_Channel.h>
#include <AP_Notify/AP_Notify.h>
#include <AP_HAL/AP_HAL.h>
#include <AP_Logger/AP_Logger.h>
#include <GCS_MAVLink/GCS.h>
extern const AP_HAL::HAL& hal;
@ -70,6 +72,8 @@ void AP_Parachute::enabled(bool on_off) @@ -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() @@ -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() @@ -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();
}
}

14
libraries/AP_Parachute/AP_Parachute.h

@ -30,6 +30,12 @@ public: @@ -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: @@ -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: @@ -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();
};

Loading…
Cancel
Save