2015-06-04 00:13:34 -03:00
|
|
|
/*
|
|
|
|
additional arming checks for plane
|
|
|
|
*/
|
2017-01-09 03:56:56 -04:00
|
|
|
#include "AP_Arming.h"
|
2015-06-04 00:13:34 -03:00
|
|
|
#include "Plane.h"
|
|
|
|
|
2021-09-10 03:28:21 -03:00
|
|
|
#include "qautotune.h"
|
|
|
|
|
2020-06-16 15:52:26 -03:00
|
|
|
constexpr uint32_t AP_ARMING_DELAY_MS = 2000; // delay from arming to start of motor spoolup
|
|
|
|
|
2015-10-25 14:03:46 -03:00
|
|
|
const AP_Param::GroupInfo AP_Arming_Plane::var_info[] = {
|
2015-08-24 00:53:15 -03:00
|
|
|
// variables from parent vehicle
|
|
|
|
AP_NESTEDGROUPINFO(AP_Arming, 0),
|
|
|
|
|
2018-09-08 00:35:18 -03:00
|
|
|
// index 3 was RUDDER and should not be used
|
2015-08-24 00:53:15 -03:00
|
|
|
|
|
|
|
AP_GROUPEND
|
|
|
|
};
|
|
|
|
|
2022-08-03 09:59:38 -03:00
|
|
|
// expected to return true if the terrain database is required to have
|
|
|
|
// all data loaded
|
|
|
|
bool AP_Arming_Plane::terrain_database_required() const
|
|
|
|
{
|
|
|
|
#if AP_TERRAIN_AVAILABLE
|
|
|
|
if (plane.g.terrain_follow) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return AP_Arming::terrain_database_required();
|
|
|
|
}
|
|
|
|
|
2015-06-04 00:13:34 -03:00
|
|
|
/*
|
|
|
|
additional arming checks for plane
|
2016-11-05 20:23:32 -03:00
|
|
|
|
2015-06-04 00:13:34 -03:00
|
|
|
*/
|
2017-08-09 08:22:15 -03:00
|
|
|
bool AP_Arming_Plane::pre_arm_checks(bool display_failure)
|
2015-06-04 00:13:34 -03:00
|
|
|
{
|
2021-07-05 22:19:53 -03:00
|
|
|
if (armed || require == (uint8_t)Required::NO) {
|
|
|
|
// if we are already armed or don't need any arming checks
|
|
|
|
// then skip the checks
|
|
|
|
return true;
|
|
|
|
}
|
2019-05-05 22:16:41 -03:00
|
|
|
//are arming checks disabled?
|
2019-10-04 18:51:32 -03:00
|
|
|
if (checks_to_perform == 0) {
|
2019-05-05 22:16:41 -03:00
|
|
|
return true;
|
|
|
|
}
|
2019-04-21 22:12:12 -03:00
|
|
|
if (hal.util->was_watchdog_armed()) {
|
|
|
|
// on watchdog reset bypass arming checks to allow for
|
|
|
|
// in-flight arming if we were armed before the reset. This
|
|
|
|
// allows a reset on a BVLOS flight to return home if the
|
|
|
|
// operator can command arming over telemetry
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-06-04 00:13:34 -03:00
|
|
|
// call parent class checks
|
2017-08-09 08:22:15 -03:00
|
|
|
bool ret = AP_Arming::pre_arm_checks(display_failure);
|
2015-06-04 00:13:34 -03:00
|
|
|
|
2015-08-24 00:53:15 -03:00
|
|
|
// Check airspeed sensor
|
2017-08-09 08:22:15 -03:00
|
|
|
ret &= AP_Arming::airspeed_checks(display_failure);
|
2015-08-24 00:53:15 -03:00
|
|
|
|
2017-12-06 19:02:11 -04:00
|
|
|
if (plane.g.fs_timeout_long < plane.g.fs_timeout_short && plane.g.fs_action_short != FS_ACTION_SHORT_DISABLED) {
|
2019-10-04 18:51:32 -03:00
|
|
|
check_failed(display_failure, "FS_LONG_TIMEOUT < FS_SHORT_TIMEOUT");
|
2017-09-19 23:18:37 -03:00
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
|
2016-06-23 09:40:13 -03:00
|
|
|
if (plane.aparm.roll_limit_cd < 300) {
|
2019-10-04 18:51:32 -03:00
|
|
|
check_failed(display_failure, "LIM_ROLL_CD too small (%u)", (unsigned)plane.aparm.roll_limit_cd);
|
2017-08-09 08:22:15 -03:00
|
|
|
ret = false;
|
2015-06-04 00:13:34 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (plane.aparm.pitch_limit_max_cd < 300) {
|
2019-10-04 18:51:32 -03:00
|
|
|
check_failed(display_failure, "LIM_PITCH_MAX too small (%u)", (unsigned)plane.aparm.pitch_limit_max_cd);
|
2017-08-09 08:22:15 -03:00
|
|
|
ret = false;
|
2015-06-04 00:13:34 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (plane.aparm.pitch_limit_min_cd > -300) {
|
2019-10-04 18:51:32 -03:00
|
|
|
check_failed(display_failure, "LIM_PITCH_MIN too large (%u)", (unsigned)plane.aparm.pitch_limit_min_cd);
|
2017-08-09 08:22:15 -03:00
|
|
|
ret = false;
|
2015-06-04 00:13:34 -03:00
|
|
|
}
|
|
|
|
|
2022-09-04 20:10:01 -03:00
|
|
|
if (plane.aparm.airspeed_min < MIN_AIRSPEED_MIN) {
|
|
|
|
check_failed(display_failure, "ARSPD_FBW_MIN too low (%i < %i)", plane.aparm.airspeed_min.get(), MIN_AIRSPEED_MIN);
|
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
|
2015-06-04 00:13:34 -03:00
|
|
|
if (plane.channel_throttle->get_reverse() &&
|
2020-07-31 05:47:39 -03:00
|
|
|
Plane::ThrFailsafe(plane.g.throttle_fs_enabled.get()) != Plane::ThrFailsafe::Disabled &&
|
2015-06-04 00:13:34 -03:00
|
|
|
plane.g.throttle_fs_value <
|
ArduPlane: Fix up after refactoring RC_Channel class
Further to refactor of RC_Channel class which included
adding get_xx set_xx methods, change reads and writes to the public members
to calls to get and set functionsss
old public member(int16_t) get function -> int16_t set function (int16_t)
(expression where c is an object of type RC_Channel)
c.radio_in c.get_radio_in() c.set_radio_in(v)
c.control_in c.get_control_in() c.set_control_in(v)
c.servo_out c.get_servo_out() c.set_servo_out(v)
c.pwm_out c.get_pwm_out() // use existing
c.radio_out c.get_radio_out() c.set_radio_out(v)
c.radio_max c.get_radio_max() c.set_radio_max(v)
c.radio_min c.get_radio_min() c.set_radio_min(v)
c.radio_trim c.get_radio_trim() c.set_radio_trim(v);
c.min_max_configured() // return true if min and max are configured
Because data members of RC_Channels are now private and so cannot be written directly
some overloads are provided in the Plane classes to provide the old functionality
new overload Plane::stick_mix_channel(RC_Channel *channel)
which forwards to the previously existing
void stick_mix_channel(RC_Channel *channel, int16_t &servo_out);
new overload Plane::channel_output_mixer(Rc_Channel* , RC_Channel*)const
which forwards to
(uint8_t mixing_type, int16_t & chan1, int16_t & chan2)const;
Rename functions
RC_Channel_aux::set_radio_trim(Aux_servo_function_t function)
to RC_Channel_aux::set_trim_to_radio_in_for(Aux_servo_function_t function)
RC_Channel_aux::set_servo_out(Aux_servo_function_t function, int16_t value)
to RC_Channel_aux::set_servo_out_for(Aux_servo_function_t function, int16_t value)
Rationale:
RC_Channel is a complicated class, which combines
several functionalities dealing with stick inputs
in pwm and logical units, logical and actual actuator
outputs, unit conversion etc, etc
The intent of this PR is to clarify existing use of
the class. At the basic level it should now be possible
to grep all places where private variable is set by
searching for the set_xx function.
(The wider purpose is to provide a more generic and
logically simpler method of output mixing. This is a small step)
2016-05-08 05:33:02 -03:00
|
|
|
plane.channel_throttle->get_radio_max()) {
|
2019-10-04 18:51:32 -03:00
|
|
|
check_failed(display_failure, "Invalid THR_FS_VALUE for rev throttle");
|
2015-06-04 00:13:34 -03:00
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
|
2021-09-10 03:28:21 -03:00
|
|
|
#if HAL_QUADPLANE_ENABLED
|
2021-11-06 13:42:40 -03:00
|
|
|
ret &= quadplane_checks(display_failure);
|
2021-09-10 03:28:21 -03:00
|
|
|
#endif
|
2019-03-04 23:51:44 -04:00
|
|
|
|
2019-01-15 13:46:13 -04:00
|
|
|
if (plane.control_mode == &plane.mode_auto && plane.mission.num_commands() <= 1) {
|
2019-10-04 18:51:32 -03:00
|
|
|
check_failed(display_failure, "No mission loaded");
|
2016-02-21 12:06:43 -04:00
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
|
2016-08-12 17:02:31 -03:00
|
|
|
// check adsb avoidance failsafe
|
|
|
|
if (plane.failsafe.adsb) {
|
2019-10-04 18:51:32 -03:00
|
|
|
check_failed(display_failure, "ADSB threat detected");
|
2016-08-12 17:02:31 -03:00
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
|
2019-02-25 20:25:11 -04:00
|
|
|
if (SRV_Channels::get_emergency_stop()) {
|
2019-10-04 18:51:32 -03:00
|
|
|
check_failed(display_failure,"Motors Emergency Stopped");
|
2019-02-25 20:25:11 -04:00
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
|
2021-08-30 15:57:10 -03:00
|
|
|
if (plane.g2.flight_options & FlightOptions::CENTER_THROTTLE_TRIM){
|
|
|
|
int16_t trim = plane.channel_throttle->get_radio_trim();
|
|
|
|
if (trim < 1250 || trim > 1750) {
|
|
|
|
check_failed(display_failure, "Throttle trim not near center stick(%u)",trim );
|
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-09 20:16:47 -03:00
|
|
|
if (plane.mission.get_in_landing_sequence_flag() &&
|
|
|
|
!plane.mission.starts_with_takeoff_cmd()) {
|
2022-05-14 00:23:25 -03:00
|
|
|
check_failed(display_failure,"In landing sequence");
|
|
|
|
ret = false;
|
|
|
|
}
|
2023-02-14 08:18:09 -04:00
|
|
|
|
|
|
|
char failure_msg[50] {};
|
|
|
|
if (!plane.control_mode->pre_arm_checks(ARRAY_SIZE(failure_msg), failure_msg)) {
|
2023-02-19 18:56:18 -04:00
|
|
|
check_failed(display_failure, "%s %s", plane.control_mode->name(), failure_msg);
|
2023-02-14 08:18:09 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-06-04 00:13:34 -03:00
|
|
|
return ret;
|
|
|
|
}
|
2015-10-16 00:52:57 -03:00
|
|
|
|
2021-11-06 13:42:40 -03:00
|
|
|
#if HAL_QUADPLANE_ENABLED
|
|
|
|
bool AP_Arming_Plane::quadplane_checks(bool display_failure)
|
|
|
|
{
|
|
|
|
if (!plane.quadplane.enabled()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!plane.quadplane.available()) {
|
|
|
|
check_failed(display_failure, "Quadplane enabled but not running");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ret = true;
|
|
|
|
|
|
|
|
if (plane.scheduler.get_loop_rate_hz() < 100) {
|
|
|
|
check_failed(display_failure, "quadplane needs SCHED_LOOP_RATE >= 100");
|
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
|
2022-09-03 22:57:38 -03:00
|
|
|
char failure_msg[50] {};
|
|
|
|
if (!plane.quadplane.motors->arming_checks(ARRAY_SIZE(failure_msg), failure_msg)) {
|
|
|
|
check_failed(display_failure, "Motors: %s", failure_msg);
|
2021-11-06 13:42:40 -03:00
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// lean angle parameter check
|
|
|
|
if (plane.quadplane.aparm.angle_max < 1000 || plane.quadplane.aparm.angle_max > 8000) {
|
|
|
|
check_failed(ARMING_CHECK_PARAMETERS, display_failure, "Check Q_ANGLE_MAX");
|
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((plane.quadplane.tailsitter.enable > 0) && (plane.quadplane.tiltrotor.enable > 0)) {
|
|
|
|
check_failed(ARMING_CHECK_PARAMETERS, display_failure, "set TAILSIT_ENABLE 0 or TILT_ENABLE 0");
|
|
|
|
ret = false;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if ((plane.quadplane.tailsitter.enable > 0) && !plane.quadplane.tailsitter.enabled()) {
|
|
|
|
check_failed(ARMING_CHECK_PARAMETERS, display_failure, "tailsitter setup not complete, reboot");
|
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((plane.quadplane.tiltrotor.enable > 0) && !plane.quadplane.tiltrotor.enabled()) {
|
|
|
|
check_failed(ARMING_CHECK_PARAMETERS, display_failure, "tiltrotor setup not complete, reboot");
|
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ensure controllers are OK with us arming:
|
|
|
|
if (!plane.quadplane.pos_control->pre_arm_checks("PSC", failure_msg, ARRAY_SIZE(failure_msg))) {
|
|
|
|
check_failed(ARMING_CHECK_PARAMETERS, display_failure, "Bad parameter: %s", failure_msg);
|
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
if (!plane.quadplane.attitude_control->pre_arm_checks("ATC", failure_msg, ARRAY_SIZE(failure_msg))) {
|
|
|
|
check_failed(ARMING_CHECK_PARAMETERS, display_failure, "Bad parameter: %s", failure_msg);
|
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
|
2022-03-15 16:48:06 -03:00
|
|
|
/*
|
|
|
|
Q_ASSIST_SPEED really should be enabled for all quadplanes except tailsitters
|
|
|
|
*/
|
|
|
|
if (check_enabled(ARMING_CHECK_PARAMETERS) &&
|
|
|
|
is_zero(plane.quadplane.assist_speed) &&
|
|
|
|
!plane.quadplane.tailsitter.enabled()) {
|
|
|
|
check_failed(display_failure,"Q_ASSIST_SPEED is not set");
|
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
|
2021-11-06 13:42:40 -03:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
#endif // HAL_QUADPLANE_ENABLED
|
|
|
|
|
2017-08-09 08:22:15 -03:00
|
|
|
bool AP_Arming_Plane::ins_checks(bool display_failure)
|
2015-10-16 00:52:57 -03:00
|
|
|
{
|
|
|
|
// call parent class checks
|
2017-08-09 08:22:15 -03:00
|
|
|
if (!AP_Arming::ins_checks(display_failure)) {
|
2015-10-16 00:52:57 -03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// additional plane specific checks
|
2023-01-21 09:23:07 -04:00
|
|
|
if (check_enabled(ARMING_CHECK_INS)) {
|
2020-08-11 02:04:10 -03:00
|
|
|
char failure_msg[50] = {};
|
2021-01-21 02:24:01 -04:00
|
|
|
if (!AP::ahrs().pre_arm_check(true, failure_msg, sizeof(failure_msg))) {
|
2020-10-06 02:21:20 -03:00
|
|
|
check_failed(ARMING_CHECK_INS, display_failure, "AHRS: %s", failure_msg);
|
2015-10-16 00:52:57 -03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2019-04-21 22:12:12 -03:00
|
|
|
|
|
|
|
bool AP_Arming_Plane::arm_checks(AP_Arming::Method method)
|
|
|
|
{
|
2020-12-06 19:47:39 -04:00
|
|
|
if (method == AP_Arming::Method::RUDDER) {
|
|
|
|
const AP_Arming::RudderArming arming_rudder = get_rudder_arming_type();
|
|
|
|
|
|
|
|
if (arming_rudder == AP_Arming::RudderArming::IS_DISABLED) {
|
|
|
|
//parameter disallows rudder arming/disabling
|
|
|
|
|
|
|
|
// if we emit a message here then someone doing surface
|
|
|
|
// checks may be bothered by the message being emitted.
|
|
|
|
// check_failed(true, "Rudder arming disabled");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if throttle is not down, then pilot cannot rudder arm/disarm
|
2021-09-18 15:03:54 -03:00
|
|
|
if (!is_zero(plane.get_throttle_input())){
|
2020-12-06 19:47:39 -04:00
|
|
|
check_failed(true, "Non-zero throttle");
|
|
|
|
return false;
|
|
|
|
}
|
2021-01-21 19:28:26 -04:00
|
|
|
}
|
2020-12-06 19:47:39 -04:00
|
|
|
|
2019-05-05 22:16:41 -03:00
|
|
|
//are arming checks disabled?
|
2019-10-04 18:51:32 -03:00
|
|
|
if (checks_to_perform == 0) {
|
2019-05-05 22:16:41 -03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-04-21 22:12:12 -03:00
|
|
|
if (hal.util->was_watchdog_armed()) {
|
|
|
|
// on watchdog reset bypass arming checks to allow for
|
|
|
|
// in-flight arming if we were armed before the reset. This
|
|
|
|
// allows a reset on a BVLOS flight to return home if the
|
|
|
|
// operator can command arming over telemetry
|
|
|
|
gcs().send_text(MAV_SEVERITY_WARNING, "watchdog: Bypassing arming checks");
|
|
|
|
return true;
|
|
|
|
}
|
2019-05-04 02:44:24 -03:00
|
|
|
|
2019-04-21 22:12:12 -03:00
|
|
|
// call parent class checks
|
|
|
|
return AP_Arming::arm_checks(method);
|
|
|
|
}
|
2019-05-29 20:37:41 -03:00
|
|
|
|
|
|
|
/*
|
2019-10-04 19:42:02 -03:00
|
|
|
update HAL soft arm state
|
2019-05-29 20:37:41 -03:00
|
|
|
*/
|
|
|
|
void AP_Arming_Plane::change_arm_state(void)
|
|
|
|
{
|
|
|
|
update_soft_armed();
|
2021-09-10 03:28:21 -03:00
|
|
|
#if HAL_QUADPLANE_ENABLED
|
2023-02-10 22:36:33 -04:00
|
|
|
plane.quadplane.set_armed(is_armed_and_safety_off());
|
2021-09-10 03:28:21 -03:00
|
|
|
#endif
|
2019-05-29 20:37:41 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool AP_Arming_Plane::arm(const AP_Arming::Method method, const bool do_arming_checks)
|
|
|
|
{
|
|
|
|
if (!AP_Arming::arm(method, do_arming_checks)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-02-16 18:03:22 -04:00
|
|
|
if (plane.update_home()) {
|
|
|
|
// after update_home the home position could still be
|
|
|
|
// different from the current_loc if the EKF refused the
|
|
|
|
// resetHeightDatum call. If we are updating home then we want
|
|
|
|
// to force the home to be the current_loc so relative alt
|
|
|
|
// takeoffs work correctly
|
|
|
|
if (plane.ahrs.set_home(plane.current_loc)) {
|
|
|
|
// update current_loc
|
|
|
|
plane.update_current_loc();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-29 20:37:41 -03:00
|
|
|
change_arm_state();
|
2020-06-16 15:52:26 -03:00
|
|
|
|
|
|
|
// rising edge of delay_arming oneshot
|
|
|
|
delay_arming = true;
|
2019-05-29 20:37:41 -03:00
|
|
|
|
|
|
|
gcs().send_text(MAV_SEVERITY_INFO, "Throttle armed");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
disarm motors
|
|
|
|
*/
|
2021-01-05 20:15:48 -04:00
|
|
|
bool AP_Arming_Plane::disarm(const AP_Arming::Method method, bool do_disarm_checks)
|
2019-05-29 20:37:41 -03:00
|
|
|
{
|
2021-01-05 20:15:48 -04:00
|
|
|
if (do_disarm_checks &&
|
2022-03-06 21:39:46 -04:00
|
|
|
(method == AP_Arming::Method::MAVLINK ||
|
|
|
|
method == AP_Arming::Method::RUDDER)) {
|
2020-12-06 19:47:39 -04:00
|
|
|
if (plane.is_flying()) {
|
2022-03-06 21:39:46 -04:00
|
|
|
// don't allow mavlink or rudder disarm while flying
|
2020-12-06 19:47:39 -04:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-06 21:39:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (do_disarm_checks && method == AP_Arming::Method::RUDDER) {
|
2020-12-06 19:47:39 -04:00
|
|
|
// option must be enabled:
|
|
|
|
if (get_rudder_arming_type() != AP_Arming::RudderArming::ARMDISARM) {
|
|
|
|
gcs().send_text(MAV_SEVERITY_INFO, "Rudder disarm: disabled");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-05 20:15:48 -04:00
|
|
|
if (!AP_Arming::disarm(method, do_disarm_checks)) {
|
2019-05-29 20:37:41 -03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (plane.control_mode != &plane.mode_auto) {
|
|
|
|
// reset the mission on disarm if we are not in auto
|
|
|
|
plane.mission.reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
// suppress the throttle in auto-throttle modes
|
2020-12-23 01:25:35 -04:00
|
|
|
plane.throttle_suppressed = plane.control_mode->does_auto_throttle();
|
2019-05-29 20:37:41 -03:00
|
|
|
|
2020-07-07 21:22:56 -03:00
|
|
|
// if no airmode switch assigned, ensure airmode is off:
|
2021-09-10 03:28:21 -03:00
|
|
|
#if HAL_QUADPLANE_ENABLED
|
2021-08-22 06:29:23 -03:00
|
|
|
if ((plane.quadplane.air_mode == AirMode::ON) && (rc().find_channel_for_option(RC_Channel::AUX_FUNC::AIRMODE) == nullptr)) {
|
2020-07-07 21:22:56 -03:00
|
|
|
plane.quadplane.air_mode = AirMode::OFF;
|
|
|
|
}
|
2021-09-10 03:28:21 -03:00
|
|
|
#endif
|
2020-07-07 21:22:56 -03:00
|
|
|
|
2019-05-29 20:37:41 -03:00
|
|
|
//only log if disarming was successful
|
|
|
|
change_arm_state();
|
|
|
|
|
|
|
|
#if QAUTOTUNE_ENABLED
|
|
|
|
//save qautotune gains if enabled and success
|
|
|
|
if (plane.control_mode == &plane.mode_qautotune) {
|
|
|
|
plane.quadplane.qautotune.save_tuning_gains();
|
|
|
|
} else {
|
|
|
|
plane.quadplane.qautotune.reset();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-10-06 18:15:24 -03:00
|
|
|
// re-initialize speed variable used in AUTO and GUIDED for
|
|
|
|
// DO_CHANGE_SPEED commands
|
|
|
|
plane.new_airspeed_cm = -1;
|
|
|
|
|
2019-05-29 20:37:41 -03:00
|
|
|
gcs().send_text(MAV_SEVERITY_INFO, "Throttle disarmed");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AP_Arming_Plane::update_soft_armed()
|
|
|
|
{
|
2021-09-10 03:28:21 -03:00
|
|
|
bool _armed = is_armed();
|
|
|
|
#if HAL_QUADPLANE_ENABLED
|
|
|
|
if (plane.quadplane.motor_test.running){
|
|
|
|
_armed = true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
hal.util->set_soft_armed(_armed);
|
2019-05-29 20:37:41 -03:00
|
|
|
AP::logger().set_vehicle_armed(hal.util->get_soft_armed());
|
2020-06-16 15:52:26 -03:00
|
|
|
|
|
|
|
// update delay_arming oneshot
|
|
|
|
if (delay_arming &&
|
|
|
|
(AP_HAL::millis() - hal.util->get_last_armed_change() >= AP_ARMING_DELAY_MS)) {
|
|
|
|
|
|
|
|
delay_arming = false;
|
|
|
|
}
|
2019-05-29 20:37:41 -03:00
|
|
|
}
|
|
|
|
|
2022-03-12 02:53:58 -04:00
|
|
|
/*
|
|
|
|
extra plane mission checks
|
|
|
|
*/
|
|
|
|
bool AP_Arming_Plane::mission_checks(bool report)
|
|
|
|
{
|
|
|
|
// base checks
|
|
|
|
bool ret = AP_Arming::mission_checks(report);
|
2022-03-22 21:29:29 -03:00
|
|
|
if (plane.mission.get_landing_sequence_start() > 0 && plane.g.rtl_autoland == RtlAutoland::RTL_DISABLE) {
|
2022-03-12 02:53:58 -04:00
|
|
|
ret = false;
|
|
|
|
check_failed(ARMING_CHECK_MISSION, report, "DO_LAND_START set and RTL_AUTOLAND disabled");
|
|
|
|
}
|
2022-07-29 23:44:18 -03:00
|
|
|
#if HAL_QUADPLANE_ENABLED
|
|
|
|
if (plane.quadplane.available()) {
|
|
|
|
const uint16_t num_commands = plane.mission.num_commands();
|
|
|
|
AP_Mission::Mission_Command prev_cmd {};
|
|
|
|
for (uint16_t i=1; i<num_commands; i++) {
|
|
|
|
AP_Mission::Mission_Command cmd;
|
|
|
|
if (!plane.mission.read_cmd_from_storage(i, cmd)) {
|
|
|
|
break;
|
|
|
|
}
|
2023-01-17 02:47:03 -04:00
|
|
|
if (plane.is_land_command(cmd.id) &&
|
2022-07-29 23:44:18 -03:00
|
|
|
prev_cmd.id == MAV_CMD_NAV_WAYPOINT) {
|
|
|
|
const float dist = cmd.content.location.get_distance(prev_cmd.content.location);
|
|
|
|
const float tecs_land_speed = plane.TECS_controller.get_land_airspeed();
|
|
|
|
const float landing_speed = is_positive(tecs_land_speed)?tecs_land_speed:plane.aparm.airspeed_cruise_cm*0.01;
|
|
|
|
const float min_dist = 0.75 * plane.quadplane.stopping_distance(sq(landing_speed));
|
|
|
|
if (dist < min_dist) {
|
|
|
|
ret = false;
|
|
|
|
check_failed(ARMING_CHECK_MISSION, report, "VTOL land too short, min %.0fm", min_dist);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
prev_cmd = cmd;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2022-03-12 02:53:58 -04:00
|
|
|
return ret;
|
|
|
|
}
|