2016-08-17 01:28:16 -03:00
|
|
|
#include "AP_Arming.h"
|
|
|
|
#include "Rover.h"
|
|
|
|
|
2017-06-30 15:48:35 -03:00
|
|
|
// perform pre_arm_rc_checks checks
|
|
|
|
bool AP_Arming_Rover::pre_arm_rc_checks(const bool display_failure)
|
|
|
|
{
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
const RC_Channel *channels[] = {
|
|
|
|
rover.channel_steer,
|
|
|
|
rover.channel_throttle,
|
|
|
|
};
|
|
|
|
const char *channel_names[] = {"Steer", "Throttle"};
|
|
|
|
|
|
|
|
for (uint8_t i= 0 ; i < ARRAY_SIZE(channels); i++) {
|
|
|
|
const RC_Channel *channel = channels[i];
|
|
|
|
const char *channel_name = channel_names[i];
|
|
|
|
// check if radio has been calibrated
|
|
|
|
if (channel->get_radio_min() > 1300) {
|
2017-08-09 08:11:13 -03:00
|
|
|
check_failed(ARMING_CHECK_RC, display_failure, "%s radio min too high", channel_name);
|
2017-06-30 15:48:35 -03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (channel->get_radio_max() < 1700) {
|
2017-08-09 08:11:13 -03:00
|
|
|
check_failed(ARMING_CHECK_RC, display_failure, "%s radio max too low", channel_name);
|
2017-06-30 15:48:35 -03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (channel->get_radio_trim() < channel->get_radio_min()) {
|
2017-08-09 08:11:13 -03:00
|
|
|
check_failed(ARMING_CHECK_RC, display_failure, "%s radio trim below min", channel_name);
|
2017-06-30 15:48:35 -03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (channel->get_radio_trim() > channel->get_radio_max()) {
|
2017-08-09 08:11:13 -03:00
|
|
|
check_failed(ARMING_CHECK_RC, display_failure, "%s radio trim above max", channel_name);
|
2017-06-30 15:48:35 -03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2017-11-29 02:30:37 -04:00
|
|
|
|
|
|
|
// performs pre_arm gps related checks and returns true if passed
|
|
|
|
bool AP_Arming_Rover::gps_checks(bool display_failure)
|
|
|
|
{
|
2019-04-01 00:41:26 -03:00
|
|
|
const AP_AHRS &ahrs = AP::ahrs();
|
|
|
|
|
|
|
|
// always check if inertial nav has started and is ready
|
|
|
|
if (!ahrs.prearm_healthy()) {
|
|
|
|
const char *reason = ahrs.prearm_failure_reason();
|
|
|
|
if (reason == nullptr) {
|
|
|
|
reason = "AHRS not healthy";
|
|
|
|
}
|
|
|
|
check_failed(ARMING_CHECK_NONE, display_failure, "%s", reason);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-01-22 07:03:14 -04:00
|
|
|
if (!rover.control_mode->requires_position() && !rover.control_mode->requires_velocity()) {
|
2017-11-29 02:30:37 -04:00
|
|
|
// we don't care!
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-11-01 04:04:58 -03:00
|
|
|
// check for ekf failsafe
|
|
|
|
if (rover.failsafe.ekf) {
|
2019-03-06 06:20:26 -04:00
|
|
|
check_failed(ARMING_CHECK_NONE, display_failure, "EKF failsafe");
|
2018-11-01 04:04:58 -03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-12-18 06:28:20 -04:00
|
|
|
// ensure position esetimate is ok
|
|
|
|
if (!rover.ekf_position_ok()) {
|
2019-04-01 00:41:26 -03:00
|
|
|
const char *reason = ahrs.prearm_failure_reason();
|
2018-12-18 06:28:20 -04:00
|
|
|
if (reason == nullptr) {
|
|
|
|
reason = "Need Position Estimate";
|
|
|
|
}
|
|
|
|
check_failed(ARMING_CHECK_NONE, display_failure, "%s", reason);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-11-29 02:30:37 -04:00
|
|
|
// call parent gps checks
|
|
|
|
return AP_Arming::gps_checks(display_failure);
|
|
|
|
}
|
2017-12-09 02:54:47 -04:00
|
|
|
|
|
|
|
bool AP_Arming_Rover::pre_arm_checks(bool report)
|
|
|
|
{
|
2019-01-25 14:58:50 -04:00
|
|
|
if (SRV_Channels::get_emergency_stop()) {
|
2019-03-06 06:20:26 -04:00
|
|
|
check_failed(ARMING_CHECK_NONE, report, "Motors Emergency Stopped");
|
2019-01-25 14:58:50 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-08-16 07:02:56 -03:00
|
|
|
return (AP_Arming::pre_arm_checks(report)
|
|
|
|
& rover.g2.motors.pre_arm_check(report)
|
2017-08-16 07:57:42 -03:00
|
|
|
& fence_checks(report)
|
|
|
|
& proximity_check(report));
|
2017-08-16 07:02:56 -03:00
|
|
|
}
|
|
|
|
|
2017-08-16 07:57:42 -03:00
|
|
|
// check nothing is too close to vehicle
|
|
|
|
bool AP_Arming_Rover::proximity_check(bool report)
|
|
|
|
{
|
|
|
|
// return true immediately if no sensor present
|
|
|
|
if (rover.g2.proximity.get_status() == AP_Proximity::Proximity_NotConnected) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// return false if proximity sensor unhealthy
|
|
|
|
if (rover.g2.proximity.get_status() < AP_Proximity::Proximity_Good) {
|
2019-03-06 06:20:26 -04:00
|
|
|
check_failed(ARMING_CHECK_NONE, report, "check proximity sensor");
|
2017-08-16 07:57:42 -03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|