View Single Post
  #5   Spotlight this post!  
Unread 10-02-2013, 14:14
Ginto8's Avatar
Ginto8 Ginto8 is offline
Programming Lead
AKA: Joe Doyle
FRC #2729 (Storm)
Team Role: Programmer
 
Join Date: Oct 2010
Rookie Year: 2010
Location: Marlton, NJ
Posts: 174
Ginto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of light
Re: |Calculating Distance to targets

Do you have a way to tell the angle and height of the camera? If so, you know the height of the tallest goal, and the angle relative to the camera, so you can use tangent to figure it out. Something like this:
Code:
distanceToTarget = (targetHeight-cameraHeight)/tan(cameraAngle+relativeTargetAngle);
I used a similar height-based algorithm last year and had the same sort of problem with error. I found this angle-based formula by looking at Miss Daisy's vision code from last year.
__________________
I code stuff.