Go to Post For some people FRC is an introduction into STEM and just a way to open someones eyes to a world they might not know exist. To other it is a lifestyle that makes crossfit look casual. - IronicDeadBird [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 05-03-2006, 18:10
sur2124 sur2124 is offline
Registered User
FRC #0116
 
Join Date: Apr 2005
Location: herndon, Va
Posts: 6
sur2124 is an unknown quantity at this point
calculating distance

My team needs to be able to calculate distance, We first used a shaft encoder, we later learned that the shaft dosn't turn with the wheel. So any ideas?
  #2   Spotlight this post!  
Unread 05-03-2006, 18:34
Stuart's Avatar
Stuart Stuart is offline
#include coffee.h
FRC #1745 (P51- Mustangs)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Dallas, TX
Posts: 414
Stuart has a reputation beyond reputeStuart has a reputation beyond reputeStuart has a reputation beyond reputeStuart has a reputation beyond reputeStuart has a reputation beyond reputeStuart has a reputation beyond reputeStuart has a reputation beyond reputeStuart has a reputation beyond reputeStuart has a reputation beyond reputeStuart has a reputation beyond reputeStuart has a reputation beyond repute
Send a message via AIM to Stuart
Re: calculating distance

trial and error . . thats what we did.

(edit)
if your talking about shooting that is.
__________________
Proud mentor of Team #1745 the P-51 Mustangs

If at first it doesn't work, use a hammer.
If that doesn't work, use a bigger hammer.

Last edited by Stuart : 05-03-2006 at 18:37.
  #3   Spotlight this post!  
Unread 05-03-2006, 18:34
abrockhoff abrockhoff is offline
Team 11 Programming Captain
AKA: Alex Brockhoff
FRC #0011 (MORT)
Team Role: Programmer
 
Join Date: Mar 2006
Rookie Year: 2005
Location: New Jersey
Posts: 16
abrockhoff will become famous soon enough
Send a message via AIM to abrockhoff
Re: calculating distance

.. because of your phrasing im not sure if your talking about shooting distance or the distance your robot travels in autonomous mode.

If I'm correct in thinking that your talking about driving distance in autonomous mode, there are quite a few options to find the distance your traveling, the first is encoders, which you say your having trouble with.

You can also try to use timer interrupts, but if your having trboule with that, you can just count program loops. Each loop is 26 milliseconds, so depending on you robots speed you can estimate the loop count you need to travel a certain distance, and then jsut test your autonomous mode to perfect it.
  #4   Spotlight this post!  
Unread 05-03-2006, 18:59
mgreenley
 
Posts: n/a
Re: calculating distance

If you are talking about distance driving or distance shooting, and a shaft encoder doesn't do the trick for you, here are some options that my team has explored in the past in similar situations:
1) Try mating the encoder to a different part of your drive train.
On my teams robot, rather than attaching the encoder to the axle that supports the wheel, we used our encoder to count revolutions of a gear in our transmission.
2) Optical encoders.
Because the shaft doesn't turn with the wheel, measuring the shaft, as you pointed out, wouldn't help much. However, you can, for a slightly less accurate measurement, use an optical encoder and some reflective tape.
3) Trial and Error with timers
As noted, possible, but time consuming in the "lets-try-it-out" department. An option not to be discounted, but not what I'd take as my first route.
4) Hall-effect sensors.
FIRST does include hall-effect sensors, which can count gear teeth, but I've heard mixed results about their implementation.

If you are trying to calculate driving distance, you only need the encoder and a known starting position (use a 3-position switch to accommodate for each starting box). Also, keep in mind that in their most simple implementation, these sensors act as courters; they are independent of direction. Hope this helps.

-Mike, Team 341

Last edited by mgreenley : 05-03-2006 at 19:04.
  #5   Spotlight this post!  
Unread 05-03-2006, 19:51
Uberbots's Avatar
Uberbots Uberbots is offline
Mad Programmer
AKA: Billy Sisson
FRC #1124 (ÜberBots)
Team Role: College Student
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Avon
Posts: 739
Uberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond repute
Re: calculating distance

Well, because you didn't state what you wanted to calculate the distance to, I'm going to assume it is the center goal.
If you are using a camera, track the light and use the camera's tilt angle (and a bit of trig) to determine the distance.
i believe the formula was
Code:
distanceToTarget = heightOfLight*tan(camTilt);
__________________
A few of my favorite numbers:
175 176 177 195 230 558 716 1024 1071 1592 1784 1816
RPI 2012
BREAKAWAY
  #6   Spotlight this post!  
Unread 10-03-2006, 12:12
Bongle's Avatar
Bongle Bongle is offline
Registered User
FRC #2702 (REBotics)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Waterloo
Posts: 1,069
Bongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond repute
Send a message via MSN to Bongle
Re: calculating distance

If you're talking about distance to the target, you can use the camera tilt angle (not very reliable or accurate), or you can use the camera's reported blob size.

If you take an average of the camera's blob size over several cycles (2-3 seconds of summing), you can get a pixel count that is effectively accurate to about 0.01 pixels. Once you know, for example, that you can see 5.27 pixels from your current position, you can plug that into an empirically derived equation to determine your distance in whatever units you want.

