From 98f218629e582a31a7d200c4b72c508517b2ae61 Mon Sep 17 00:00:00 2001 From: franchioping Date: Mon, 13 Apr 2026 15:04:37 +0100 Subject: [PATCH] working mot --- components/DShotRMT | 2 +- main/drone.cpp | 30 +++++++----------------------- 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/components/DShotRMT b/components/DShotRMT index 262feec..4f731ed 160000 --- a/components/DShotRMT +++ b/components/DShotRMT @@ -1 +1 @@ -Subproject commit 262feec75cbc8b6de3b776b025b85fa534685e71 +Subproject commit 4f731edaead51a644270d2bf183a8a43cae33454 diff --git a/main/drone.cpp b/main/drone.cpp index 7af0f94..be64755 100644 --- a/main/drone.cpp +++ b/main/drone.cpp @@ -40,7 +40,6 @@ dcont::ControllerConfig default_config() { // Velocity Loop (Velocity -> Acceleration/Tilt) config.stack.linvel_pid = { {1.0f, 1.0f, 1.0f}, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}, 15.0f}; - // Rotation Loop (Angle -> Angular Rate) config.stack.rotation_pid = { {4.0f, 4.0f, 4.0f}, {1.0f, 1.0f, 1.0f}, {0.0f, 0.0f, 0.0f}, 50.0f}; @@ -67,10 +66,10 @@ dcont::ControllerConfig default_config() { */ float mixer[4][3] = { - {1.0f, -1.0f, 1.0f}, // Front Right - Real front - {-1.0f, -1.0f, -1.0f}, // Front Left - Real left - {-1.0f, 1.0f, 1.0f}, // Rear Left - Real rear - {1.0f, 1.0f, -1.0f} // Rear Right - Real right + {1.0f, -1.0f, 1.0f}, // Front Right + {-1.0f, -1.0f, -1.0f}, // Front Left + {-1.0f, 1.0f, 1.0f}, // Rear Left + {1.0f, 1.0f, -1.0f} // Rear Right }; for (int i = 0; i < 4; i++) { @@ -157,44 +156,29 @@ void drone_controller_task(void *params) { const gpio_num_t motor_pins[4] = {GPIO_NUM_46, GPIO_NUM_16, GPIO_NUM_14, GPIO_NUM_15}; -const bool reversed[4] = {false, true, false, false}; +// const bool reversed[4] = {false, true, false, false}; DShotRMT *motors[4]; void motor_throttles_task(void *params) { for (int i = 0; i < 4; i++) { motors[i] = new DShotRMT(motor_pins[i], DSHOT300, false); - motors[i]->begin(); - - rmt_tx_wait_all_done(motors[i]->_rmt_tx_channel, 2); - motors[i]->_cleanupRmtResources(); } // ARM unsigned long armTime = millis(); while (millis() - armTime < 5000) { for (int i = 0; i < 4; i++) { - motors[i]->begin(); motors[i]->sendThrottlePercent(0); - - rmt_tx_wait_all_done(motors[i]->_rmt_tx_channel, 2); - // delayMicroseconds(50); - motors[i]->_cleanupRmtResources(); } - // vTaskDelay(1); + vTaskDelay(1); } while (true) { for (int i = 0; i < 4; i++) { - motors[i]->begin(); - motors[i]->sendThrottlePercent(motor_throttles[i] * 100.0f); - - rmt_tx_wait_all_done(motors[i]->_rmt_tx_channel, 2); - // delayMicroseconds(50); - motors[i]->_cleanupRmtResources(); } - // vTaskDelay(1); + vTaskDelay(1); } }