From: roschler on
I'm a veteran computer programmer with a Math background that came to
a screeching halt at about the 1st semester of Calculus. However, I
think I'm wasting time implementing filtering solutions that could be
better served by a Kalman filter. Here's a recent example. I am
interfacing with a Gyroscope, that for some enigmatic reason seems to
put out, via the API call I make to its interface DLL, delta
acceleration values rather than X,Y offsets. The device seems to
throw off random noise values with a fair degree of frequency, as much
as 1 per second with readings coming in about 10 times a second. I
filter these out-of-band values by taking the standard deviation of
the last 5 readings, and replacing any that exceed a certain threshold
of standard deviation with the current mean. It works well but I
wonder if this is the kind of application that could be better served
by a Kalman filter.

There are a few open source Kalman filter implementations on the web
that I could use ( last I checked). Also, I found a "Kalman filter
for Dummies" tutorial on the web, but I still can't get a feeling
after reading it how I would use it in practice; most notably what
values I would feed it and a layman's explanation of how the Kalman
filter tunes itself to separate the noise from the hypothesized
unaffected signal so I could know how to apply the filter. Is there a
Kalman filter tutorial around that is more akin to "how you drive the
car" rather than "how you build one" that has lots of pictures?

Thanks,
Robert
From: Tim Wescott on
On 08/09/2010 07:48 AM, roschler wrote:
> I'm a veteran computer programmer with a Math background that came to
> a screeching halt at about the 1st semester of Calculus. However, I
> think I'm wasting time implementing filtering solutions that could be
> better served by a Kalman filter. Here's a recent example. I am
> interfacing with a Gyroscope, that for some enigmatic reason seems to
> put out, via the API call I make to its interface DLL, delta
> acceleration values rather than X,Y offsets. The device seems to
> throw off random noise values with a fair degree of frequency, as much
> as 1 per second with readings coming in about 10 times a second. I
> filter these out-of-band values by taking the standard deviation of
> the last 5 readings, and replacing any that exceed a certain threshold
> of standard deviation with the current mean. It works well but I
> wonder if this is the kind of application that could be better served
> by a Kalman filter.
>
> There are a few open source Kalman filter implementations on the web
> that I could use ( last I checked). Also, I found a "Kalman filter
> for Dummies" tutorial on the web, but I still can't get a feeling
> after reading it how I would use it in practice; most notably what
> values I would feed it and a layman's explanation of how the Kalman
> filter tunes itself to separate the noise from the hypothesized
> unaffected signal so I could know how to apply the filter. Is there a
> Kalman filter tutorial around that is more akin to "how you drive the
> car" rather than "how you build one" that has lots of pictures?

I hate to say this, but I don't think you're going to find such -- or at
least nothing that'll honestly help. The reason is that to some extent
the name "Kalman filter" is a misnomer. A Kalman filter isn't a
particular kind of filter -- rather, it's a filter that's designed using
a particular kind of method. Further, unless you understand what you're
doing and why, the best you can do at "Kalman filter" design is to go
through the motions, and very probably miss the mark.

Getting back to your real problem: "The device seems to throw off random
noise values with a fair degree of frequency". One likes one's noise to
have a Gaussian distribution. If you're finding outliers by comparing
data against standard deviation (and if you're doing it honestly) then
your noise is non-Gaussian -- and one of the assumptions behind a
standard Kalman filter is Gaussian noise, so the first thing you'd have
to do to get a really good filter in your case would be to re-tool the
Kalman filter math to accommodate the non-Gaussian noise!

If you haven't already, you may want take a break from asking yourself
"how can I accommodate my sensor's screwy behavior?" and instead spend a
bit of time asking yourself "can I _fix_ my sensor's screwy behavior?"

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" was written for you.
See details at http://www.wescottdesign.com/actfes/actfes.html
From: Jerry Avins on
On 8/9/2010 12:22 PM, Tim Wescott wrote:

...

> If you haven't already, you may want take a break from asking yourself
> "how can I accommodate my sensor's screwy behavior?" and instead spend a
> bit of time asking yourself "can I _fix_ my sensor's screwy behavior?"

I second that suggestion. Are you sure that the noise originates with
the gyro, and not somewhere outside the system?

Jerry
--
Engineering is the art of making what you want from things you can get.
�����������������������������������������������������������������������
From: Tim Wescott on
On 08/09/2010 09:34 AM, Jerry Avins wrote:
> On 8/9/2010 12:22 PM, Tim Wescott wrote:
>
> ...
>
>> If you haven't already, you may want take a break from asking yourself
>> "how can I accommodate my sensor's screwy behavior?" and instead spend a
>> bit of time asking yourself "can I _fix_ my sensor's screwy behavior?"
>
> I second that suggestion. Are you sure that the noise originates with
> the gyro, and not somewhere outside the system?

The best advice I ever got as a control systems engineer was when I was
still an undergrad -- "Change the plant!"

It took me about 10 years to realize the value of it.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" was written for you.
See details at http://www.wescottdesign.com/actfes/actfes.html
From: maury on
On Aug 9, 9:48 am, roschler <robert.osch...(a)gmail.com> wrote:
> I'm a veteran computer programmer with a Math background that came to
> a screeching halt at about the 1st semester of Calculus.  However, I
> think I'm wasting time implementing filtering solutions that could be
> better served by a Kalman filter.  Here's a recent example.  I am
> interfacing with a Gyroscope, that for some enigmatic reason seems to
> put out, via the API call I make to its interface DLL, delta
> acceleration values rather than X,Y offsets.  The device seems to
> throw off random noise values with a fair degree of frequency, as much
> as 1 per second with readings coming in about 10 times a second.  I
> filter these out-of-band values by taking the standard deviation of
> the last 5 readings, and replacing any that exceed a certain threshold
> of standard deviation with the current mean.  It works well but I
> wonder if this is the kind of application that could be better served
> by a Kalman filter.
>
> There are a few open source Kalman filter implementations on the web
> that I could use ( last I checked).  Also, I found a "Kalman filter
> for Dummies" tutorial on the web, but I still can't get a feeling
> after reading it how I would use it in practice; most notably what
> values I would feed it and a layman's explanation of how the Kalman
> filter tunes itself to separate the noise from the hypothesized
> unaffected signal so I could know how to apply the filter.  Is there a
> Kalman filter tutorial around that is more akin to "how you drive the
> car" rather than "how you build one" that has lots of pictures?
>
> Thanks,
> Robert

Robert,
If your noise samples are TRULY outliers, I would suggest you look at
median filters.

Maurice Givens