So here's what you can do:
1. Write code that sums up the blob size over the last 100 robot cycles
2. Have the code print out the sum of the last 100 cycles, and record this value
3. Measure the distance your robot is from the target, and record that value next to the value from step 2
4. Write the distance and sum down, and repeat for varying distances
5. Put all these (sum,distance) pairs into excel, and have it generate a matching function for you (our best fit was a polynomial).

Example data:
Code:
Pixels	Distance
5.27	8m
5.70	7m
5.95	6m
We ended up collecting five pixel sizes for each distance, and spaced the distances 25cm apart from 8m to 4m.

Once you have this polynomial function, you can use it to take a sum or average of blob sizes and turn it into a measured distance with great accuracy.

The problem with trig is that moving 1 foot when you're 10 feet away doesn't change the angle very much, and as such, you won't get a very accurate distance measurement. We tested this method, and it's accurate to about 10 centimeters. You can also make it variably accurate, depending on how much time you have to measure the blob size. The problem with the blob method is that when you're off to the side, the blob will be artificially smaller without decreasing the distance. However, if you're so off to the side that that is a big issue, you probably won't make the shot anyway.

Last edited by Bongle : 10-03-2006 at 12:14.
  #7   Spotlight this post!  
Unread 10-03-2006, 12:46
Dad1279 Dad1279 is offline
Registered User
FRC #1279 (Cold Fusion)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: NJ
Posts: 511
Dad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud of
Re: calculating distance

We used a gear tooth sensor on a wheel sprocket. Then divide the circumference of the wheel by the number of teeth to get "inches per count"

Then Easy C made it easy to program.
  #8   Spotlight this post!  
Unread 14-03-2006, 20:05
sur2124 sur2124 is offline
Registered User
FRC #0116
 
Join Date: Apr 2005
Location: herndon, Va
Posts: 6
sur2124 is an unknown quantity at this point
Re: calculating distance

I was talking in general, we needed the shaft encoder to find the distance to a point in autonomus mode. We used the Gyro to find direction, y-accelemoter to find tilt angle, and tried to use the shaft encoder to find distance to a point on the field.
  #9   Spotlight this post!  
Unread 15-03-2006, 16:31
Uberbots's Avatar
Uberbots Uberbots is offline
Mad Programmer
AKA: Billy Sisson
FRC #1124 (ÜberBots)
Team Role: College Student
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Avon
Posts: 739
Uberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond repute
Re: calculating distance

Quote:
Originally Posted by sur2124
I was talking in general, we needed the shaft encoder to find the distance to a point in autonomus mode. We used the Gyro to find direction, y-accelemoter to find tilt angle, and tried to use the shaft encoder to find distance to a point on the field.
why didn't you use another gyro to find the tilt angle? it makes things a bit easier

anyway, if you want to calculate distance (without using the camera), you might want to use that encoder.
the encoder counts can be extremely useful, (AFAIK) they count more times per revolution then a GTS can, and (once again, AFAIK) they miss less counters then a GTS.

anyway, what you have to do is figure out the amount of counts per revolution, and then how far each revolution makes the robot go. as far as I'm concerned, this is simple math.
once you have figured that out, assign a PWM value and count up to that value. you might have to use a bit of PI or PID to make sure that the robot will STOP at the desired length, but counting the encoder output is definitely a good idea.

If you are trying to discover position, then you would have to take into account the GYRO angle. By doing this (and a bit of trig i think) you can determine the position of the robot on the Field.
__________________
A few of my favorite numbers:
175 176 177 195 230 558 716 1024 1071 1592 1784 1816
RPI 2012
BREAKAWAY
  #10   Spotlight this post!  
Unread 15-03-2006, 18:05
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
Re: calculating distance

Quote:
Originally Posted by sur2124
I was talking in general, we needed the shaft encoder to find the distance to a point in autonomus mode. We used the Gyro to find direction, y-accelemoter to find tilt angle, and tried to use the shaft encoder to find distance to a point on the field.
That should be pretty easy then. All you need to do is find out how many encoder ticks you get per revolution of the wheel. With that information, you can convert that to ticks per inch. From there you should be able to determine how many ticks you need to go a certain distance.

Edit: This is similar to what Uberbots posted. Should have read more carefully
  #11   Spotlight this post!  
Unread 15-03-2006, 18:36
Andrew Blair's Avatar
Andrew Blair Andrew Blair is offline
SAE Formula is FIRST with Gasoline.
FRC #0306 (CRT)
Team Role: Alumni
 
Join Date: Feb 2005
Rookie Year: 2004
Location: Corry
Posts: 1,193
Andrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond repute
Send a message via AIM to Andrew Blair Send a message via Yahoo to Andrew Blair
Re: calculating distance

As far as saving your encoders- try mounting a small sprocket onto the encoder shaft, and let it run right with the chain.

Be careful though - from what I've heard, encoders don't exactly take kindly to side loads...
__________________
Reading makes a full man, conference a ready man, and writing an exact man.
-Sir Francis Bacon

"Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction."
-Albert Einstein
Closed Thread


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
get distance from cmucam ModMan24 Programming 14 29-10-2010 17:51
Sharp IR distance sensors Gdeaver Electrical 13 10-02-2007 20:36
Some ways to measure distance during autonomous shamu1001 Programming 2 06-02-2006 15:24
Center to Center Distance for 2002 Chaiphua and Cluster gear sanddrag Motors 1 20-07-2005 07:36
Long distance... Ashley Christine Chit-Chat 6 27-04-2005 15:11


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

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