2013-11-27 22:18:14 -04:00
|
|
|
/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
|
|
|
#ifndef __AP_ARMING_H__
|
|
|
|
#define __AP_ARMING_H__
|
|
|
|
|
|
|
|
#include <AP_AHRS.h>
|
|
|
|
#include <AP_HAL.h>
|
|
|
|
#include <AP_Param.h>
|
|
|
|
#include <GCS_MAVLink.h>
|
|
|
|
|
|
|
|
class AP_Arming {
|
|
|
|
public:
|
|
|
|
enum ArmingChecks {
|
|
|
|
ARMING_CHECK_NONE = 0x0000,
|
|
|
|
ARMING_CHECK_ALL = 0x0001,
|
|
|
|
ARMING_CHECK_BARO = 0x0002,
|
|
|
|
ARMING_CHECK_COMPASS = 0x0004,
|
|
|
|
ARMING_CHECK_GPS = 0x0008,
|
|
|
|
ARMING_CHECK_INS = 0x0010,
|
|
|
|
ARMING_CHECK_PARAMETERS = 0x0020,
|
|
|
|
ARMING_CHECK_RC = 0x0040,
|
|
|
|
ARMING_CHECK_VOLTAGE = 0x0080,
|
|
|
|
ARMING_CHECK_BATTERY = 0x0100,
|
2015-01-19 20:27:13 -04:00
|
|
|
ARMING_CHECK_AIRSPEED = 0x0200,
|
2015-02-06 03:38:53 -04:00
|
|
|
ARMING_CHECK_LOGGING = 0x0400,
|
2013-11-27 22:18:14 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
enum ArmingMethod {
|
|
|
|
NONE = 0,
|
|
|
|
RUDDER,
|
|
|
|
MAVLINK
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ArmingRequired {
|
2013-12-19 20:59:05 -04:00
|
|
|
NO = 0,
|
|
|
|
YES_MIN_PWM = 1,
|
|
|
|
YES_ZERO_PWM = 2
|
2013-11-27 22:18:14 -04:00
|
|
|
};
|
|
|
|
|
2015-07-23 08:44:41 -03:00
|
|
|
enum ArmingRudder {
|
|
|
|
ARMING_RUDDER_DISABLED = 0,
|
|
|
|
ARMING_RUDDER_ARMONLY = 1,
|
|
|
|
ARMING_RUDDER_ARMDISARM = 2
|
|
|
|
};
|
|
|
|
|
2015-05-24 20:24:11 -03:00
|
|
|
// for the hacky function pointer to gcs_send_text_p
|
|
|
|
FUNCTOR_TYPEDEF(gcs_send_t_p, void, gcs_severity, const prog_char_t *);
|
2013-11-27 22:18:14 -04:00
|
|
|
|
2014-07-10 10:47:59 -03:00
|
|
|
AP_Arming(const AP_AHRS &ahrs_ref, const AP_Baro &baro, Compass &compass,
|
2015-02-20 19:13:43 -04:00
|
|
|
const enum HomeState &home_set, gcs_send_t_p);
|
2013-12-11 01:09:11 -04:00
|
|
|
|
2013-12-11 02:02:25 -04:00
|
|
|
ArmingRequired arming_required();
|
2013-12-11 01:09:11 -04:00
|
|
|
bool arm(uint8_t method);
|
|
|
|
bool disarm();
|
|
|
|
bool is_armed();
|
2015-07-23 08:44:41 -03:00
|
|
|
ArmingRudder rudder_arming() const { return (ArmingRudder)rudder_arming_value.get(); }
|
2013-12-11 01:09:11 -04:00
|
|
|
uint16_t get_enabled_checks();
|
|
|
|
|
2015-06-04 00:13:03 -03:00
|
|
|
/*
|
|
|
|
pre_arm_checks() is virtual so it can be modified
|
|
|
|
in a vehicle specific subclass
|
|
|
|
*/
|
|
|
|
virtual bool pre_arm_checks(bool report);
|
2015-01-20 04:47:15 -04:00
|
|
|
void set_skip_gyro_cal(bool set) { skip_gyro_cal = set; }
|
2014-01-23 06:39:55 -04:00
|
|
|
|
2015-02-06 03:38:53 -04:00
|
|
|
void set_logging_available(bool set) { logging_available = set; }
|
|
|
|
|
2013-11-27 22:18:14 -04:00
|
|
|
//for params
|
|
|
|
static const struct AP_Param::GroupInfo var_info[];
|
|
|
|
|
2015-06-04 00:13:03 -03:00
|
|
|
protected:
|
2015-01-20 04:47:15 -04:00
|
|
|
bool armed:1;
|
2015-02-06 03:38:53 -04:00
|
|
|
bool logging_available:1;
|
2015-01-20 04:47:15 -04:00
|
|
|
bool skip_gyro_cal:1;
|
2013-11-27 22:18:14 -04:00
|
|
|
|
|
|
|
//Parameters
|
|
|
|
AP_Int8 require;
|
2015-07-23 08:44:41 -03:00
|
|
|
AP_Int8 rudder_arming_value;
|
2013-11-27 22:18:14 -04:00
|
|
|
//bitmask for which checks are required
|
|
|
|
AP_Int16 checks_to_perform;
|
|
|
|
|
|
|
|
//how the vehicle was armed
|
|
|
|
uint8_t arming_method;
|
|
|
|
|
|
|
|
const AP_AHRS &ahrs;
|
|
|
|
const AP_Baro &barometer;
|
2014-07-10 10:47:59 -03:00
|
|
|
Compass &_compass;
|
2015-02-20 19:13:43 -04:00
|
|
|
const enum HomeState &home_is_set;
|
2013-11-27 22:18:14 -04:00
|
|
|
gcs_send_t_p gcs_send_text_P;
|
2015-05-08 07:23:21 -03:00
|
|
|
uint32_t last_accel_pass_ms[INS_MAX_INSTANCES];
|
|
|
|
uint32_t last_gyro_pass_ms[INS_MAX_INSTANCES];
|
2013-11-27 22:18:14 -04:00
|
|
|
|
|
|
|
void set_enabled_checks(uint16_t);
|
|
|
|
|
2014-01-23 06:39:55 -04:00
|
|
|
bool barometer_checks(bool report);
|
2013-11-27 22:18:14 -04:00
|
|
|
|
2015-01-19 20:27:13 -04:00
|
|
|
bool airspeed_checks(bool report);
|
|
|
|
|
2015-02-06 03:38:53 -04:00
|
|
|
bool logging_checks(bool report);
|
|
|
|
|
2015-01-19 20:27:13 -04:00
|
|
|
bool ins_checks(bool report);
|
|
|
|
|
2014-01-23 06:39:55 -04:00
|
|
|
bool compass_checks(bool report);
|
2013-11-27 22:18:14 -04:00
|
|
|
|
2014-01-23 06:39:55 -04:00
|
|
|
bool gps_checks(bool report);
|
2013-11-27 22:18:14 -04:00
|
|
|
|
2014-01-23 06:39:55 -04:00
|
|
|
bool battery_checks(bool report);
|
2013-11-27 22:18:14 -04:00
|
|
|
|
2014-01-23 06:39:55 -04:00
|
|
|
bool hardware_safety_check(bool report);
|
2013-11-27 22:18:14 -04:00
|
|
|
|
2014-01-23 06:39:55 -04:00
|
|
|
bool manual_transmitter_checks(bool report);
|
2013-11-27 22:18:14 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif //__AP_ARMING_H__
|