Go to Post More later, if anyone's interested and I still have homework to avoid. - Chris is me [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 Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 10-08-2013, 09:15
GuyM142's Avatar
GuyM142 GuyM142 is offline
Registered User
AKA: Guy
FRC #3339 (BumbleBee)
Team Role: Mentor
 
Join Date: Jul 2013
Rookie Year: 2012
Location: Israel
Posts: 158
GuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really nice
Measuring angle relative to the floor

Our team's robot is a climber and during the climb the chassis' angle, relative to ground is changing.
I'd like to use a sensor to measure it and eventually to use this info in order to achieve an autonomous climb.

I don't know whether to use a gyro or an accelerometer to do that.
Which of them should I use?
Reply With Quote
  #2   Spotlight this post!  
Unread 10-08-2013, 10:26
nathan_hui nathan_hui is offline
Registered User
AKA: Nathan Hui
FRC #2473 (CHS Robotics)
Team Role: Alumni
 
Join Date: Feb 2012
Rookie Year: 2009
Location: Cupertino, CA
Posts: 228
nathan_hui will become famous soon enoughnathan_hui will become famous soon enough
Send a message via AIM to nathan_hui
Re: Measuring angle relative to the floor

Accelerometer measures acceleration along three linear axis. It won't give you rotational data. A gyro will give you rotational velocity. It won't directly give you rotational data, but an integrating the gyro will. That is, of course, assuming you have the gyro aligned in the proper orientation.
__________________
Nathan Hui
B.S. Electrical Engineering, UCSD '16
FRC 2473 (CHS Robotics), Team Captain '12
FTC 4950, 6038
Reply With Quote
  #3   Spotlight this post!  
Unread 10-08-2013, 10:31
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,077
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: Measuring angle relative to the floor

Quote:
Originally Posted by nathan_hui View Post
Accelerometer measures acceleration along three linear axis. It won't give you rotational data.
If you can filter out the signal noise caused by the movement of the vehicle, it will tell you which direction gravity is pointing. And that will give you the rotational angle of the robot.


Reply With Quote
  #4   Spotlight this post!  
Unread 10-08-2013, 21:58
RyanCahoon's Avatar
RyanCahoon RyanCahoon is offline
Disassembling my prior presumptions
FRC #0766 (M-A Bears)
Team Role: Engineer
 
Join Date: Dec 2007
Rookie Year: 2007
Location: Mountain View
Posts: 689
RyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond repute
Re: Measuring angle relative to the floor

Quote:
Originally Posted by GuyM142 View Post
I'd like to use a sensor to measure [angle, relative to ground]. I don't know whether to use a gyro or an accelerometer to do that.
I think the answer is either one, though in different cases. The "best" approach would be to use both and combine the information from both sensors using a filter. This is probably overkill for what you're doing, though.

In general, over short periods of time (seconds to a couple of minutes) gyros are good sensors for measurement of angle. They're differential sensors (they only measure change in angle), though, so they suffer from two disadvantages: 1. they're susceptible to accumulated error and 2. you have to set the initial angle through some other means.

Accelerometers are somewhat complementary to gyros. As [Ether] says, you can get an absolute measure of angle relative to the local gravity vector, but this only gives a good reading when the sensor is not otherwise accelerating (practically, this means when the sensor is stationary) - under other conditions, the reading has noise introduced into the reading by the other accelerations. If the angle being measured isn't changing too quickly, and the system isn't under a constant acceleration, you can get a better measure by averaging the angle reading over time, and all the transient accelerations will more or less cancel out. This is called low-pass filtering.

Kalman filters and complementary filters work by essentially combining these two sources of data in ways that allow each to counteract the other's short-comings, creating a better estimate of the current angle.

Since you're probably only interested in tracking the angle for a few seconds and you can start with the knowledge that the robot is flat on the floor, (tl;dr) the gyro is probably the best sensor for your application.

P.S. Another approach would be to use distance sensor(s) (I would probably use infrared) pointed downwards from the bottom of your chassis to measure the distance from the ground, which you could then use to get an estimate of the robot angle.
__________________
FRC 2046, 2007-2008, Student member
FRC 1708, 2009-2012, College mentor; 2013-2014, Mentor
FRC 766, 2015-, Mentor
Reply With Quote
  #5   Spotlight this post!  
Unread 11-08-2013, 08:14
GuyM142's Avatar
GuyM142 GuyM142 is offline
Registered User
AKA: Guy
FRC #3339 (BumbleBee)
Team Role: Mentor
 
