kalman filtering

I want to know how to use kalman filter with gyro output data

You take readings from the gyro, and pass them through a kalman filter.

Surprising I know :wink:

Look at:-

.. and if that scares the life out of you, try this.

I took it from the Apple iPhone example code for using the accelerometer, so I guess it might do the trick for you.

I believe its called lossy integration.

Adjust alpha for the level of smoothing.

#define alpha 0.8

void loop()
{
static double lastX = 0;
double newX = readAccelerometerX();
double smoothX = alpha * lastX + (1 - alpha) * newX;
lastX = newX;
// ditto for the other 2 axes
}

I found it to be very effective and within my limited mathematical grasp. I tried it all out in a spreadsheet first, then used captured data from the serial monitor to get the right value of alpha.

Well that's just a very simple low pass filter calling it "lossy integration" is one of the more pretentious things I have come across this month.

Thats what the guys at Stanford call it.

I'm sure they must be devastated at the thought of you thinking them pretentious :wink:

Mike is right - that is jaw-droppingly pretentious.

As Miss Piggy would say -- Pretentions? Moi?

I just stumbled across an algorithm that worked for me to implement a low pass filter easily. Thats what it's name is. I think its quite a good name that sums up well how the algorithm works. I like names, they identify things and sometimes tell you something about the object (E.g. Grumpy Mike)

In all seriousness, I would have thought that if your noise is at a much higher frequency than the signal you are interested in, wouldn't a nice simple-to-implement low pass filter be a good recommendation for many kinds of noise reduction? Is that right, or am I being over simplistic?

I am braced for education.

wouldn't a nice simple-to-implement low pass filter be a good recommendation for many kinds of noise reduction

Yes it would, and I also suspect that will do for the original poster.

However the name "kalman filter" appears to have developed a certain mystique amongst people who know little. The essence of this sort of filter is that you know something about the underlying physical process that is going on and use that to predicted the noise less values. In this way it attempts to apply the filtering to unexpected values to filter the noise more than the signal. For example if you know your system can't change by more than an amount N between samples and you see a bigger change then you can assume that it is mainly noise.

A simple low pass filter knows nothing of the process and just apples the filtering equally to signal and noise.

Good explanation, thanks.

A Kalman Filter software named 'Visual Kalman Filter' will help you. It's nice, and it's a shareware.

Have a try.