Implement AUTO mode for automatic flights

Support SET_ATTITUDE_TARGET, SET_ACTUATOR_CONTROL_TARGET in mavlink.
ACTUATOR_OUTPUT_STATUS is changed ACTUATOR_CONTROL_TARGET to match used message for setting motor outputs.
Add support for changing mode from mavlink.
Support automatic flights in pyflix.
This commit is contained in:
Oleg Kalachev
2025-08-28 00:49:24 +03:00
parent 10fafbc4a0
commit 40fc4b96b5
8 changed files with 181 additions and 33 deletions

View File

@@ -35,7 +35,7 @@
#define TILT_MAX radians(30)
#define RATES_D_LPF_ALPHA 0.2 // cutoff frequency ~ 40 Hz
const int MANUAL = 0, ACRO = 1, STAB = 2; // flight modes
const int MANUAL = 0, ACRO = 1, STAB = 2, AUTO = 3; // flight modes
int mode = STAB;
bool armed = false;
@@ -71,6 +71,8 @@ void interpretControls() {
if (controlMode < 0.75) mode = STAB;
if (controlMode > 0.75) mode = STAB;
if (mode == AUTO) return; // pilot is not effective in AUTO mode
if (controlThrottle < 0.05 && controlYaw > 0.95) armed = true; // arm gesture
if (controlThrottle < 0.05 && controlYaw < -0.95) armed = false; // disarm gesture
@@ -168,6 +170,7 @@ const char* getModeName() {
case MANUAL: return "MANUAL";
case ACRO: return "ACRO";
case STAB: return "STAB";
case AUTO: return "AUTO";
default: return "UNKNOWN";
}
}