View Single Post
  #2   Spotlight this post!  
Unread 21-01-2006, 17:53
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: get distance from cmucam

Haven't written the code yet, but just so you know, you can't get the distance to target *directly* from the camera (without some elegant code that I don't know about). However, it is still rather easy.

Using Kevin Watson's Default camera code, there should be a variable called something like tilt_value. Using this value, after converting the PWM value into a useable angle, you can employ a bit of triganometry to derive the distance to target.

(Vert_goal_hight/(tan(angle_to_goal)))= distnce to goal

I would use a lookup table, it'll be much faster than constantly calculating the distance.
__________________
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