Go to Post As usual, I mistakenly look for a technical solution to a social problem. - MrForbes [more]
Home
Go Back   Chief Delphi > Technical > Control System > Sensors
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 26-11-2011, 17:41
kearnel kearnel is offline
Registered User
FRC #2771 (Code Red Robotics)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Grand Rapids
Posts: 9
kearnel is an unknown quantity at this point
Accelerometer Filtering

I recently wired up an accelerometer/gyro board to our robot in hopes of using it to track the bot's position. The problem is that the accelerometer is giving me very noisy data and I don't know how to filter it. I've looked online and I can't find anything I can understand or use. If someone could explain a good filtering algorithm to me I'd appreciate it.

Please don't tell me it's impossible to track the bot's position using only an accelerometer and gyro because I don't plan on doing that.

Thanks
Reply With Quote
  #2   Spotlight this post!  
Unread 26-11-2011, 17:50
plnyyanks's Avatar
plnyyanks plnyyanks is offline
Data wins arguments.
AKA: Phil Lopreiato
FRC #1124 (The ÜberBots), FRC #2900 (The Mighty Penguins)
Team Role: College Student
 
Join Date: Apr 2010
Rookie Year: 2010
Location: NYC/Washington, DC
Posts: 1,113
plnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond repute
Re: Accelerometer Filtering

It depends what language you're writing your code in.

I know that in LabVIEW (my forte), there are some functions in the signal processing palate that you should look at. There's a subpalate for filtering (Signal Processing->Filters) and it has a bunch of filtering VIs you could use. I haven't personally used them, but they're there. Note that these VIs will require the entire data set as an 1D array to filter them. Since this isn't too practical for real-time filters, look at Signal Processing->Point By Point->Filters for VIs that can filter one data point at a time.
Attached Thumbnails
Click image for larger version

Name:	filters.png
Views:	170
Size:	35.0 KB
ID:	11129  
__________________
Phil Lopreiato - "It's a hardware problem"
Team 1124 (2010 - 2013), Team 1418 (2014), Team 2900 (2016)
FRC Notebook The Blue Alliance for Android
Reply With Quote
  #3   Spotlight this post!  
Unread 26-11-2011, 18:14
kearnel kearnel is offline
Registered User
FRC #2771 (Code Red Robotics)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Grand Rapids
Posts: 9
kearnel is an unknown quantity at this point
Re: Accelerometer Filtering

I'm using Java but I wouldn't mind porting code if you found some. I also wouldn't mind writing code but I don't understand how the algorithms work.

I suppose these VIs are black boxes with no viewable source code?

I don't mind a small delay either.
Reply With Quote
  #4   Spotlight this post!  
Unread 26-11-2011, 19:54
plnyyanks's Avatar
plnyyanks plnyyanks is offline
Data wins arguments.
AKA: Phil Lopreiato
FRC #1124 (The ÜberBots), FRC #2900 (The Mighty Penguins)
Team Role: College Student
 
Join Date: Apr 2010
Rookie Year: 2010
Location: NYC/Washington, DC
Posts: 1,113
plnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond repute
Re: Accelerometer Filtering

I don't think porting LV code to Java is the best approach. Instead, I'd recommend reading up on some filtering algorithms and trying to find some appropriate Java libraries.

Start by reading some wikipedia articles about different types of filters and decide how you want to approach your filtering. Then, search for some packages that you might be able to use.

Maybe someone with some experience with Java programming might be able to help you out a little better
__________________
Phil Lopreiato - "It's a hardware problem"
Team 1124 (2010 - 2013), Team 1418 (2014), Team 2900 (2016)
FRC Notebook The Blue Alliance for Android
Reply With Quote
  #5   Spotlight this post!  
Unread 27-11-2011, 21:50
kearnel kearnel is offline
Registered User
FRC #2771 (Code Red Robotics)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Grand Rapids
Posts: 9
kearnel is an unknown quantity at this point
Re: Accelerometer Filtering

I've been reading and trying to understand these algorithms but it appears that I need to understand calculus. I can't find anything that I can understand.

Edit: I'm wondering If there are any websites that explain filtering without using crazy-looking math to do it.

