PID changes
Added ID profile to PID init and new init func
This commit is contained in:
parent
0e61e0ebf2
commit
2227ab997f
@ -111,7 +111,7 @@ void pidInit();
|
||||
* BRIEF: Initializes the pid profile PID controller *
|
||||
* INFORMATION: Recommended to use if unexpected values occur of profile *
|
||||
**************************************************************************/
|
||||
void pidUAVInit(pidProfile_t *pidProfile);
|
||||
void pidUAVInit(pidProfile_t *pidProfile, uint8_t ID);
|
||||
|
||||
/**************************************************************************
|
||||
* BRIEF: Dynamic PID controller, able to handle several PID controller *
|
||||
|
@ -133,11 +133,12 @@ void getPointRate(float *desiredCommand, uint8_t ID_profile)
|
||||
* BRIEF: Initializes the pid profile PID controller *
|
||||
* INFORMATION: Recommended to use if unexpected values occur of profile *
|
||||
**************************************************************************/
|
||||
void pidUAVInit(pidProfile_t *pidProfile)
|
||||
void pidUAVInit(pidProfile_t *pidProfile, uint8_t ID)
|
||||
{
|
||||
/*This is recommended init settings*/
|
||||
pidProfile->ID_profile = 0;
|
||||
pidProfile->ID_profile = ID;
|
||||
|
||||
pidProfile->pidEnabled = true;
|
||||
pidProfile-> pidStabilisationEnabled = true;
|
||||
|
||||
pidProfile->DOF = 0;
|
||||
@ -203,10 +204,13 @@ void pidUAVInit(pidProfile_t *pidProfile)
|
||||
**************************************************************************/
|
||||
void pidInit()
|
||||
{
|
||||
pidUAVInit(&PidGyroProfile);
|
||||
pidUAVInit(&PidAccelerometerProfile);
|
||||
pidUAVInit(&PidCompassProfile);
|
||||
pidUAVInit(&PidBarometerProfile);
|
||||
|
||||
mpu6000_init(&gyroProfile,&accelProfile);
|
||||
|
||||
pidUAVInit(&PidGyroProfile, PID_ID_GYRO);
|
||||
pidUAVInit(&PidAccelerometerProfile, PID_ID_ACCELEROMETER);
|
||||
pidUAVInit(&PidCompassProfile, PID_ID_COMPASS);
|
||||
pidUAVInit(&PidBarometerProfile, PID_ID_BAROMETER);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
@ -318,15 +322,15 @@ void pidRun(uint8_t ID)
|
||||
case PID_ID_GYRO:
|
||||
|
||||
if (!PidGyroProfile.pidEnabled)
|
||||
{
|
||||
pidUAV(&PidGyroProfile);
|
||||
}
|
||||
else
|
||||
{
|
||||
PidGyroProfile.PID_Out[ROLL] = RawRcCommand.Roll;
|
||||
PidGyroProfile.PID_Out[PITCH] = RawRcCommand.Pitch;
|
||||
PidGyroProfile.PID_Out[YAW] = RawRcCommand.Yaw;
|
||||
}
|
||||
else
|
||||
{
|
||||
pidUAV(&PidGyroProfile);
|
||||
}
|
||||
|
||||
break;
|
||||
case PID_ID_ACCELEROMETER:
|
||||
|
Reference in New Issue
Block a user