Ian Hua / Quadcopter-mbedRTOS
Committer:
pHysiX
Date:
Tue Apr 29 14:53:32 2014 +0000
Revision:
3:605fbcb54e75
Parent:
2:ab967d7b4346
Child:
5:4879ef0e6d41
Fully implemented system. Need to test stability of RTOS, and to make sure that values are correct. ; Rate Mode only.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pHysiX 2:ab967d7b4346 1 /* PID */
pHysiX 2:ab967d7b4346 2
pHysiX 1:43f8ac7ca6d7 3 #include "Task2.h"
pHysiX 1:43f8ac7ca6d7 4 #include "setup.h"
pHysiX 3:605fbcb54e75 5 #include "PID.h"
pHysiX 3:605fbcb54e75 6
pHysiX 3:605fbcb54e75 7 int yaw_adjust = 0;
pHysiX 3:605fbcb54e75 8 int pitch_adjust = 0;
pHysiX 3:605fbcb54e75 9 int roll_adjust = 0;
pHysiX 3:605fbcb54e75 10
pHysiX 3:605fbcb54e75 11 int16_t gx, gy, gz;
pHysiX 1:43f8ac7ca6d7 12
pHysiX 1:43f8ac7ca6d7 13 void Task2(void const *argument)
pHysiX 1:43f8ac7ca6d7 14 {
pHysiX 3:605fbcb54e75 15 yawPIDrate.setSetPoint(RCCommand[0]);
pHysiX 3:605fbcb54e75 16 pitchPIDrate.setSetPoint(RCCommand[1]);
pHysiX 3:605fbcb54e75 17 rollPIDrate.setSetPoint(RCCommand[2]);
pHysiX 2:ab967d7b4346 18
pHysiX 3:605fbcb54e75 19 imu.getRotation(&gx, &gy, &gz);
pHysiX 3:605fbcb54e75 20 gx /= 32.8;
pHysiX 3:605fbcb54e75 21 gy /= 32.8;
pHysiX 3:605fbcb54e75 22 gz /= 32.8;
pHysiX 3:605fbcb54e75 23
pHysiX 3:605fbcb54e75 24 yawPIDrate.setProcessValue(gz);
pHysiX 3:605fbcb54e75 25 pitchPIDrate.setProcessValue(gy);
pHysiX 3:605fbcb54e75 26 rollPIDrate.setProcessValue(gz);
pHysiX 3:605fbcb54e75 27
pHysiX 3:605fbcb54e75 28 yaw_adjust = yawPIDrate.compute();
pHysiX 3:605fbcb54e75 29 pitch_adjust = pitchPIDrate.compute();
pHysiX 3:605fbcb54e75 30 roll_adjust = rollPIDrate.compute();
pHysiX 2:ab967d7b4346 31
pHysiX 2:ab967d7b4346 32 //LED[2] = !LED[2];
pHysiX 1:43f8ac7ca6d7 33 }