Skip to main content
. 2016 Jan 26;16(2):153. doi: 10.3390/s16020153
Algorithm A1
for each measured sample from the sensors do
   ωkbgyroscopesample
Prediction
      Predict gravity and acceleration (KFacc)
            xkacc=[g^kba^kb]=[exp([ωk1b×]Ts)0303caI3][g^k1b+a^k1b+]
      Process noise covariance matrix (KFacc)
            Qk1acc=[[g^kb×]0303cbI3][I3(σgTs)20303I3][[g^kb×]0303cbI3]T
      Predict Earth’s magnetic field and disturbances (KFmag)
            xkmag=[h^kbd^kb]=[exp([ωk1b×]Ts)0303caI3][h^k1b+d^k1b+]
      Process noise covariance matrix (KFmag)
            Qk1mag=[[h^kb×]0303cbI3][I3(σgTs)20303I3][[h^kb×]0303cbI3]T  Update:
     H=Hmag=Hacc=[I3I3]
       Measurement update (KFacc)
          ykaccaccelerometersample
          Racc=I3σ2a
        x^kacc+ KalmanUpdate (xkacc, Qk1acc, ykacc, H, Racc)
       Measurement update (KFmag)
          ykmagmagnetometersample
          Rmag=I3σ2m
         x^kmag+ KalmanUpdate (xkacc, Qk1mag, ykmag, H, Rmag)
 Orientation computation (TRIAD algorithm)
       Normalize g^kb+ and h^kb+ to one
      Mobs=[g^kb+g^kb+×h^kb+g^kb+×(g^kb+×h^kb+)]
      Mref=[gngn×hngn×(gn×hn)]
       q^kbn=matrixToQuaternion(MrefMobsT)
end for