Go to Post I don't care if students, engineers, my aging grandmother, or a pack of monkeys builds the robot...as long as at least one student walks away inspired then the goal of FIRST has been reached. - Andy Grady [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 09-02-2013, 12:04
Doron_Sivan Doron_Sivan is offline
Registered User
FRC #4590 (GreenBlitz)
Team Role: Programmer
 
Join Date: Oct 2012
Rookie Year: 2013
Location: Israel
Posts: 11
Doron_Sivan is an unknown quantity at this point
|Calculating Distance to targets

Hi everybody,

We've tried to use formulas in order to find the distance to the high target. When we checked it physically, we noticed that it calculated a distance that is wrong in approximately 2 meters.

I'll explain first our formula – it's the regular formula which WPILIB suggest to use:
We know the target height in inches – 20 inches for the high goal.
We know the target height in pixels (with vision processing)
We know the image width in pixels (it's basically the resolution) – our resolution was 640 pixels.
So we can calculate the field of view width in inches. We know the camera horizontal angle which is (in our camera) 47 degrees, so we can calculate the distance to the target using tangent.

So the formula is:
distance = (targetHeightInches * ImageWidthPixels) / (2 * targetHeightPixels * tan(cameraHorizontalAngle/2);


I can think of number of reason to our errors, I'll be glad if you'll comment and tell me if I'm right or there are another reasons.

First, maybe the camera horizontal angle is not accurate (should we measure it ourselves?)

Second, the distance we measured physically was distance which is parallel to the ground. In the formula the distance has some angle with the ground – alpha - so the calculated distance is : parallelDistance / cos(alpha). I think it's negligible (alpha would be something like 10 degrees, right?).

Another reason might be that in this calculation we assume that we are at the height of the target – when our camera is something like 15 inches from the ground and the high target is much higher so the field of view is not a square it's some Quadrilateral. We assume in the calculation that the width of the FOV is constant but it's changing - the lower pixels might be smaller in the reality compared to the higher pixels. We put the target in the center of our image – do our "wrong" assumptions still affect and cause to those errors?

Maybe it would never be precise with a formula and we need to use physical measurements for each distance??

Thanks for your help.

Last edited by Doron_Sivan : 10-02-2013 at 08:11. Reason: I wrote the wrong number of inches
 


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 10:10.

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