View Single Post
  #2   Spotlight this post!  
Unread 28-01-2007, 17:13
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: Using VirtualWindow() ... how?

Quote:
Originally Posted by JohnC View Post
I'm looking to track two lights to be able to center the robot between them, but I am clueless.

If I tell the camera to use a VW, will it go back to using a full window in the next loop? Will I still be able to use the pan/tilt angles as printed by the default camera code? Where will I find the coordinate values of the bounding box? If I create two VWs in one loop of autonomous code (for two lights), how can I get the coordinates of the bounding box for each?

Also, I'm assuming I don't need to change the camera to Raw Mode because the initialization function does that.

Basically, as is very clear, I'm new to using the camera. Any help is appreciated.
The Virtual Window command tells the camera to ignore information outside the window you specify in the command. If the camera is streaming t-packets, you'll need to call the Camera_Idle( ) function first, wait for an ACK, then call Virtual_Window( ), wait for another ACK, then call Track_Color( ) if needed. There are two global variables in camera.c that count the number of ACKs and NCKs the camera has sent. When they increment, you know the camera has acknowledged (or not acknowledged) your command. You'll need to add these lines to camera.h before they'll be visable to other source code files:

extern unsigned int camera_acks;
extern unsigned int camera_ncks;

The new virtual window is persistent until the camera is reset, at which point the camera will revert back to using the full frame.

You do not need to call Raw_Mode( ) again.

The coordinant frame is discussed in the command dictionary, which is available at http://kevin.org/frc. If you mounted the camera using the instructions in the workbook, pixel 1,1 in in the upper left corner, otherwise it's located in the lower right corner.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org