From cfa8a9d74e1d881aa24950c1e98bb0e8227af6cb Mon Sep 17 00:00:00 2001 From: Sam Hos Date: Mon, 31 Mar 2025 13:23:48 +0200 Subject: [PATCH] output finally works forgot to set standard values for controller when it's not connected --- src/drone/src/main.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/drone/src/main.cpp b/src/drone/src/main.cpp index 7e3aa50..c4e1ad7 100644 --- a/src/drone/src/main.cpp +++ b/src/drone/src/main.cpp @@ -283,10 +283,10 @@ DSM1024 DSM; // Must match the sender structure typedef struct struct_message { - int PWMCH1; - int PWMCH2; - int PWMCH3; - int PWMCH4; + int PWMCH1 = 1500; + int PWMCH2 = 1500; + int PWMCH3 = 1500; + int PWMCH4 = 1500; } struct_message; // Create a struct_message called myData @@ -477,12 +477,12 @@ void loop() // Print data at 100hz (uncomment one at a time for troubleshooting) - SELECT ONE: // printRadioData(); //Prints radio pwm values (expected: 1000 to 2000) // printDesiredState(); //Prints desired vehicle state commanded in either degrees or deg/sec (expected: +/- maxAXIS for roll, pitch, yaw; 0 to 1 for throttle) - printGyroData(); //Prints filtered gyro data direct from IMU (expected: ~ -250 to 250, 0 at rest) - printAccelData(); // Prints filtered accelerometer data direct from IMU (expected: ~ -2 to 2; x,y 0 when level, z 1 when level) + // printGyroData(); //Prints filtered gyro data direct from IMU (expected: ~ -250 to 250, 0 at rest) + // printAccelData(); // Prints filtered accelerometer data direct from IMU (expected: ~ -2 to 2; x,y 0 when level, z 1 when level) // printMagData(); //Prints filtered magnetometer data direct from IMU (expected: ~ -300 to 300) - printRollPitchYaw(); //Prints roll, pitch, and yaw angles in degrees from Madgwick filter (expected: degrees, 0 when level) - printPIDoutput(); //Prints computed stabilized PID variables from controller and desired setpoint (expected: ~ -1 to 1) - // printMotorCommands(); //Prints the values being written to the motors (expected: 120 to 250) + // printRollPitchYaw(); //Prints roll, pitch, and yaw angles in degrees from Madgwick filter (expected: degrees, 0 when level) + // printPIDoutput(); //Prints computed stabilized PID variables from controller and desired setpoint (expected: ~ -1 to 1) + printMotorCommands(); //Prints the values being written to the motors (expected: 120 to 250) // printServoCommands(); //Prints the values being written to the servos (expected: 0 to 180) // printLoopRate(); //Prints the time between loops in microseconds (expected: microseconds between loop iterations) // printDebugInfo(); //PWM 1 and 5 + Armed condition @@ -894,7 +894,7 @@ void calibrateAttitude() Madgwick(GyroX, -GyroY, -GyroZ, -AccX, AccY, AccZ, MagY, -MagX, MagZ, dt); loopRate(2000); // do not exceed 2000Hz } -} + void Madgwick(float gx, float gy, float gz, float ax, float ay, float az, float mx, float my, float mz, float invSampleFreq) {