Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   How do I get distance between Camera and the target? (http://www.chiefdelphi.com/forums/showthread.php?t=42729)

sjung9442 26-01-2006 21:12

How do I get distance between Camera and the target?
 
How do I get the distance between Camera and the green light?
Is it in the code? or do I have to use some other program to get the data?
I really don't understand it...

Jared Russell 26-01-2006 21:30

Re: How do I get distance between Camera and the target?
 
Math.

If the target is centered, then:

(goal_height - camera_height) / tan(camera_tilt) = range

The problem is implementing a tan() function on the PIC - check the Whitepapers on Delphi for a few ways to do this (search for CORDIC).

Also, if the target is not centered, then you have to convert the vertical pixel error into an angle and add that to the camera_tilt value. This requires that you know the field of view angle of the camera lens.

Mike 26-01-2006 21:34

Re: How do I get distance between Camera and the target?
 
Quote:

Originally Posted by Abwehr
Math.

If the target is centered, then:

(goal_height - camera_height) / tan(camera_tilt) = range

The problem is implementing a tan() function on the PIC - check the Whitepapers on Delphi for a few ways to do this (search for CORDIC).

Also, if the target is not centered, then you have to convert the vertical pixel error into an angle and add that to the camera_tilt value. This requires that you know the field of view angle of the camera lens.

tan() is included in the latest version of C18 compiler (2.4 I believe)

It has been this way since (at least) last year.

Greg Marra 26-01-2006 21:37

Re: How do I get distance between Camera and the target?
 
Quote:

Originally Posted by Mike
tan() is included in the latest version of C18 compiler (2.4 I believe)

It has been this way since (at least) last year.

The only problem with the trig functions on the RC is they take a very long time to execute (relatively speaking). If you try to do this often, you're going to create problems for the rest of your code.

Jared Russell 26-01-2006 21:41

Re: How do I get distance between Camera and the target?
 
Quote:

Originally Posted by Mike
tan() is included in the latest version of C18 compiler (2.4 I believe)

It has been this way since (at least) last year.

I should have said a tan() that executes in a reasonable time. The PIC has no native floating point support - using your own integer-valued library can speed things up tenfold easily.

Alan Anderson 27-01-2006 09:44

Re: How do I get distance between Camera and the target?
 
Instead of doing the math, it might be simpler just to implement a lookup table. Put the robot 50 feet from the goal and measure the camera tilt angle. Move it a foot closer at a time and repeat. Put the answers in the program.

If you have an adjustable shooter, you can put the required barrel tilt/wheel speed/catapult stop bar location in the table instead of the distance.


All times are GMT -5. The time now is 08:59.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi