diff --git a/libraries/AP_Vehicle/AP_Vehicle.h b/libraries/AP_Vehicle/AP_Vehicle.h index 308cde357f..6097ec5d17 100644 --- a/libraries/AP_Vehicle/AP_Vehicle.h +++ b/libraries/AP_Vehicle/AP_Vehicle.h @@ -19,6 +19,8 @@ parameters needed by multiple libraries */ +#include "ModeReason.h" // reasons can't be defined in this header due to circular loops + #include #include // board configuration library #include @@ -49,6 +51,8 @@ public: static AP_Vehicle *get_singleton(); + bool virtual set_mode(const uint8_t new_mode, const ModeReason reason) = 0; + /* common parameters for fixed wing aircraft */ diff --git a/libraries/AP_Vehicle/ModeReason.h b/libraries/AP_Vehicle/ModeReason.h new file mode 100644 index 0000000000..2ef46b684a --- /dev/null +++ b/libraries/AP_Vehicle/ModeReason.h @@ -0,0 +1,54 @@ +/* + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +#pragma once + +#include + +// interface to set the vehicles mode +enum class ModeReason : uint8_t { + UNKNOWN, + RC_COMMAND, + GCS_COMMAND, + RADIO_FAILSAFE, + BATTERY_FAILSAFE, + GCS_FAILSAFE, + EKF_FAILSAFE, + GPS_GLITCH, + MISSION_END, + THROTTLE_LAND_ESCAPE, + FENCE_BREACHED, + TERRAIN_FAILSAFE, + BRAKE_TIMEOUT, + FLIP_COMPLETE, + AVOIDANCE, + AVOIDANCE_RECOVERY, + THROW_COMPLETE, + TERMINATE, + TOY_MODE, + CRASH_FAILSAFE, + SOARING_FBW_B_WITH_MOTOR_RUNNING, + SOARING_THERMAL_DETECTED, + SOARING_THERMAL_ESTIMATE_DETERIORATED, + VTOL_FAILED_TRANSITION, + VTOL_FAILED_TAKEOFF, + FAILSAFE, // general failsafes, prefer specific failsafes over this as much as possible + INITIALISED, + SURFACE_COMPLETE, + BAD_DEPTH, + LEAK_FAILSAFE, + SERVOTEST, + STARTUP, + SCRIPTING, + UNAVAILABLE, +};