|
|
@ -78,8 +78,8 @@ void Drift_correction(void) |
|
|
|
|
|
|
|
|
|
|
|
//*****YAW*************** |
|
|
|
//*****YAW*************** |
|
|
|
// We make the gyro YAW drift correction based on compass magnetic heading |
|
|
|
// We make the gyro YAW drift correction based on compass magnetic heading |
|
|
|
#if (MAGNETOMETER==1) |
|
|
|
#if (MAGNETOMETER) |
|
|
|
errorCourse= (DCM_Matrix[0][0]*APM_Compass.Heading_X) - (DCM_Matrix[1][0]*APM_Compass.Heading_Y); //Calculating YAW error |
|
|
|
errorCourse= (DCM_Matrix[0][0]*APM_Compass.Heading_Y) - (DCM_Matrix[1][0]*APM_Compass.Heading_X); //Calculating YAW error |
|
|
|
Vector_Scale(errorYaw,&DCM_Matrix[2][0],errorCourse); //Applys the yaw correction to the XYZ rotation of the aircraft, depeding the position. |
|
|
|
Vector_Scale(errorYaw,&DCM_Matrix[2][0],errorCourse); //Applys the yaw correction to the XYZ rotation of the aircraft, depeding the position. |
|
|
|
|
|
|
|
|
|
|
|
Vector_Scale(&Scaled_Omega_P[0],&errorYaw[0],Kp_YAW); |
|
|
|
Vector_Scale(&Scaled_Omega_P[0],&errorYaw[0],Kp_YAW); |
|
|
@ -113,8 +113,6 @@ void Matrix_update(void) |
|
|
|
Accel_Vector[1]=Accel_Vector[1]*0.4 + (float)read_adc(4)*0.6; // acc y |
|
|
|
Accel_Vector[1]=Accel_Vector[1]*0.4 + (float)read_adc(4)*0.6; // acc y |
|
|
|
Accel_Vector[2]=Accel_Vector[2]*0.4 + (float)read_adc(5)*0.6; // acc z |
|
|
|
Accel_Vector[2]=Accel_Vector[2]*0.4 + (float)read_adc(5)*0.6; // acc z |
|
|
|
|
|
|
|
|
|
|
|
Accel_Vector[1]=0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Vector_Add(&Omega[0], &Gyro_Vector[0], &Omega_I[0]);//adding integrator |
|
|
|
Vector_Add(&Omega[0], &Gyro_Vector[0], &Omega_I[0]);//adding integrator |
|
|
|
Vector_Add(&Omega_Vector[0], &Omega[0], &Omega_P[0]);//adding proportional |
|
|
|
Vector_Add(&Omega_Vector[0], &Omega[0], &Omega_P[0]);//adding proportional |
|
|
|
|
|
|
|
|
|
|
|