Shop OBEX P1 Docs P2 Docs Learn Events
Saving 4 Cogs on the Propeller IMU + Kalman Filter Object — Parallax Forums

Saving 4 Cogs on the Propeller IMU + Kalman Filter Object

JoeBoticsJoeBotics Posts: 17
edited 2009-02-22 05:28 in Robotics
Hello fellow PropellerHeads!! I have been working on a balancing robot using the excellent IMU.spin object (thanks JWood!!), but I needed more cogs, so I started looking into the IMU and the KalmanFilter objects, trying to figure out a way to reduce the number of cogs, and I think I found a way to do it: if you look into the main IMU code loop, it constantly invokes the KalmanFilter routines state.update and kalman.update, but the KalmanFilter object does not have a main loop constantly running calculations, the KalmanFilter object only goes to work when invoked by IMU, so why not run the state.update and kalman.update internally in the IMU object instead? so I copied those routines into IMU, and it works!, also, the KalmanFilter object uses FloatMath.spin, created by Chip, these are a bunch of spin based Float routines, so I also copied them into the main IMU object in order to support the KalmanFilter routines, they fit nicely into IMU. Next, Float32Full is used by the IMU, and it takes two cogs (FLoat32Full uses Float32A), when you look into it, you notice that IMU uses ATan and ATan2 routines (present on Float32A), so I decided to create a limited version of Float32Full that included those routines, of course I had to remove a bunch of routines from Float32Full in order to be able to fit Atan and Atan2 + the associated routines into one cog. tricky, but I got it working.. smile.gif so:

Original cog count as follows:

IMU.spin: 1 cog
KalmanFilter.spin: 1 cog for Pitch calculations, 1 cog for Roll calculations = 2 cogs
FloatMath.spin: 1 cog ( this object was invoked by the original KalmanFilter.spin)

Total number of cogs = 4 cogs, so this object saves 3 cogs... smile.gif

The Limited version of Float32Full running on one cog saves another cog by eliminating the need for Float32A.spin for a total savings of 4 cogs.

Please email me if this information is not correct at joebotics@gmail.com

Attached are the IMU+KF object and the limited version of Float32Full....

I haven't been able to test all the routines on IMU+KF, but when I use these objects on my balancing robot it works. So I would like to validate that:

If these objects are a logical and practical approach to reducing the number of cogs on the IMU Object
If the objects really work as intended

Then for us to get together and test all the routines and fix the bugs and/or improve the objects



I hope this helps... Thanks.. Joebotics

Comments

  • Brandon NapierBrandon Napier Posts: 1
    edited 2009-02-22 05:28
    Well done friend!

    I am also building a balancing bot. I will give your code a look over and tell you if I spot something. Can you send me some pics or a link to more info on your Bot?
Sign In or Register to comment.