Go to Post Well, it's officially that part of the offseason where we all lose our minds again. - Whippet [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 25-01-2007, 14:01
BradAMiller BradAMiller is offline
Registered User
AKA: Brad
#0190 ( Gompei and the Herd)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Worcester, MA
Posts: 588
BradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant future
Camera tracking demo in easyC or WPILib

Here is the shortest program that I could write that will track to a green light. It assumes 2 motors connected to PWM ports 1 and 2. Also the camera is fixed (no servoing). The robot will follow the light as long as it is seeing it.

Here is the easyC version (just the C code), but there is a link to an easyC Pro project and an MPLab project. There is also a link to a video showing it running on a FRC controller on a Vex robot chassis.

Code:
#include "Main.h"

void main ( void )
{
      unsigned char regionSize; 
      unsigned char mx; 
      int error; 

      TwoWheelDrive(2,1); // The following 4 functions are built into WPILib, but have no blocks
      SetInvertedMotor(1); //    So they have to be user code blocks
      SetInvertedMotor(2);
      SetCameraDebugMode(1);
      InitCamera ( 1 ) ; // default FIRST green setup
      StartCamera ( ) ;
      while ( 1 )
      {
            CaptureTrackingData ( &mx , 0 , 0 , 0 , 0 , 0 , &regionSize , 0 , 0 , 0 ) ;
            if ( regionSize > 10 )
            {
                  error = ((int) mx) - 80 ;
                  Drive(50, error); // turn towards the light
            }
            else
            {
                  Drive(0, 0); // no light - stop driving
            }
      }
}
Attached Files
File Type: zip EasyCTrackToTheLight.zip (23.2 KB, 45 views)
File Type: zip MPLabTrackToTheLight.zip (143.6 KB, 40 views)
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute
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
Quetion about servo tracking function in easyC pro itsme Programming 5 31-01-2007 11:30
easyc demo code not working sniggel Programming 5 28-01-2007 16:40
Labview Demo File for 2006 Camera? JABianchi General Forum 2 15-09-2006 18:23
CMU Camera Tracking auditt241 Programming 0 03-02-2005 16:33
Camera Tracking Woes VideoMan053 Programming 4 29-01-2005 18:09


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

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