Go to Post It is impossible to be grumpy about anything when eating biscotti made by one's beautiful wife, drinking tea sweetened by one's own honey, warmed by a wood stove, and with a dog asleep on one's foot. Simply impossible. - pfreivald [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
  #3   Spotlight this post!  
Unread 27-01-2005, 00:43
Tom Bottiglieri Tom Bottiglieri is offline
Registered User
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Jan 2004
Rookie Year: 2003
Location: San Francisco, CA
Posts: 3,187
Tom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond repute
Re: Have you gotten your robot to go towards the vision tetra?

There is a few things that can be helpful to use while tracking color using camera_find_color().

Ill give a quick run down of how this works. The camera processor can send and receive messages through the serial port. If you look in the camera manual PD, you will see a complete list of commands and their parameters. The one we are interested in is "TC" (track color) You send the camera this command followed by the max and min RB values.

This is the format of the Track Color Command:
TC [ Rmin Rmax Gmin Gmax Bmin Bmax ] r

Now, the camera processor takes over. Using the max and min RGB values (which you found in calibration), it looks for a color blob which has pixels that fit into the RGB value window you have specified (once again, with calibration) If the does not find a color, it will return a 0. If the camera does find your color, it will return what is called a 't packet' This serial packet includes information about the color blob's Centroid coordinates, bounding box (how big of an area it covers), amount of pixels tracked, and a certainty rating (0-100%, how sure the camera is this is YOUR blob)

Once the camera finds the blob, it goes into frame differencing mode. In this mode, the camera records many frames per second, in a very small resolution. It then can determine whether the color blob has moved over time. It will compute how far the blob has moved to either the left or right, and since the camera board has control of a pan servo, it will try to correct itself, so that the blob's centroid is in the exact center of the frame.

Now, you may be asking what you can do with this information...

The camera driver sets up a structure, from which you can grab different values. When camera_track_update( ) is called, it will take the last good T packet and throw the data into local variables. It also grabs the current servo angles (pwm values) and throws those into RC local variables. Now, you have exactly what the camera is seeing in variables on the RC, which can be accessed by referencing the "cam" object. So to get the pan servo's pwm value, all you would need to do in your code is include the cam structure, and then use that structures variable 'pan_servo'

This is how you can do that:
Code:
extern cam_struct cam; //include cam structure in your NEW, not default code.

//set local reference to latest cam data
camera_track_update( );  
TheServo = cam.pan_servo;
Now, you know what angle the blob is in relation to the front of the bot (from the servo angle) You can now adjust the bots heading according to this. If the blob is to the left of the bot, rotate left. To the right, rotate right. Now when your bot is 0o with the blobl, you are safe to drive forward.

So (in very basic form), this is how to track a color, in code form.
Code:
int SPEED_SETTING = 155; //Set how fast you want bot to drive/turn.
int centered = 0;   //use this to check if bot is alligned with blob.
int tracking = 0;    //use this to see if we got a good frame.

//set camera to track your color, lets say green.
tracking = camera_find_color( GREEN );

//update camera info
camera_track_update( );

//See if bot is facing blob. If not, correct.

if(cam.pan_servo < 120) //im using a 7 value deadband.
{
     wheel_l = 255 - SPEED_SETTING;
     wheel_r = SPEED_SETTING;      // This turns bot to the left.
     centered = 0;
}
else if(cam.pan_servo > 134)
{
     wheel_l = SPEED_SETTING;
     wheel_r = 255 - SPEED_SETTING;     //This turns bot to right.
     centered = 0;
}
else centered = 1;

//Now check to see if theres a good frame, and if the servo blob is in front of the bot. If there is, drive to it.

if(tracking == 1 && centered==1)
{
     wheel_l = SPEED_SETTING;
     wheel_l = SPEED_SETTING; //Drive straight!
}
Now that will bring you into basic color tracking. The next logical thing to do would be to stop when you are close to a color. To this, you may use a tilt servo, which does the same thing as the pan servo (in which it tries to center the color blob; meaning.. the tilt servo would be pointing directly at your color's centroid) If you know the tilt servos angle, you can do some basic trig to find out how far the color is away.



Another way you could find how far away the blob is by looking at the bounding box, and comparing its values.

If I get some good feedback, I will write a white paper explaining the camera more in depth and giving more example code.

Hope this helped,
Tom.
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Q/A questions so far.. AmyPrib Rules/Strategy 49 28-01-2005 08:39
Wolrd Triple Play Autonomous Mode (WAM) Standards Natchez General Forum 3 11-01-2005 15:52
Can an a robot take a tetra from another robot in their allinace? Koko Ed Rules/Strategy 3 10-01-2005 23:01
Vision Tetra Alignment Issues phrontist Rules/Strategy 8 10-01-2005 20:56
Just where are vision "bonus" tetras placed? David Brinza Rules/Strategy 17 10-01-2005 20:50


All times are GMT -5. The time now is 21:34.

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