Go to Post Welcome to FIRST, the place where you can be competitive in a team. Here people can learn more in one year of FIRST than in four years of high school. - dude__hi [more]
Home
Go Back   Chief Delphi > Other > Math and Science
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 04-04-2010, 21:22
Luke Pike's Avatar
Luke Pike Luke Pike is offline
Programmer
FRC #1501 (THRUST)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2008
Location: Huntington
Posts: 114
Luke Pike is a name known to allLuke Pike is a name known to allLuke Pike is a name known to allLuke Pike is a name known to allLuke Pike is a name known to allLuke Pike is a name known to all
Using antiderivative to find velocity from acceleration

I have a quick question.

Last week my calculus class started teaching antiderivatives. If there is a function A(t) which gives acceleration as a function of time, then it's antiderivative is a function V(t) which gives velocity as a function of time (the antiderivative of that would be position), plus a constant C of course.

Now suppose we have an accelerometer sensor on a robot. If I can take the numerical antiderivative (if I can even do that), would that give me the velocity of the robot at that time (assuming the robot started off not moving)?
__________________
Twitter Profile
Reply With Quote
  #2   Spotlight this post!  
Unread 04-04-2010, 21:37
Chris Hibner's Avatar Unsung FIRST Hero
Chris Hibner Chris Hibner is offline
Eschewing Obfuscation Since 1990
AKA: Lars Kamen's Roadie
FRC #0051 (Wings of Fire)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1997
Location: Canton, MI
Posts: 1,488
Chris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond repute
Re: Using antiderivative to find velocity from acceleration

Quote:
Originally Posted by Luke Pike View Post
I have a quick question.

Last week my calculus class started teaching antiderivatives. If there is a function A(t) which gives acceleration as a function of time, then it's antiderivative is a function V(t) which gives velocity as a function of time (the antiderivative of that would be position), plus a constant C of course.

