Ian Hua / Quadcopter-mbedRTOS

RTOS-Threads/src/Task2.cpp

Committer:
pHysiX
Date:
2014-04-29
Revision:
3:605fbcb54e75
Parent:
2:ab967d7b4346
Child:
5:4879ef0e6d41

File content as of revision 3:605fbcb54e75:

/* PID */

#include "Task2.h"
#include "setup.h"
#include "PID.h"

int yaw_adjust = 0;
int pitch_adjust = 0;
int roll_adjust = 0;

int16_t gx, gy, gz;

void Task2(void const *argument)
{
    yawPIDrate.setSetPoint(RCCommand[0]);
    pitchPIDrate.setSetPoint(RCCommand[1]);
    rollPIDrate.setSetPoint(RCCommand[2]);
    
    imu.getRotation(&gx, &gy, &gz);
    gx /= 32.8;
    gy /= 32.8;
    gz /= 32.8;
    
    yawPIDrate.setProcessValue(gz);
    pitchPIDrate.setProcessValue(gy);
    rollPIDrate.setProcessValue(gz);
    
    yaw_adjust = yawPIDrate.compute();
    pitch_adjust = pitchPIDrate.compute();
    roll_adjust = rollPIDrate.compute();
    
    //LED[2] = !LED[2];
}