Skip to main content
. 2016 Jan 26;16(2):153. doi: 10.3390/s16020153
Algorithm A2
for each measured sample from the sensors do
   ωkb←gyroscope sample
  Prediction
      Predict the quaternion and the magnetic disturbance
                x^k−=[q^kbn−b^knm−]=[exp(Ω(ωk−1b)Ts)0303I3][q^k−1bn+b^k−1nm+]
      Process noise covariance matrix
                 Qk−1=[(σgTs2)2Ξ(q^k−1bn+)I3Ξ(q^k−1bn+)T04×303×4σ2b⋅I3]
  Update:
        compute R^bn−=quaternionToMatrix(q^bn−)
        yk=[ykmagykacc],ykmag←magnetometer sampleykacc←accelerometer sample
       Sensor data validation
                Racc={I3⋅σ2a, if   |yacc−R^bn−gn|<εacc∞,                        otherwise
               Rmag={I3⋅σ2m, if   |ymag−R^bn−(hn−b^knm−)|<εmag∞,                        otherwise
                R=[RmagRacc]
      Jacobian calculation
              H=[Ψ(q^kbn−,hn+b^knm−)RbnΨ(q^kbn−,gn)03]
        x^+←KalmanUpdate (x^−, Qk−1, yk, H, R)
end for