# Distance Calculation in Workbench

Hi I was wondering if anyone had figured out how to do distance calculation using the axis camera in workbench. Any help would be appreciated. We were thinking of using angles to find the distance to the flag.

verticalServo->GetAngle() gets you the angle, then use some trig

Sorry I should have been more specific we are hard mounting the camera is there anyway to get the vertical angle from the center of the image to the flag but thanks.

Well with just the camera you can tell what point the target is at, and you can tell how big it appears. You know how big it should be and how high it should be. So compare the two. I am looking over this as well and it will probably be pathagerian therom like this:

(height)^2 * X^2 = (actual distance)^2

where height is the height in the picture compared to the actual trailer height and actual distance is a comparison between the size of the target and the apparent size of the target.

I think this is correct, but I am still thinking it over and working on it myself, I hope this helps you.

One method that does not rely on the size of the blobs is to calibrate your robot so that it knows the distance using the y-offset of the target. The closer you are, the higher the blobs are in the image. You need to be consistent as to which color data you are getting the info from (such as always the bottom one). We will be calibrating ours by setting out a tape measure and moving the target trailer right next to the robot. Record the y-offset. Move the target 3-4 inches (whatever resolution you want) and record the y-offset again. Keep going until you have the makings of a look-up table. Our tests at about 10 feet gave us 2-3 inch distance resolution.

Steve C