# Alternatives to Kalmam Filter

I am currently working on a self balancing robot project. I am going to use a MPU6050 to get data from both the accelerometer and the gyroscope. Since I need to get accurate data in a very small amount of data I need to filter the raw data I get. So many people have suggested me to use the Kalman Filter but I could not comprehend it (the maths behind it). Are there any other types of filters I can use in my project?

• A complementary filter can sometimes be used in these situations.
– Paul
Commented Feb 15, 2017 at 22:14
• So you've giving up one of the best filters (i.e. it is an optimal filter ) that ever been invented just because you don't understand its math?! I don't agree with your logic yet the math of Kalman is trivial. You don't need to understand its derivation though. Commented Feb 16, 2017 at 14:23
• @CroCo you are right. But I just could not find a source that explains it well for me to comprehend. I have checked many websites. All I want to know is what I should do with the data I get from mpu.
– Huzo
Commented Feb 16, 2017 at 14:25
• Applied Optimal Estimation by Gelb is a good practical book. Commented Feb 16, 2017 at 14:26
• You don't need any sensor fusion algorithm if you have already the attitude from a sensor fusion library. The Kalman filter could be used, if you want to get (Yaw, Pitch, Roll) from (GyroX, GyroY, GyroZ, AccX, AccY, AccZ). Commented Feb 19, 2017 at 9:49

A good choice for sensor fusion with the MPU6050 is a second order complementary filter, which I used for the orientation estimation in a project. The complementary filter is computational cheap and so a good choice for a microcontroller. A paper about the implementation you can find here:

Particle filters (epecially in Monte Carlo localization) always seemed easy to intuitively understand to me. You basically simulate bunch of possible states of your robot, rank them with probabilities and occasionally you throw away the improbable ones.

There's obviously more to it (and more math), but this should be enough to make a small working test.

• Will check it out!
– Huzo
Commented Feb 16, 2017 at 9:52
• are you saying that a particle filter should be used to estimate the pitch of the robot? Commented Feb 20, 2017 at 0:49
• Should? No. It's just another tool. Particle filters could be used to estimate it. They would likely end up slower than comparable Kalman filter, but they can handle more complicated inputs and are really dead simple to visualize.
– cube
Commented Feb 20, 2017 at 21:04

Check this website pratical approach to kalman filter it will give you a comprehensive description of kalman filter for a balancing robot (like yours) both theoritical and pratical (you have the code as well). And it runs on an Arduino !

Want to get orientations from accelerometers and gyroscopes?

It has the same structure as a Kalman filter, but in place of an static gain $$K$$, it uses a full filter $$F(s)$$.