ardupilot/APMrover2/AP_Arming.cpp

93 lines
2.9 KiB
C++
Raw Normal View History

#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) {
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) {
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()) {
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()) {
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;
}
// performs pre_arm gps related checks and returns true if passed
bool AP_Arming_Rover::gps_checks(bool display_failure)
{
if (!rover.control_mode->requires_position() && !rover.control_mode->requires_velocity()) {
// we don't care!
return true;
}
// call parent gps checks
return AP_Arming::gps_checks(display_failure);
}
bool AP_Arming_Rover::pre_arm_checks(bool report)
{
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
}
bool AP_Arming_Rover::fence_checks(bool report)
{
// check fence is initialised
const char *fail_msg = nullptr;
2018-06-25 02:26:31 -03:00
if (!rover.g2.fence.pre_arm_check(fail_msg)) {
2017-08-16 07:02:56 -03:00
if (report && fail_msg != nullptr) {
gcs().send_text(MAV_SEVERITY_CRITICAL, "PreArm: Fence : %s", fail_msg);
}
return false;
}
return true;
}
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) {
if (report) {
gcs().send_text(MAV_SEVERITY_CRITICAL,"PreArm: check proximity sensor");
}
return false;
}
return true;
}