calcMagAng.m 771 B

123456789101112131415161718
  1. function angMeas = calcMagAng(decl,gPhi,gPsi,gTheta,magX,magY,magZ,q0,q1,q2,q3)
  2. %CALCMAGANG
  3. % ANGMEAS = CALCMAGANG(DECL,GPHI,GPSI,GTHETA,MAGX,MAGY,MAGZ,Q0,Q1,Q2,Q3)
  4. % This function was generated by the Symbolic Math Toolbox version 5.8.
  5. % 14-Jan-2015 16:51:18
  6. % Define rotation from magnetometer to sensor using a 312 rotation sequence
  7. Tms = calcTms(gPhi,gPsi,gTheta);
  8. % Define rotation from sensor to NED
  9. Tsn = Quat2Tbn([q0;q1;q2;q3]);
  10. % Define rotation from magnetometer to NED axes
  11. Tmn = Tsn*Tms;
  12. % rotate magentic field measured at top plate into nav axes
  13. magMeasNED = Tmn*[magX;magY;magZ];
  14. % the predicted measurement is the angle wrt magnetic north of the horizontal
  15. % component of the measured field
  16. angMeas = atan2(magMeasNED(2),magMeasNED(1)) - decl;