Last edited by kearnel : 27-11-2011 at 22:04.
Reply With Quote
  #6   Spotlight this post!  
Unread 27-11-2011, 23:59
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,025
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Accelerometer Filtering


Quote:
Originally Posted by kearnel View Post
I've been reading and trying to understand these algorithms but it appears that I need to understand calculus. I can't find anything that I can understand.

Edit: I'm wondering If there are any websites that explain filtering without using crazy-looking math to do it.
Here's a very very simple "hello world" low-pass filter that will reduce noise (but also introduce delay):

new_filtered_value = f*previous_filtered_value + (1-f)*newly_read_value;

f is a tuning parameter between 0 and 1.

when f is zero, you get no filtering:

new_filtered_value = newly_read_value;

as you increase f from 0 towards 1, the filtering gets more aggressive.



Reply With Quote
  #7   Spotlight this post!  
Unread 28-11-2011, 12:53
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,559
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Accelerometer Filtering

Quote:
Originally Posted by kearnel View Post
I've been reading and trying to understand these algorithms but it appears that I need to understand calculus. I can't find anything that I can understand.

Edit: I'm wondering If there are any websites that explain filtering without using crazy-looking math to do it.
You are correct that the types of filters that you will likely want to use do use calculus. They are typically introduced in upper division college classes, and covered in detail in graduate classes. Do you have any mentors with an electrical engineering or controls degree?

Filtering is very much dependent on the application. So far all you've told us is that you want to use the accelerometer for positioning, but you aren't using it for positioning. That makes it very hard to help. Filtering is a tradeoff between complexity (processing power), how well it keeps what you want, and how well it's able to reject what you don't want. Ether's filter is fairly simple filter that I've used before. It's very simple as far as processing, and is adjustable which is helpful. However it won't match the performance of a more complicated filter (which may or may not be necessary).

The advantage of using LabVIEW is the instant visualization of the data (besides the large number of built in filters). You can play around with the filters without understanding the math until you find a filter (and the coefficients) that work for your data. I would start with a Butterworth filter. Without the math background, all you'd be doing is copying code, so you'd be better off finding something already implemented. You can probably find a java implementation of a Butterworth filter.

For determining position with multiple sensors, a Kalman filter is probably what you really need, but that's several orders of magnitude harder then a Butterworth filter. I've seen several threads on chiefdelphi where people talked about them, but I'm not sure that anyone's successfully implemented one for a FIRST robot.
Reply With Quote
  #8   Spotlight this post!  
Unread 28-11-2011, 14:57
EricVanWyk EricVanWyk is offline
Registered User
no team
 
Join Date: Jan 2007
Rookie Year: 2000
Location: Boston
Posts: 1,597
EricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond repute
Send a message via AIM to EricVanWyk
Re: Accelerometer Filtering

Quote:
Originally Posted by kearnel View Post
I've been reading and trying to understand these algorithms but it appears that I need to understand calculus. I can't find anything that I can understand.

Edit: I'm wondering If there are any websites that explain filtering without using crazy-looking math to do it.
Designing filters takes advanced math, but using and understanding them doesn't.

Your best bet will be to find a mentor who can explain it to you. One-on-one, this will take a good 30-45 minutes provided a 10th grade math background. One-to-many takes a lot longer.

You should also install LabVIEW and play with the filters. Looking at input to output visually while tweaking parameters is remarkably helpful. I usually give my students a half hour of playing with that palette, and it really helps solidify my droning at the white board.
Reply With Quote
  #9   Spotlight this post!  
Unread 13-01-2012, 01:08
Sparks333's Avatar
Sparks333 Sparks333 is offline
Robotics Engineer
AKA: Dane B.
FRC #1425 (Wilsonville Robotics)
Team Role: Alumni
 
Join Date: Feb 2004
Rookie Year: 2003
Location: Wilsonville, Oregon
Posts: 184
Sparks333 is a glorious beacon of lightSparks333 is a glorious beacon of lightSparks333 is a glorious beacon of lightSparks333 is a glorious beacon of lightSparks333 is a glorious beacon of lightSparks333 is a glorious beacon of light
Send a message via AIM to Sparks333
Re: Accelerometer Filtering

