Go to Post Its always good to read the rules yourself rather than listen to "word of mouth" rules. - Killraine [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 08-02-2007, 14:33
Ultima Ultima is offline
Registered User
FRC #0369
 
Join Date: Oct 2005
Location: Brooklyn, NY
Posts: 26
Ultima will become famous soon enough
Converting EasyC Tracking Code into MpLAB

Now our team this year decided to keep programming in MpLAB since over the past years we have become a little more familiar with and is easier for us to use. The problem with this is that Intellitek released a 2 target following code for their EasyC, now we have a problem converting that code into MpLAB. This is the code that we have extracted from EasyC:

Quote:
void SeekLight(void)
{
unsigned char centroid_x;
unsigned char centroid_y;
unsigned char lowright_x;
unsigned char lowright_y;
unsigned char upleft_x;
unsigned char upleft_y;
unsigned char region_size;
unsigned char confidence;
int elevation;
char done = 0;
int xerror = 0;
int icentroid_x;
int target_width;
unsigned long timer = 0;
int target_x;
int rotation;
int old_rotation;
unsigned char targets = 0;

elevation = Start_Elevation_PWM;
rotation = Center_Camera_PWM;
ClearScreen();
while (!done) // go until finished
{
PrintFrameToGD ( 1, 1, 10, 20, 0);
PrintTextToGD ( 2, 2, 0, "Targeting Camera\n");
PrintTextToGD ( 4, 2, 0, "Targets Found: %d\n", (int)targets);
PrintTextToGD ( 6, 4, 0, "Pan%3d\n", (int)(rotation - 127);
PrintTextToGD ( 8, 4, 9, "Tilt%d\n", (int)(elevation - 127);
// get data from camera

CaptureTrackingData (&centroid_x, &centroid_y, &upleft_x, &upleft_y, &lowright_x, &lowright_y, &region_size, &confidence, 0, 0);
target_width = lowright_x - upleft_x; // Horizontal extents of bounding box
icentroid_x = (int)centroid_x; // Move into integer variable
if (target_width > Widest_One_Light) // Looking at two targets?
{
targets = 2;
if ((lowright_x - centroid_x) < (centroid_x - upleft_x))
{
//centroid is near the left
target_x = lowright_x - HALF_LIGHT_WIDTH;
}
else
{
// the centroid is nearer the left
target_x = upleft_x +HALF_LIGHT_WIDTH;
}
}
else if (region_size > MIN_REGION)
{
targets = 1;
target_x = icentroid_x; //target that light
}
else // The target is not wide, it's one light
{
// SetCurPos (4, 18);
PrintToScreen ("0);
targets = 0;
}
// PrintToScreen ("TargetX = %d\n", (int)target_x)
if (region_size > MIN_REGION) // Check if we're locked
{
timer = GetTimer (TIMER_NUM); // is it time to recenter the tilter
if (timer > TILT_SAMPLE_RATE ); //# of milliseconds between samples
{
elevation = DistanceToPeg (elevation, centroid_y); // Center tilt, get distance
rotation = RotateToPeg (rotation, target_x);
//SetCurPos (6, 11);
//PrintToScreen ("%d ", rotation - 127);
//SetCurPos (7, 11);
//PrintToScreem ("%d ", elevation - 127);
PresetTimer (TIMER_NUM, 0); // Reset The Timer
}
}
}
}
As far as I can see this code basically finds the target and checks to see whether that target it found is bigger than the normal sized light, if so it would recognize that there are 2 lights and find the better one. I would really appreciate it if someone can clarify this code or maybe even help us convert it into MpLAB for use. I understand that the fuction PrintTextToGD of course acts as a printf function, and RotateToPeg, and DistanceToPeg are your Tilt and Pan Values. As for all other functions I have no idea where to start making this work. ANY Help at all is greatly appreciated. Thank you very much!
  #2   Spotlight this post!  
Unread 08-02-2007, 14:53
Kingofl337's Avatar
Kingofl337 Kingofl337 is offline
You didn't see anything....
AKA: Adam
FRC #0501 (Power Knights)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 1998
Location: Manchester, NH
Posts: 861
Kingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond repute
Send a message via Yahoo to Kingofl337
Re: Converting EasyC Tracking Code into MpLAB

You could use WPILib with MPLAB or just use easyC Pro. It has a syntax highlighting C editor so you can type code just like in MPLAB.
__________________
FIRST Team 501 PowerKnights - Mentor
FIRST Team 40 Checkmate - Mentor Alum
FIRST Team 146 Blue Lightning - Alumni

Last edited by Kingofl337 : 08-02-2007 at 16:26.
  #3   Spotlight this post!  
Unread 08-02-2007, 16:08
CrashOverride's Avatar
CrashOverride CrashOverride is offline
Registered User
FRC #1831
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Gilford, NH
Posts: 16
CrashOverride is an unknown quantity at this point
Re: Converting EasyC Tracking Code into MpLAB

Instead of trying to convert this code from easyC to MPLab you should check out Kevin's libraries posted on: http://www.kevin.org/frc/

It has solid code ready for use with MpLab.
  #4   Spotlight this post!  
Unread 08-02-2007, 16:29
Ultima Ultima is offline
Registered User
FRC #0369
 
Join Date: Oct 2005
Location: Brooklyn, NY
Posts: 26
Ultima will become famous soon enough
Re: Converting EasyC Tracking Code into MpLAB

Is Kevin's code able to track 2 simultanious targets?
  #5   Spotlight this post!  
Unread 08-02-2007, 16:32
Kingofl337's Avatar
Kingofl337 Kingofl337 is offline
You didn't see anything....
AKA: Adam
FRC #0501 (Power Knights)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 1998
Location: Manchester, NH
Posts: 861
Kingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond repute
Send a message via Yahoo to Kingofl337
Re: Converting EasyC Tracking Code into MpLAB

The CMU camera doesn't track multiple targets. The code you mention just looks at the size of the blob and dertermines how many tagets its seeing.
__________________
FIRST Team 501 PowerKnights - Mentor
FIRST Team 40 Checkmate - Mentor Alum
FIRST Team 146 Blue Lightning - Alumni
  #6   Spotlight this post!  
Unread 08-02-2007, 21:38
DanDon's Avatar
DanDon DanDon is offline
ohhh MY god
AKA: Dan Hoizner
FRC #0375 (The Robotic Plague)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Staten Island, NY
Posts: 1,432
DanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond repute
Send a message via ICQ to DanDon Send a message via AIM to DanDon Send a message via MSN to DanDon
Re: Converting EasyC Tracking Code into MpLAB

Quote:
Originally Posted by Ultima View Post
Is Kevin's code able to track 2 simultanious targets?
Search the forum for team 250's Multiple Object tracking code. I believe it is a sticky in the CMUcam subforum or the programming forum.

This code uses the camera's VW (Virtual Window) command to disect image seen and parse the image to track multiple objects with distinct bounding boxes.
__________________
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
Camera tracking demo in easyC or WPILib BradAMiller Programming 0 25-01-2007 14:01
how to convert Easy C code into real code? TheHolyLancer Programming 1 29-01-2006 09:09
Vex Easyc vs Mplab Joohoo Programming 17 27-01-2006 08:22
Kickoff easyC workshop integrated into EasyC help file Dan Larochelle Programming 0 11-01-2006 06:12
Converting the Bosch Metric Pinion into an English- Specification Pinion evolution Motors 3 28-08-2004 16:30


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

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