Join Date: Jul 2013
Rookie Year: 2012
Location: Israel
Posts: 158
GuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really nice
Re: Measuring angle relative to the floor

Quote:
Originally Posted by RyanCahoon View Post
I think the answer is either one, though in different cases. The "best" approach would be to use both and combine the information from both sensors using a filter. This is probably overkill for what you're doing, though.

In general, over short periods of time (seconds to a couple of minutes) gyros are good sensors for measurement of angle. They're differential sensors (they only measure change in angle), though, so they suffer from two disadvantages: 1. they're susceptible to accumulated error and 2. you have to set the initial angle through some other means.

Accelerometers are somewhat complementary to gyros. As [Ether] says, you can get an absolute measure of angle relative to the local gravity vector, but this only gives a good reading when the sensor is not otherwise accelerating (practically, this means when the sensor is stationary) - under other conditions, the reading has noise introduced into the reading by the other accelerations. If the angle being measured isn't changing too quickly, and the system isn't under a constant acceleration, you can get a better measure by averaging the angle reading over time, and all the transient accelerations will more or less cancel out. This is called low-pass filtering.

Kalman filters and complementary filters work by essentially combining these two sources of data in ways that allow each to counteract the other's short-comings, creating a better estimate of the current angle.

Since you're probably only interested in tracking the angle for a few seconds and you can start with the knowledge that the robot is flat on the floor, (tl;dr) the gyro is probably the best sensor for your application.

P.S. Another approach would be to use distance sensor(s) (I would probably use infrared) pointed downwards from the bottom of your chassis to measure the distance from the ground, which you could then use to get an estimate of the robot angle.
Thank you for the detailed answer!
I will try to do it with a gyro, and I'll try to look for some filtering guides online just to make my programming skills a bit better
Anyway, do you have some information about filters which I can start with?
Reply With Quote
  #6   Spotlight this post!  
Unread 12-08-2013, 02:54
RyanCahoon's Avatar
RyanCahoon RyanCahoon is offline
Disassembling my prior presumptions
FRC #0766 (M-A Bears)
Team Role: Engineer
 
Join Date: Dec 2007
Rookie Year: 2007
Location: Mountain View
Posts: 689
RyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond repute
Re: Measuring angle relative to the floor

Quote:
Originally Posted by GuyM142 View Post
do you have some information about filters which I can start with?
"Filter" is a general term meaning a system which does some operation on a signal. They encompass a whole sub-field of (usually) electrical engineering called signal processing, so the best I can do is point you to an introductory book to get you started, if that's what you're interested in.

Regarding complementary and Kalman filters specifically, there's a rather good white paper (pdf version) posted to CD a few years ago on complementary filters, that also includes most of what I posted above. I suggest you start here.

You can also get several good webpages that address both complementary filters and Kalman filters by Googling on complementary filters.

To quote from the white paper, though, "[Kalman filters are] mathematically complex, requiring some knowledge of linear algebra." Understanding the modern derivation of them also requires a basic understanding of multivariate probability. Assuming you're still in high school, these may be a little out of reach for you until you've taken some college courses. However, there's a fantastic online course on Udacity called "Artificial Intelligence for Robotics" that includes a lesson on Kalman filters. If you're a good math student and are feeling adventurous, try it out - it does a good job of breaking down the algorithm so it's more accessible (much more so than trying to figure out the raw equations on the Wikipedia page).

If you keep doing robotics after high school, check out Probabilistic Robotics by Thrun (who also teaches the online course I linked), Burgard, and Fox after you've gotten some college math courses under your belt. It's a great overview of techniques for state estimation in robotics from some of the leaders in the field.
__________________
FRC 2046, 2007-2008, Student member
FRC 1708, 2009-2012, College mentor; 2013-2014, Mentor
FRC 766, 2015-, Mentor
Reply With Quote
  #7   Spotlight this post!  
Unread 12-08-2013, 08:35
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,077
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: Measuring angle relative to the floor

Quote:
Originally Posted by GuyM142 View Post
do you have some information about filters which I can start with?
Here's a very simple low-pass IIR filter:

Code:
filtered_value = a*filtered_value + (1-a)*new_value
"new_value" is the new reading from the accelerometer.

"filtered_value" is the filtered version of the accelerometer reading.

"a" is a tuning constant which tunes the strength of the filter. "a" has a range of 0 to 1.

When a=0, there's no filtering -- the filtered_value always equals the accelerometer reading.

As "a" approaches 1, the filtering gets more aggressive -- the filtered_value has less noise (but more phase lag).


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 22:01.

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