2015-06-18 07:45:33 -03:00
|
|
|
// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
|
|
|
#include "Plane.h"
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
call parachute library update
|
|
|
|
*/
|
|
|
|
void Plane::parachute_check()
|
|
|
|
{
|
|
|
|
parachute.update();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
parachute_release - trigger the release of the parachute
|
|
|
|
*/
|
|
|
|
void Plane::parachute_release()
|
|
|
|
{
|
|
|
|
if (parachute.released()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// send message to gcs and dataflash
|
2015-10-24 19:36:35 -03:00
|
|
|
gcs_send_text(MAV_SEVERITY_CRITICAL,"Parachute: Released");
|
2015-06-18 07:45:33 -03:00
|
|
|
|
|
|
|
// release parachute
|
|
|
|
parachute.release();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
parachute_manual_release - trigger the release of the parachute,
|
|
|
|
after performing some checks for pilot error checks if the vehicle
|
|
|
|
is landed
|
|
|
|
*/
|
2015-10-27 01:17:13 -03:00
|
|
|
bool Plane::parachute_manual_release()
|
2015-06-18 07:45:33 -03:00
|
|
|
{
|
|
|
|
// exit immediately if parachute is not enabled
|
|
|
|
if (!parachute.enabled() || parachute.released()) {
|
2015-10-27 01:17:13 -03:00
|
|
|
return false;
|
2015-06-18 07:45:33 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
// do not release if vehicle is not flying
|
|
|
|
if (!is_flying()) {
|
|
|
|
// warn user of reason for failure
|
2015-11-18 15:17:50 -04:00
|
|
|
gcs_send_text(MAV_SEVERITY_WARNING,"Parachute: Not flying");
|
2015-10-27 01:17:13 -03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (relative_altitude() < parachute.alt_min()) {
|
2015-11-18 15:17:50 -04:00
|
|
|
gcs_send_text_fmt(MAV_SEVERITY_WARNING, "Parachute: Too low");
|
2015-10-27 01:17:13 -03:00
|
|
|
return false;
|
2015-06-18 07:45:33 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
// if we get this far release parachute
|
|
|
|
parachute_release();
|
2015-10-27 01:17:13 -03:00
|
|
|
|
|
|
|
return true;
|
2015-06-18 07:45:33 -03:00
|
|
|
}
|