Go to Post That goal is going to commit suicide by the end of the regional........so many balls @_@... - DanDon [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
  #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!
 


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 04:47.

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