AP_Arming: integrate visual odometry pre_arm_check

This commit is contained in:
Randy Mackay 2020-03-30 12:30:20 +09:00
parent 9a32e8208f
commit 1b1687f43d
2 changed files with 27 additions and 1 deletions

View File

@ -36,6 +36,7 @@
#include <AP_Camera/AP_RunCam.h> #include <AP_Camera/AP_RunCam.h>
#include <AP_GyroFFT/AP_GyroFFT.h> #include <AP_GyroFFT/AP_GyroFFT.h>
#include <AP_RCMapper/AP_RCMapper.h> #include <AP_RCMapper/AP_RCMapper.h>
#include <AP_VisualOdom/AP_VisualOdom.h>
#if HAL_WITH_UAVCAN #if HAL_WITH_UAVCAN
#include <AP_BoardConfig/AP_BoardConfig_CAN.h> #include <AP_BoardConfig/AP_BoardConfig_CAN.h>
@ -115,7 +116,7 @@ const AP_Param::GroupInfo AP_Arming::var_info[] = {
// @Description: Checks prior to arming motor. This is a bitmask of checks that will be performed before allowing arming. The default is no checks, allowing arming at any time. You can select whatever checks you prefer by adding together the values of each check type to set this parameter. For example, to only allow arming when you have GPS lock and no RC failsafe you would set ARMING_CHECK to 72. For most users it is recommended that you set this to 1 to enable all checks. // @Description: Checks prior to arming motor. This is a bitmask of checks that will be performed before allowing arming. The default is no checks, allowing arming at any time. You can select whatever checks you prefer by adding together the values of each check type to set this parameter. For example, to only allow arming when you have GPS lock and no RC failsafe you would set ARMING_CHECK to 72. For most users it is recommended that you set this to 1 to enable all checks.
// @Values: 0:None,1:All,2:Barometer,4:Compass,8:GPS Lock,16:INS(INertial Sensors - accels & gyros),32:Parameters(unused),64:RC Channels,128:Board voltage,256:Battery Level,1024:LoggingAvailable,2048:Hardware safety switch,4096:GPS configuration,8192:System,16384:Mission,32768:RangeFinder,65536:Camera,131072:AuxAuth // @Values: 0:None,1:All,2:Barometer,4:Compass,8:GPS Lock,16:INS(INertial Sensors - accels & gyros),32:Parameters(unused),64:RC Channels,128:Board voltage,256:Battery Level,1024:LoggingAvailable,2048:Hardware safety switch,4096:GPS configuration,8192:System,16384:Mission,32768:RangeFinder,65536:Camera,131072:AuxAuth
// @Values{Plane}: 0:None,1:All,2:Barometer,4:Compass,8:GPS Lock,16:INS(INertial Sensors - accels & gyros),32:Parameters(unused),64:RC Channels,128:Board voltage,256:Battery Level,512:Airspeed,1024:LoggingAvailable,2048:Hardware safety switch,4096:GPS configuration,8192:System,16384:Mission,32768:RangeFinder,65536:Camera,131072:AuxAuth // @Values{Plane}: 0:None,1:All,2:Barometer,4:Compass,8:GPS Lock,16:INS(INertial Sensors - accels & gyros),32:Parameters(unused),64:RC Channels,128:Board voltage,256:Battery Level,512:Airspeed,1024:LoggingAvailable,2048:Hardware safety switch,4096:GPS configuration,8192:System,16384:Mission,32768:RangeFinder,65536:Camera,131072:AuxAuth
// @Bitmask: 0:All,1:Barometer,2:Compass,3:GPS lock,4:INS,5:Parameters,6:RC Channels,7:Board voltage,8:Battery Level,10:Logging Available,11:Hardware safety switch,12:GPS Configuration,13:System,14:Mission,15:Rangefinder,16:Camera,17:AuxAuth // @Bitmask: 0:All,1:Barometer,2:Compass,3:GPS lock,4:INS,5:Parameters,6:RC Channels,7:Board voltage,8:Battery Level,10:Logging Available,11:Hardware safety switch,12:GPS Configuration,13:System,14:Mission,15:Rangefinder,16:Camera,17:AuxAuth,18:VisualOdometry
// @Bitmask{Plane}: 0:All,1:Barometer,2:Compass,3:GPS lock,4:INS,5:Parameters,6:RC Channels,7:Board voltage,8:Battery Level,9:Airspeed,10:Logging Available,11:Hardware safety switch,12:GPS Configuration,13:System,14:Mission,15:Rangefinder,16:Camera,17:AuxAuth // @Bitmask{Plane}: 0:All,1:Barometer,2:Compass,3:GPS lock,4:INS,5:Parameters,6:RC Channels,7:Board voltage,8:Battery Level,9:Airspeed,10:Logging Available,11:Hardware safety switch,12:GPS Configuration,13:System,14:Mission,15:Rangefinder,16:Camera,17:AuxAuth
// @User: Standard // @User: Standard
AP_GROUPINFO("CHECK", 8, AP_Arming, checks_to_perform, ARMING_CHECK_ALL), AP_GROUPINFO("CHECK", 8, AP_Arming, checks_to_perform, ARMING_CHECK_ALL),
@ -1053,6 +1054,7 @@ bool AP_Arming::pre_arm_checks(bool report)
& can_checks(report) & can_checks(report)
& proximity_checks(report) & proximity_checks(report)
& camera_checks(report) & camera_checks(report)
& visodom_checks(report)
& aux_auth_checks(report); & aux_auth_checks(report);
} }
@ -1193,6 +1195,27 @@ bool AP_Arming::rc_checks_copter_sub(const bool display_failure, const RC_Channe
return ret; return ret;
} }
// check visual odometry is working
bool AP_Arming::visodom_checks(bool display_failure) const
{
if ((checks_to_perform != ARMING_CHECK_ALL) && !(checks_to_perform & ARMING_CHECK_VISION)) {
return true;
}
#if HAL_VISUALODOM_ENABLED
AP_VisualOdom *visual_odom = AP::visualodom();
if (visual_odom != nullptr) {
char fail_msg[MAVLINK_MSG_STATUSTEXT_FIELD_TEXT_LEN+1];
if (!visual_odom->pre_arm_check(fail_msg, ARRAY_SIZE(fail_msg))) {
check_failed(ARMING_CHECK_VISION, display_failure, "VisualOdom: %s", fail_msg);
return false;
}
}
#endif
return true;
}
void AP_Arming::Log_Write_Arm(const bool forced, const AP_Arming::Method method) void AP_Arming::Log_Write_Arm(const bool forced, const AP_Arming::Method method)
{ {
const struct log_Arm_Disarm pkt { const struct log_Arm_Disarm pkt {

View File

@ -35,6 +35,7 @@ public:
ARMING_CHECK_RANGEFINDER = (1U << 15), ARMING_CHECK_RANGEFINDER = (1U << 15),
ARMING_CHECK_CAMERA = (1U << 16), ARMING_CHECK_CAMERA = (1U << 16),
ARMING_CHECK_AUX_AUTH = (1U << 17), ARMING_CHECK_AUX_AUTH = (1U << 17),
ARMING_CHECK_VISION = (1U << 18),
}; };
enum class Method { enum class Method {
@ -173,6 +174,8 @@ protected:
bool servo_checks(bool report) const; bool servo_checks(bool report) const;
bool rc_checks_copter_sub(bool display_failure, const RC_Channel *channels[4]) const; bool rc_checks_copter_sub(bool display_failure, const RC_Channel *channels[4]) const;
bool visodom_checks(bool report) const;
// mandatory checks that cannot be bypassed. This function will only be called if ARMING_CHECK is zero or arming forced // mandatory checks that cannot be bypassed. This function will only be called if ARMING_CHECK is zero or arming forced
virtual bool mandatory_checks(bool report) { return true; } virtual bool mandatory_checks(bool report) { return true; }