Making an ESP32-based quadcopter from scratch
Python arduinoautopilotcontrol-theorydroneesp32flight-controlflight-controllermavlinkquadcopterquadcopter-firmwareuav
Add argument to motor testing commands for specifying thrust
Oleg Kalachev1ae85ff11810
diff --git a/flix/cli.ino b/flix/cli.inoindex 9eaa12c..4926243 100644--- a/flix/cli.ino+++ b/flix/cli.ino@@ -51,7 +51,7 @@ const char* motd ="espnow <mac> [<key>] - configure ESP-NOW peer\n""mot - show motor output\n""log [dump] - print log header [and data]\n"-"mfr, mfl, mrr, mrl - test motor (remove props)\n"+"mfr/mfl/mrr/mrl [<thrust>] - test motor (remove props)\n""sys - show system info\n""reset - reset drone's state\n""reboot - reboot the drone\n";@@ -161,13 +161,13 @@ void doCommand(String str, bool echo = false) {} else if (command == "ca") {calibrateAccel();} else if (command == "mfr") {- testMotor(MOTOR_FRONT_RIGHT);+ testMotor(MOTOR_FRONT_RIGHT, arg0.isEmpty() ? 0.2 : arg0.toFloat());} else if (command == "mfl") {- testMotor(MOTOR_FRONT_LEFT);+ testMotor(MOTOR_FRONT_LEFT, arg0.isEmpty() ? 0.2 : arg0.toFloat());} else if (command == "mrr") {- testMotor(MOTOR_REAR_RIGHT);+ testMotor(MOTOR_REAR_RIGHT, arg0.isEmpty() ? 0.2 : arg0.toFloat());} else if (command == "mrl") {- testMotor(MOTOR_REAR_LEFT);+ testMotor(MOTOR_REAR_LEFT, arg0.isEmpty() ? 0.2 : arg0.toFloat());} else if (command == "sys") {#ifdef ESP32print("Chip: %s\n", ESP.getChipModel());diff --git a/flix/motors.ino b/flix/motors.inoindex 9654eec..6b808b1 100644--- a/flix/motors.ino+++ b/flix/motors.ino@@ -51,9 +51,9 @@ bool motorsActive() {return motors[0] != 0 || motors[1] != 0 || motors[2] != 0 || motors[3] != 0;}-void testMotor(int n) {+void testMotor(int n, float thrust) {print("Testing motor %d\n", n);- motors[n] = 0.2;+ motors[n] = thrust;delay(50); // ESP32 may need to wait until the end of the current cycle to change duty https://github.com/espressif/arduino-esp32/issues/5306sendMotors();pause(3);diff --git a/gazebo/flix.h b/gazebo/flix.hindex e0ba9ab..a6f36fb 100644--- a/gazebo/flix.h+++ b/gazebo/flix.h@@ -38,7 +38,7 @@ const char* getModeName();void sendMotors();int getDutyCycle(float value);bool motorsActive();-void testMotor(int n);+void testMotor(int, float);void print(const char* format, ...);void pause(float duration);void doCommand(String str, bool echo);