DSPRelated.com
Forums

Rate-gyro and compass: Kalman filter

Started by Marco Trapanese May 27, 2009
Tim Wescott ha scritto:


> Convenient, simple -- and damned subtle and hard to wrap your brain > around: > > Use the fact that integers wrap to your advantage. It's the only time > you'll be able to, so revel in it. > > If you're programming in C, on a machine that uses 2's compliment > arithmetic, then INT_MAX will equal 2^(N-1) - 1, where N is the word > width in bits. INT_MIN will equal exactly -2^(N-1). So map your angles > into integers such that INT_MIN represents -180 degrees. Then -- as if > by magic -- you'll find that +179 degrees + 1 degree = -180 degrees.
Tim, I understand how much I have to learn!
> Now _carefully_ arrange your filter: > > y_t = y_t + (x_t - y_t) / factor. > > This is a first-order low-pass with a pole at 1 - 1/factor. What's cool > about it is that (on all of the machines that I've encountered) the x_t - > y_t term wraps, so it always finds the shortest path between the state > and the target.
Very, very interesting.
> Try it, You'll like it. Hopefully this will get you started -- I'm sure > this can be extended to 2nd-order filters, but you'll have to use a more > state-space approach rather than looking up bilinear filters in a cook > book.
By the way, may you suggest me a good book about digital filters that presents both theory and C code? Thanks Marco