Ian Hua / Quadcopter-mbedRTOS
Revision:
17:18c3bd016e49
Parent:
12:953d25061417
Child:
18:af657c4c3944
--- a/RTOS-Threads/src/Task2.cpp	Sat May 03 01:33:28 2014 +0000
+++ b/RTOS-Threads/src/Task2.cpp	Sat May 03 01:47:54 2014 +0000
@@ -15,6 +15,60 @@
 
 void Task2(void const *argument)
 {
+
+    /*
+        if (counterTask1 > 1) {
+            //yawPIDstable.setSetPoint((RCCommand[0]-1500)*9/100);
+            pitchPIDstable.setSetPoint(RCCommand[1]-1500)*9/100);
+            rollPIDstable.setSetPoint(RCCommand[2]-1500)*9/100);
+
+            //yawPIDstable.setProcessValue(ypr[0]);
+            pitchPIDstable.setProcessValue(ypr[1]);
+            rollPIDstable.setProcessValue(ypr[2]);
+
+            counterTask1 = 0;
+
+            pitch_adjust_stable = pitchPIDstable.compute();
+            roll_adjust_stable = rollPIDstable.compute();
+
+            yawPIDrate.setSetPoint((RCCommand[0]-1500)*9/100);
+            pitchPIDrate.setSetPoint(pitch_adjust_stable);
+            rollPIDrate.setSetPoint(rate_adjust_stable);
+
+            imu.getRotation(&gx, &gy, &gz);
+            gyro[0] = ((float) gx / 32.8) + 2;
+            gyro[1] = ((float) gy / 32.8);
+            gyro[2] = ((float) gz / 32.8);
+
+            yawPIDrate.setProcessValue(gyro[2]);
+            pitchPIDrate.setProcessValue(gyro[1]);
+            rollPIDrate.setProcessValue(gyro[0]);
+
+            yaw_adjust = yawPIDrate.compute();
+            pitch_adjust = pitchPIDrate.compute();
+            roll_adjust = rollPIDrate.compute();
+        } else {
+            yawPIDrate.setSetPoint((RCCommand[0]-1500)*9/100);
+            pitchPIDrate.setSetPoint((RCCommand[1]-1500)*-1*9/100);
+            rollPIDrate.setSetPoint((RCCommand[2]-1500)*9/100);
+
+            imu.getRotation(&gx, &gy, &gz);
+            gyro[0] = ((float) gx / 32.8) + 2;
+            gyro[1] = ((float) gy / 32.8);
+            gyro[2] = ((float) gz / 32.8);
+
+            yawPIDrate.setProcessValue(gyro[2]);
+            pitchPIDrate.setProcessValue(gyro[1]);
+            rollPIDrate.setProcessValue(gyro[0]);
+
+            yaw_adjust = yawPIDrate.compute();
+            pitch_adjust = pitchPIDrate.compute();
+            roll_adjust = rollPIDrate.compute();
+        }
+
+    */
+
+
     imu.getRotation(&gx, &gy, &gz);
     gyro[0] = ((float) gx / 32.8) + 2;
     gyro[1] = ((float) gy / 32.8);
@@ -32,24 +86,6 @@
     pitch_adjust = pitchPIDrate.compute();
     roll_adjust = rollPIDrate.compute();
 
-    /*
-    if (counterTask1) {
-    yawPIDstable.setSetPoint((RCCommand[0]-1500)*9/100);
-    pitchPIDstable.setSetPoint(RCCommand[1]-1500)*9/100);
-    rollPIDstable.setSetPoint(RCCommand[2]-1500)*9/100);
-
-    yawPIDstable.setProcessValue(ypr[0]);
-    pitchPIDstable.setProcessValue(ypr[1]);
-    rollPIDstable.setProcessValue(ypr[2]);
-
-    feed into ratePID();
-
-    counterTask1 = false;
-    } else {
-        rate as above
-        }
-    */
-
     counterESC = true;
 
     if (gyro_out)