Go to Post Sally Ride says role models are needed - that's you. - JaneYoung [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
  #9   Spotlight this post!  
Unread 07-02-2005, 22:59
russell's Avatar
russell russell is offline
Registered User
#1430 (WRONG)
Team Role: Electrical
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Anchorage AK
Posts: 402
russell is a name known to allrussell is a name known to allrussell is a name known to allrussell is a name known to allrussell is a name known to allrussell is a name known to all
Re: Autonomous With Camera

Quote:
Originally Posted by schenkin
Does just executing that camera track green color make the robot go towards green?
No it isnt quite that simple. Here is generall what I did (I am writing this from memory here so you will have to forgive possible problems in it):
in user_routines_fast.c
Code:
int counter=0; //define a counter in the beginning

then down in the autonomous part.....


if(counter==0)
  {
   camera_init(45,19,121);
   camera_auto_servo(1);
   camera_find_color(GREEN);
   }

if(camera_track_update()==1)
  {
   if (cam.size>0)
     {
      tracking=1;
      }
   else
      tracking=0;


if(tracking==1)
   {
    Ok now put some single joystick drive code here using the variable cam.pan_servo as the x axis of the joystick, and a constant value as the y axis
    }
else
  pwm11=pwm12=127;
Something like that. It is crude but it is working for me.

Basically what it does is when the program starts the first time it runs it initializes the camera (oh yeah you are gonna want to change those values in there to the ones you got from calibrating), then it sets it up to use auto servo then it tells it to track green. Then it checks to see if there is new data from the camera. If there is then it checks to see if it is tracking one or more pixels and if so it sets the variable "tracking" equal to one, and if it is not it sets it equal to 0. Then if tracking is equal to one it executes your drive code, and if not then it stops your motors. It is important to stop your motors so that when you loose sight of a target your robot doesnt go nuts.

If you have any questions please ask away, I am quite proud of this relatively simple code and I would love to answer any questions. Yeah, this is my first year programming....

Last edited by russell : 08-02-2005 at 00:38.
 


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
Scripting Setup and the Camera + Serial Port Drivers CJO Programming 22 11-01-2006 17:42
Unresponsive camera neilsonster Programming 9 17-02-2005 08:51
CMUCam2 Camera Code - Are important parts commented out? Mr. Lim Programming 4 14-01-2005 12:11
autonomous mode problem on field Chris_C Programming 17 26-03-2003 19:11


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

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