I'm trying to implement a kalman filter to obtain the orientation of an object, using an 3 axis accelerometer and a 3 axis gyroscope as sensors.
Choosing the dynamic model for the predict phase of this filter is straight forward, it's:
new_angle = angle + angular_velocity * time
new_angular_velocity = angular_velocity
But I do not have floating point support at hand, and I need every single bit of precision to model the angle. Therefore, my plan was to represent the angle as 32 bit integer data, representing a full turn of 2 pi
as 2^32 small steps.
As consequence, integer overflow handles the wrap (2 pi
being the same orientation as 0
) for free.
But this also poses a problem to the filter: If the estimated angle would be, say 359°
, and my measurement is 0°
, then the filter is assuming a huge innovation, leading to uncertainty and odd values.
Is there any way of making the filter aware of this possible wrap? Giving an innovation of only 1°
in the above case?
To circumvent the problem, I thought about using angle differences instead of angles, but I cannot find a suitable model.