|
|
|
@ -14,6 +14,7 @@
@@ -14,6 +14,7 @@
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
#include "AP_Arming.h" |
|
|
|
|
#include <AP_HAL/AP_HAL.h> |
|
|
|
|
#include <AP_BoardConfig/AP_BoardConfig.h> |
|
|
|
|
#include <AP_BattMonitor/AP_BattMonitor.h> |
|
|
|
|
#include <AP_Notify/AP_Notify.h> |
|
|
|
@ -23,6 +24,17 @@
@@ -23,6 +24,17 @@
|
|
|
|
|
#include <AP_Rally/AP_Rally.h> |
|
|
|
|
#include <SRV_Channel/SRV_Channel.h> |
|
|
|
|
|
|
|
|
|
#if HAL_WITH_UAVCAN |
|
|
|
|
#include <AP_BoardConfig/AP_BoardConfig_CAN.h> |
|
|
|
|
#include <AP_Common/AP_Common.h> |
|
|
|
|
#include <AP_Vehicle/AP_Vehicle.h> |
|
|
|
|
|
|
|
|
|
// To be replaced with macro saying if KDECAN library is included
|
|
|
|
|
#if APM_BUILD_TYPE(APM_BUILD_ArduCopter) || APM_BUILD_TYPE(APM_BUILD_ArduPlane) || APM_BUILD_TYPE(APM_BUILD_ArduSub) |
|
|
|
|
#include <AP_KDECAN/AP_KDECAN.h> |
|
|
|
|
#endif |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
#define AP_ARMING_COMPASS_MAGFIELD_EXPECTED 530 |
|
|
|
|
#define AP_ARMING_COMPASS_MAGFIELD_MIN 185 // 0.35 * 530 milligauss
|
|
|
|
|
#define AP_ARMING_COMPASS_MAGFIELD_MAX 875 // 1.65 * 530 milligauss
|
|
|
|
@ -635,6 +647,44 @@ bool AP_Arming::system_checks(bool report)
@@ -635,6 +647,44 @@ bool AP_Arming::system_checks(bool report)
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool AP_Arming::can_checks(bool report) |
|
|
|
|
{ |
|
|
|
|
#if HAL_WITH_UAVCAN |
|
|
|
|
if (check_enabled(ARMING_CHECK_SYSTEM)) { |
|
|
|
|
const char *fail_msg = nullptr; |
|
|
|
|
uint8_t num_drivers = AP::can().get_num_drivers(); |
|
|
|
|
|
|
|
|
|
for (uint8_t i = 0; i < num_drivers; i++) { |
|
|
|
|
switch (AP::can().get_protocol_type(i)) { |
|
|
|
|
case AP_BoardConfig_CAN::Protocol_Type_KDECAN: { |
|
|
|
|
// To be replaced with macro saying if KDECAN library is included
|
|
|
|
|
#if APM_BUILD_TYPE(APM_BUILD_ArduCopter) || APM_BUILD_TYPE(APM_BUILD_ArduPlane) || APM_BUILD_TYPE(APM_BUILD_ArduSub) |
|
|
|
|
AP_KDECAN *ap_kdecan = AP_KDECAN::get_kdecan(i); |
|
|
|
|
if (ap_kdecan != nullptr && !ap_kdecan->pre_arm_check(fail_msg)) { |
|
|
|
|
if (fail_msg == nullptr) { |
|
|
|
|
check_failed(ARMING_CHECK_SYSTEM, report, "KDECAN failed"); |
|
|
|
|
} else { |
|
|
|
|
check_failed(ARMING_CHECK_SYSTEM, report, "%s", fail_msg); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
#else |
|
|
|
|
UNUSED_RESULT(fail_msg); // prevent unused variable error
|
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
case AP_BoardConfig_CAN::Protocol_Type_UAVCAN: |
|
|
|
|
case AP_BoardConfig_CAN::Protocol_Type_None: |
|
|
|
|
default: |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool AP_Arming::pre_arm_checks(bool report) |
|
|
|
|
{ |
|
|
|
|
#if !APM_BUILD_TYPE(APM_BUILD_ArduCopter) |
|
|
|
@ -656,7 +706,8 @@ bool AP_Arming::pre_arm_checks(bool report)
@@ -656,7 +706,8 @@ bool AP_Arming::pre_arm_checks(bool report)
|
|
|
|
|
& mission_checks(report) |
|
|
|
|
& servo_checks(report) |
|
|
|
|
& board_voltage_checks(report) |
|
|
|
|
& system_checks(report); |
|
|
|
|
& system_checks(report) |
|
|
|
|
& can_checks(report); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool AP_Arming::arm_checks(ArmingMethod method) |
|
|
|
|