Really, most filters designs don't require calculus. If you want to do something like a Kalman, it does require a bit of differential equations, but I wouldn't recommend using something like that anyway. All you need to know is a few basic pieces of information - passband frequency and stopband frequency. An accelerometer will have most of its interesting information at around DC, so you'll be wanting a lowpass filter. The easiest filter you can implement is called a finite-impulse response filter (FIR), which, in discrete terms, means all you do is a multi-tap filter like Ether recommended (his is a two-tap filter, but you can realistically have as many taps as you want - the more taps you have the more it will reject higher frequencies [sharper rolloff]). There are ways to set the coefficients of each tap to favor older values over newer (that is the function of Ether's f parameter) or vice-versa, but from experience you can make it work with a a simple boxcar averaging algorithm - every tap has the same coefficient, and they all add to 1.

Looking at the beginning post, though, I do worry slightly - what you propose is to record the robot's location based on gyro and accelerometer readings. I cannot stress enough that this is incredibly difficult, especially for any extended period of time. The best you can do is robot attitude. For anything along those lines, you will actually probably want to use a Kalman, but that's a huge amount of work.

I hope this is helpful.

Sparks
__________________
ICs do weird things when voltage is run out of spec.

I love to take things apart. The fact that they work better when I put them back together it just a bonus.

http://www.ravenblack.net/random/surreal.html
Reply With Quote
  #10   Spotlight this post!  
Unread 13-01-2012, 07:31
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,025
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Accelerometer Filtering

Quote:
Originally Posted by Sparks333 View Post
The easiest filter you can implement is called a finite-impulse response filter (FIR), which, in discrete terms, means all you do is a multi-tap filter like Ether recommended
Actually, the one I posted is IIR (infinite impulse response)

Reply With Quote
  #11   Spotlight this post!  
Unread 13-01-2012, 13:39
Sparks333's Avatar
Sparks333 Sparks333 is offline
Robotics Engineer
AKA: Dane B.
FRC #1425 (Wilsonville Robotics)
Team Role: Alumni
 
Join Date: Feb 2004
Rookie Year: 2003
Location: Wilsonville, Oregon
Posts: 184
Sparks333 is a glorious beacon of lightSparks333 is a glorious beacon of lightSparks333 is a glorious beacon of lightSparks333 is a glorious beacon of lightSparks333 is a glorious beacon of lightSparks333 is a glorious beacon of light
Send a message via AIM to Sparks333
Re: Accelerometer Filtering

Right you are - missed the previous_filtered_value, read it as previous_read_value.

Sparks
__________________
ICs do weird things when voltage is run out of spec.

I love to take things apart. The fact that they work better when I put them back together it just a bonus.

http://www.ravenblack.net/random/surreal.html
Reply With Quote
  #12   Spotlight this post!  
Unread 31-12-2012, 14:40
StephenNutt StephenNutt is offline
Registered User
FRC #0172 (Falgor)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Falmouth, ME
Posts: 37
StephenNutt is an unknown quantity at this point
Re: Accelerometer Filtering

Try using an Alpha-Beta filter, see http://en.wikipedia.org/wiki/Alpha_beta_filter

It is very simple to implement, so simple for my team I've created a simple Excel spreadsheet that takes a series a data points, the alpha and beta values, and plots the raw and filtered values in a graph. I can then adjust the alpha and beta values in Excel and view the changes in real time until I see the results I like and then plug those into the robot.

Steve
Reply With Quote
  #13   Spotlight this post!  
Unread 06-02-2013, 09:24
ekapalka's Avatar
ekapalka ekapalka is offline
Registered User
FRC #3216
 
Join Date: Dec 2012
Location: Bermuda
Posts: 277
ekapalka has a spectacular aura aboutekapalka has a spectacular aura about
Re: Accelerometer Filtering

Have you considered a moving average? It accumulates the last x number of data samples in an array and finds the average of them in real time. We wrote one for our rangefinders, but it should apply to just about anything. It's only about sixteen lines of code (with five curly brackets, making it more like 11 lines of functional code). We're programming in C++, but syntactically it's almost the same.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 08:04.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi