Making an ESP32-based quadcopter from scratch
Python arduinoautopilotcontrol-theorydroneesp32flight-controlflight-controllermavlinkquadcopterquadcopter-firmwareuav
Rename manual mode to raw mode Make it callable from the console. Increase the coefficient. Corresponding change in pyflix. [email protected].
Oleg Kalachev4d583185a988
diff --git a/docs/usage.md b/docs/usage.mdindex 52a3c5f..976a93b 100644--- a/docs/usage.md+++ b/docs/usage.md@@ -211,9 +211,9 @@ The default mode is *STAB*. In this mode, the drone stabilizes its attitude (oriIn this mode, the pilot controls the angular rates. This control method is difficult to fly and mostly used in FPV racing.-#### MANUAL+#### RAW-Manual mode disables all the stabilization, and the pilot inputs are passed directly to the motors. This mode is intended for testing and demonstration purposes only, and basically the drone **cannot fly in this mode**.+*RAW* mode disables all the stabilization, and the pilot inputs are mixed directly to the motors. The IMU sensor is not involved. This mode is intended for testing and demonstration purposes only, and basically the drone **cannot fly in this mode**.#### AUTOdiff --git a/flix/cli.ino b/flix/cli.inoindex 3dc93cc..b92f56d 100644--- a/flix/cli.ino+++ b/flix/cli.ino@@ -8,7 +8,7 @@#include "util.h"extern const int MOTOR_REAR_LEFT, MOTOR_REAR_RIGHT, MOTOR_FRONT_RIGHT, MOTOR_FRONT_LEFT;-extern const int ACRO, STAB, AUTO;+extern const int RAW, ACRO, STAB, AUTO;extern float t, dt, loopRate;extern uint16_t channels[16];extern float controlRoll, controlPitch, controlThrottle, controlYaw, controlMode;@@ -35,7 +35,7 @@ const char* motd ="imu - show IMU data\n""arm - arm the drone\n""disarm - disarm the drone\n"-"stab/acro/auto - set mode\n"+"raw/stab/acro/auto - set mode\n""rc - show RC data\n""wifi - show Wi-Fi info\n""mot - show motor output\n"@@ -117,6 +117,8 @@ void doCommand(String str, bool echo = false) {armed = true;} else if (command == "disarm") {armed = false;+ } else if (command == "raw") {+ mode = RAW;} else if (command == "stab") {mode = STAB;} else if (command == "acro") {diff --git a/flix/control.ino b/flix/control.inoindex 9e047d8..9018630 100644--- a/flix/control.ino+++ b/flix/control.ino@@ -34,7 +34,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, AUTO = 3; // flight modes+const int RAW = 0, ACRO = 1, STAB = 2, AUTO = 3; // flight modesint mode = STAB;bool armed = false;@@ -65,7 +65,6 @@ void control() {}void interpretControls() {- // NOTE: put ACRO or MANUAL modes there if you want to use themif (controlMode < 0.25) mode = STAB;if (controlMode < 0.75) mode = STAB;if (controlMode > 0.75) mode = STAB;@@ -93,10 +92,10 @@ void interpretControls() {ratesTarget.z = -controlYaw * maxRate.z; // positive yaw stick means clockwise rotation in FLU}- if (mode == MANUAL) { // passthrough mode+ if (mode == RAW) { // direct torque controlattitudeTarget.invalidate(); // skip attitude controlratesTarget.invalidate(); // skip rate control- torqueTarget = Vector(controlRoll, controlPitch, -controlYaw) * 0.01;+ torqueTarget = Vector(controlRoll, controlPitch, -controlYaw) * 0.1;}}@@ -157,7 +156,7 @@ void controlTorque() {const char* getModeName() {switch (mode) {- case MANUAL: return "MANUAL";+ case RAW: return "RAW";case ACRO: return "ACRO";case STAB: return "STAB";case AUTO: return "AUTO";diff --git a/tools/pyflix/flix.py b/tools/pyflix/flix.pyindex f385f5d..a12d25f 100644--- a/tools/pyflix/flix.py+++ b/tools/pyflix/flix.py@@ -40,7 +40,7 @@ class Flix:_connection_timeout = 3_print_buffer: str = ''- _modes = ['MANUAL', 'ACRO', 'STAB', 'AUTO']+ _modes = ['RAW', 'ACRO', 'STAB', 'AUTO']def __init__(self, system_id: int=1, wait_connection: bool=True):if not (0 <= system_id < 256):diff --git a/tools/pyproject.toml b/tools/pyproject.tomlindex 9c779b8..5ec9593 100644--- a/tools/pyproject.toml+++ b/tools/pyproject.toml@@ -1,6 +1,6 @@[project]name = "pyflix"-version = "0.10"+version = "0.11"description = "Python API for Flix drone"authors = [{ name="Oleg Kalachev", email="[email protected]" }]license = "MIT"