Go to Post Ohh the [strike]humanity[/strike] robotity! - artdutra04 [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

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 22-12-2008, 14:04
excel2474's Avatar
excel2474 excel2474 is offline
Registered User
AKA: Aaron Stewart
FRC #2474 (Excel)
Team Role: Engineer
 
Join Date: Mar 2008
Rookie Year: 2008
Location: Niles, Michigan
Posts: 177
excel2474 is a jewel in the roughexcel2474 is a jewel in the roughexcel2474 is a jewel in the roughexcel2474 is a jewel in the rough
Program Axis Camera in c++

Hi, lately i have been doing a lot of studying c++. I've download the wpi code and looked over it pretty well, but i'm just not exactly sure how to program the camera. We haven't received our crio yet and I want to be ready to program it when we get it. Could someone explain to me how I would use the camera to track a specific color of light and then align that light in the center view of the camera? Do you have well commented code you could show me? Thanks for all your help.
__________________
"Find some thing you like to do and EXCEL at it with dilligence."

University of Notre Dame- Mechanical Engineering.
  #2   Spotlight this post!  
Unread 22-12-2008, 14:14
Bongle's Avatar
Bongle Bongle is offline
Registered User
FRC #2702 (REBotics)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Waterloo
Posts: 1,069
Bongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond repute
Send a message via MSN to Bongle
Re: Program Axis Camera in c++

Camera documentation starts at page 41 of this document:
http://first.wpi.edu/Images/CMS/Firs...de_for_FRC.pdf
  #3   Spotlight this post!  
Unread 22-12-2008, 14:29
excel2474's Avatar
excel2474 excel2474 is offline
Registered User
AKA: Aaron Stewart
FRC #2474 (Excel)
Team Role: Engineer
 
Join Date: Mar 2008
Rookie Year: 2008
Location: Niles, Michigan
Posts: 177
excel2474 is a jewel in the roughexcel2474 is a jewel in the roughexcel2474 is a jewel in the roughexcel2474 is a jewel in the rough
Re: Program Axis Camera in c++

Yeah, I've read this, but I don't understand how this will take an image and align it in the center view of the camera. Could anyone highlight some code and explane it. thanks
__________________
"Find some thing you like to do and EXCEL at it with dilligence."

University of Notre Dame- Mechanical Engineering.
  #4   Spotlight this post!  
Unread 22-12-2008, 15:25
Bongle's Avatar
Bongle Bongle is offline
Registered User
FRC #2702 (REBotics)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Waterloo
Posts: 1,069
Bongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond repute
Send a message via MSN to Bongle
Re: Program Axis Camera in c++

Note that I've never done this, I'm just giving somewhat-informed advice.

Ok, if you turn to page 53, there's a bit more detail about the processing step (I'm guessing you've read that too).
Here's the code
Code:
TrackingThreshold tdata = GetTrackingData(BLUE, FLUORESCENT);
This line declares a TrackingThreshhold structure. Based on the comments on the PDF and the way it is used in the code, this appears to be a block of settings that is later used by the FindColor function to do its image analysis. In this case, it appears that they are filling it with pre-set defaults for a generic blue color.

Code:
ParticleAnalysisReport par;
This declares a ParticleAnalysisReport structure. This structure is filled with many useful image-analysis results by the FindColor function.


Code:
if (FindColor(IMAQ_HSL, &tdata.hue, &tdata.saturation, &tdata.luminance, &par)
This is where the magic happens. The FindColor function uses the Hue, Saturation, and Luminance (another way of specifying a color, it is like RGB) from the TrackingThreshhold object to tell it what to look for, then returns its results in the ParticleAnalysisReport structure. Note that they use an if statement here. This is because FindColor returns 1 on success, 0 on failure. I haven't found definitions for what it considers success of failure, but I'd guess (just a guess) that it returns failure if it can't find a good enough blob.

Code:
{ 
  printf(“color found at x = %i, y = %i", par.center_mass_x_normalized, par.center_mass_y_normalized); 
  printf(“color as percent of image: %d", par.particleToImagePercent); 
}
This is where you would act on the results. The center_mass_x_normalized variable tells you where the best match (the biggest blue blob, in this case) is on the x axis. -1.0 means it is on the edge of the camera's vision to the left, and 1.0 means it is on the edge of the camera's vision to the right.

So if I understand your question, you would want your robot to turn left if you see a value less than 0.0, turn right if you see a value more than 0.0, and remain still if the camera value is at 0.0. It would be a good idea to use a PID loop to control this, however, because you'd get big oscillations if you had a simple algorithm like that.

Last edited by Bongle : 22-12-2008 at 15:31.
  #5   Spotlight this post!  
Unread 22-12-2008, 15:41
Travis Hoffman's Avatar Unsung FIRST Hero
Travis Hoffman Travis Hoffman is offline
O-H
FRC #0048 (Delphi E.L.I.T.E.)
Team Role: Engineer
 
Join Date: Sep 2001
Rookie Year: 2001
Location: Warren, Ohio USA
Posts: 4,047
Travis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond repute
Re: Program Axis Camera in c++

I haven't examined it yet, but Team 1114 released C++ beta test code that has basic color tracking autonomous functionality implemented on their 2007 robot. You may elect to see how they did it:

Click here.

From their site:

"The C++ code developed for teleoperated control of the robot. It includes examples of an IterativeRobot with one-joystick drive and simple arm control, as well as some convenience classes we wrote for double solenoids and the Logitech Dual Action Gamepad. Also included is an autonomous mode that tracks the green light and scores a tube on a spider leg, as well as a class for doing PID calculations 1114-style."

(Yes, I know, I linked to a certain intermediate website instead of providing the direct link. Tough cookies! )
__________________

Travis Hoffman, Enginerd, FRC Team 48 Delphi E.L.I.T.E.
Encouraging Learning in Technology and Engineering - www.delphielite.com
NEOFRA - Northeast Ohio FIRST Robotics Alliance - www.neofra.com
NEOFRA / Delphi E.L.I.T.E. FLL Regional Partner

Last edited by Travis Hoffman : 22-12-2008 at 15:44.
  #6   Spotlight this post!  
Unread 22-12-2008, 17:14
excel2474's Avatar
excel2474 excel2474 is offline
Registered User
AKA: Aaron Stewart
FRC #2474 (Excel)
Team Role: Engineer
 
Join Date: Mar 2008
Rookie Year: 2008
Location: Niles, Michigan
Posts: 177
excel2474 is a jewel in the roughexcel2474 is a jewel in the roughexcel2474 is a jewel in the roughexcel2474 is a jewel in the rough
Re: Program Axis Camera in c++

Thanks guys for the help. Bongle, that is exactly what i'm looking for. Thanks alot.
__________________
"Find some thing you like to do and EXCEL at it with dilligence."

University of Notre Dame- Mechanical Engineering.
Closed Thread


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
Axis camera without the cRIO CrazyCarl461 NI LabVIEW 12 17-01-2009 10:53
Axis Camera Testing help koo_04 Programming 7 20-12-2008 13:55
axis camera - problem s0crates FRC Control System 11 16-12-2008 09:34
program camera kasemodz Programming 2 13-01-2007 15:59
EasyC Program For Camera? G1279 Programming 1 08-01-2007 19:00


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

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