2017-02-27 17:12:56 -04:00
|
|
|
#include "AP_Arming_Sub.h"
|
|
|
|
#include "Sub.h"
|
|
|
|
|
|
|
|
enum HomeState AP_Arming_Sub::home_status() const
|
|
|
|
{
|
|
|
|
return sub.ap.home_state;
|
|
|
|
}
|
2017-03-01 00:05:51 -04:00
|
|
|
|
|
|
|
bool AP_Arming_Sub::rc_check(bool report)
|
|
|
|
{
|
|
|
|
// set rc-checks to success if RC checks are disabled
|
|
|
|
if ((checks_to_perform != ARMING_CHECK_ALL) && !(checks_to_perform & ARMING_CHECK_RC)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char* message_fail = "PreArm: Check RC min/max parameters";
|
|
|
|
bool ret = true;
|
|
|
|
|
|
|
|
// check channels 1 & 2 have min <= 1300 and max >= 1700
|
|
|
|
if (sub.channel_roll->get_radio_min() > 1300 || sub.channel_roll->get_radio_max() < 1700 || sub.channel_pitch->get_radio_min() > 1300 || sub.channel_pitch->get_radio_max() < 1700) {
|
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// check channels 3 & 4 have min <= 1300 and max >= 1700
|
|
|
|
if (sub.channel_throttle->get_radio_min() > 1300 || sub.channel_throttle->get_radio_max() < 1700 || sub.channel_yaw->get_radio_min() > 1300 || sub.channel_yaw->get_radio_max() < 1700) {
|
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// check channels 1 & 2 have trim >= 1300 and <= 1700
|
|
|
|
if (sub.channel_roll->get_radio_trim() < 1300 || sub.channel_roll->get_radio_trim() > 1700 || sub.channel_pitch->get_radio_trim() < 1300 || sub.channel_pitch->get_radio_trim() > 1700) {
|
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// check channel 4 has trim >= 1300 and <= 1700
|
|
|
|
if (sub.channel_yaw->get_radio_trim() < 1300 || sub.channel_yaw->get_radio_trim() > 1700) {
|
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (report && !ret) {
|
2017-07-08 22:51:41 -03:00
|
|
|
gcs().send_text(MAV_SEVERITY_CRITICAL, message_fail);
|
2017-03-01 00:05:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AP_Arming_Sub::pre_arm_checks(bool report)
|
|
|
|
{
|
|
|
|
if (armed) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-04-14 17:37:36 -03:00
|
|
|
return AP_Arming::pre_arm_checks(report) & rc_check(report) & ins_checks(report);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AP_Arming_Sub::ins_checks(bool report)
|
|
|
|
{
|
|
|
|
// call parent class checks
|
|
|
|
if (!AP_Arming::ins_checks(report)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// additional plane specific checks
|
|
|
|
if ((checks_to_perform & ARMING_CHECK_ALL) ||
|
|
|
|
(checks_to_perform & ARMING_CHECK_INS)) {
|
|
|
|
if (!ahrs.healthy()) {
|
|
|
|
if (report) {
|
|
|
|
const char *reason = ahrs.prearm_failure_reason();
|
|
|
|
if (reason) {
|
2017-07-09 00:57:38 -03:00
|
|
|
gcs().send_text(MAV_SEVERITY_CRITICAL, "PreArm: %s", reason);
|
2017-04-14 17:37:36 -03:00
|
|
|
} else {
|
2017-07-09 00:57:38 -03:00
|
|
|
gcs().send_text(MAV_SEVERITY_CRITICAL, "PreArm: AHRS not healthy");
|
2017-04-14 17:37:36 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2017-03-01 00:05:51 -04:00
|
|
|
}
|