Skip to main content
. 2016 Jan 26;16(2):153. doi: 10.3390/s16020153
Algorithm A1
for each measured sample from the sensors do
   ωkb←gyroscope sample
Prediction
      Predict gravity and acceleration (KFacc)
            xkacc−=[g^kb−a^kb−]=[exp(−[ωk−1b×]⋅Ts) 0303ca⋅I3][g^k−1b+a^k−1b+]
      Process noise covariance matrix (KFacc)
            Qk−1acc=[[g^kb−×]0303cb⋅I3][I3⋅(σgTs)20303I3] [[g^kb−×]0303cb⋅I3]T
      Predict Earth’s magnetic field and disturbances (KFmag)
            xkmag−=[h^kb−d^kb−]=[exp(−[ωk−1b×]⋅Ts) 0303ca⋅I3][h^k−1b+d^k−1b+]
      Process noise covariance matrix (KFmag)
            Qk−1mag=[[h^kb−×]0303cb⋅I3][I3⋅(σgTs)20303I3] [[h^kb−×]0303cb⋅I3]T  Update:
     H=Hmag=Hacc=[I3I3]
       Measurement update (KFacc)
          ykacc←accelerometer sample
          Racc=I3⋅σ2a
        x^kacc+← KalmanUpdate (xkacc−, Qk−1acc, ykacc, H, Racc)
       Measurement update (KFmag)
          ykmag←magnetometer sample
          Rmag=I3⋅σ2m
         x^kmag+← KalmanUpdate (xkacc−, Qk−1mag, 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