Now suppose we have an accelerometer sensor on a robot. If I can take the numerical antiderivative (if I can even do that), would that give me the velocity of the robot at that time (assuming the robot started off not moving)?
Yes, you can easily calculate the velocity from the acceleration. You do the exact same thing when you use a "gyro" on the robot to calculate your heading (the "gyro" actually is an angular velocity sensor, and you calculate the angle via the antiderivative (more accurately called an "integral").

To calculate an integral (i.e. anti-derivative) in software you do the following:

velocity = velocity + acceleration*sample_time;

You perform the above calculation over and over at a fast rate. "sample_time" is the time since the last time you took an acceleration reading.
__________________
-
An ounce of perception is worth a pound of obscure.
Reply With Quote
  #3   Spotlight this post!  
Unread 04-04-2010, 22:02
Mr. Lim Mr. Lim is offline
Registered User
AKA: Mr. Lim
no team
Team Role: Leadership
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Toronto, Ontario
Posts: 1,125
Mr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond repute
Re: Using antiderivative to find velocity from acceleration

Quote:
Originally Posted by Luke Pike View Post
I have a quick question.

Last week my calculus class started teaching antiderivatives. If there is a function A(t) which gives acceleration as a function of time, then it's antiderivative is a function V(t) which gives velocity as a function of time (the antiderivative of that would be position), plus a constant C of course.

Now suppose we have an accelerometer sensor on a robot. If I can take the numerical antiderivative (if I can even do that), would that give me the velocity of the robot at that time (assuming the robot started off not moving)?
Great question... here's the 1 minute answer, but note that this is meant to get you started - there is MUCH MUCH more detail regarding these (numerical) methods that I won't get to touch on.

If you are given an accelerometer, and let's say it gives you values in m/s^2, you certainly can easily calculate the definite anti-derivative (integral) of acceleration to give you velocity.

How?

Read the accelerometer periodically, and keep adding your readings to a "counter." For example, start your counter at 0 (this is actually your C value), and start reading your accelerometer every 1s.

Let's say the first reading you get is 10m/s^2. Add the value 10 to your counter, and it turns out this counter will represent your velocity.

1 second later, let's say your next reading is again 10m/s^2. Add the value 10 to your counter which should now be 20. That makes sense, because if you've been accelerating at 10m/s^2 for 2 seconds, you'll be moving at 20m/s.

1 second later, let's say your next reading is -5m/s^2. Add the value to your counter, which should now be 15. You're moving at about 15m/s.

It turns out, velocity is simply the sum of all your acceleration readings. You also have to adjust the values a bit depending on how often you are reading your accelerometer, but I'll leave that for you to figure out - it's not too difficult. This method is adding up values into a counter is called "accumulation" and it shows up all over the place, and is one of the most basic forms of numerical integration.

Now if you were wondering, if you created ANOTHER counter, and used that counter to add up the values from you first counter described above, you would be performing a DOUBLE integral, and would actually get your robot's POSITION.

Before other posters jump on me, it turns out the method I mentioned above is very inaccurate. You will get a lot of "drift" and over time your velocity will no longer match up. There are a number of ways to improve on it, but chances are another poster will jump in and expand on that.

(waiting for someone to deliver an amazing 3rd year numerical methods lecture below)
__________________
In life, what you give, you keep. What you fail to give, you lose forever...

Last edited by Mr. Lim : 04-04-2010 at 22:13.
Reply With Quote
  #4   Spotlight this post!  
Unread 04-04-2010, 22:46
Luke Pike's Avatar
Luke Pike Luke Pike is offline
Programmer
FRC #1501 (THRUST)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2008
Location: Huntington
Posts: 114
Luke Pike is a name known to allLuke Pike is a name known to allLuke Pike is a name known to allLuke Pike is a name known to allLuke Pike is a name known to allLuke Pike is a name known to all
Re: Using antiderivative to find velocity from acceleration

Thanks for the answers. I figured it was a little more involved in practice. I was just excited that something I was learning in calculus could be applied to something I've been meaning to try in robotics!

Thanks again, I'll have to look into some of the methods you guys described, looking forward to it!
__________________
Twitter Profile
Reply With Quote
  #5   Spotlight this post!  
Unread 05-04-2010, 03:51
eugenebrooks eugenebrooks is offline
Team Role: Engineer
AKA: Dr. Brooks
no team (WRRF)
 
Join Date: Jan 2004
Rookie Year: 2001
Location: Livermore, CA
Posts: 601
eugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond repute
Re: Using antiderivative to find velocity from acceleration

See an old 2005 white paper titled:
An Introduction to C Programming for FIRST Robotics Applications

An Introduction to C Programming for FIRST Robotics Applicatyions [SP]

It describes a second on integration of a gyro, using second order
accuracy and careful subtraction of the average at rest in order to
obtain a low drift angular position. You could go further by adding
temperature compensation. The code is for the old control system.
You could do the same with an accelerometer to get velocity, but
the pulse rate of wheel counters would provide much better results.
Integrating a second time, using the relatively poor acceleration
measurements, would not produce very useful results, but I'll
resist going into that.

An issue with doing this on the cRIO is getting an accurate time
interval between measurements. There may be a suitable system
call to provide the time to sufficient accuracy.

Eugene

Last edited by eugenebrooks : 05-04-2010 at 03:54.
Reply With Quote
  #6   Spotlight this post!  
Unread 06-04-2010, 21:09
DonRotolo's Avatar
DonRotolo DonRotolo is offline
Back to humble
FRC #0832
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Atlanta GA
Posts: 6,979
DonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond repute
Re: Using antiderivative to find velocity from acceleration

Quote:
Originally Posted by Luke Pike View Post
I was just excited that something I was learning in calculus could be applied to something I've been meaning to try in robotics!
For me, not being shown practical applications for all that math was the most frustrating part of learning it.

Distance is measured in meters
Speed is measured in meters per second
Acceleration is measure din meters per second, per second (m/s2)

The relationship between these three physical values can be found through calculus. A derivative is dX/dt, right? what do you think that "t" is for? Yes, it is TIME.

The slope of the 'distance versus time' curve is speed.
The slope of the 'speed versus time' curve is acceleration.

>>The derivative of the curve gives us the slope.


The area under the 'acceleration versus time' curve gives us the speed
The area under the 'speed versus time' curve gives us the distance

>>The integral of the curve gives us the area under the curve.


Ain't calculus fun?
Now think of how darned smart the guys who figured all this out must have been...
__________________

I am N2IRZ - What's your callsign?

Last edited by DonRotolo : 07-04-2010 at 19:50.
Reply With Quote
  #7   Spotlight this post!  
Unread 06-04-2010, 22:16
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is online now
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,610
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
Re: Using antiderivative to find velocity from acceleration

Practical applications note:

Your standard 3-axis accelerometer is going to be reading something like 9.8 m/s^2 in some direction while apparently at rest. This is usually a good thing. A reading of less than this generally means your robot is rapidly approaching the ground, or we're all in a heap of trouble, as gravity has taken a holiday.

Nevertheless, your robot isn't actually accelerating at this speed towards the ground, so you need to subtract the acceleration of gravity from the reading of your accelerometer. Which is all fine and easy, until your robot starts pointing in a different direction and gravity is suddenly -9.8 m/s^2 in the x direction.

This means you need to keep track of your robot's orientation in space, just so you can accurately account for the effect of gravity. Which means you slap a 3 axis gyro on your robot and start integrating rates of rotation to determine your orientation, to determine where gravity is, to subtract gravity from your overall acceleration, which you finally integrate to determine your velocity.

And then you wrap it in shiny white plastic, call it a Wii MotionPlus, and make millions of dollars.

Heaven help you if the accelerometer is off-center of the axis of rotation, though. Then you get all sorts of fun extra motion.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter

Last edited by Kevin Sevcik : 06-04-2010 at 22:18.
Reply With Quote
  #8   Spotlight this post!  
Unread 07-04-2010, 21:30
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,034
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: Using antiderivative to find velocity from acceleration

Some useful vocabulary and definitions:

- an antiderivative of a function f(x) is any function whose derivative equals f(x)

- "indefinite integral" and "antiderivative" are, in most contexts, synonyms

- the definite integral of f(x) evaluated over the range x=a to x=b can be calculated analytically if an antiderivative for f(x) can be found. If F(x) is an antiderivative of f(x), then the afore-mentioned definite integral is equal to F(b)-F(a). Loosely speaking, this amazing fact is known as the Fundamental Theorem of Calculus.

- not all functions f(x) have an antiderivative expressable with elementary functions

- definite integrals can be approximated using numerical methods. A very simple method, often called Euler's method, is to simply sum up the values of f(x) at equal intervals in the range and multiply the sum by the interval. Other more accurate methods are available, such as Runge-Kutta. These methods are often available in numerical computation libraries.

- in the real world, integrating a sensor signal to obtain a new signal is fraught with difficulties. jitter and rounding errors can create signals which are not accurate. proceed with caution.
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using the vision processing function of FIRST to find circles Ghtm NI LabVIEW 1 20-01-2010 20:05
problems with velocity readout from encoderget vi windell747 NI LabVIEW 3 25-03-2009 13:47
how to find distance using two color servo camera? Steelix4532 General Forum 4 06-02-2009 17:20
What constants are u using for high velocity PID Salik Syed Programming 3 18-02-2006 23:22
Problems Using PID for Velocity Astronouth7303 Programming 6 10-02-2006 09:00


All times are GMT -5. The time now is 12:42.

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