|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Older FRC autonomous code
I have the 2007 FRC bot (along with the 2006, 2005). I am programming using mplab 7.2. I am trying to install an autononmous code. I just want a short code that moves the bot forward a short distance , turns and returns to the original location.
Does anyone have a default workspace that has the autonomous code imbedded, who might be willing to share? thanks john |
|
#2
|
|||||
|
|||||
|
Re: Older FRC autonomous code
Do you mean the original default code?
Or Kevin Watson's default variation? Or did you want direction on how to implement autonomous code? Or were you looking for someone to drop your simple autonomous movements into the default to use as a starting example? Last edited by Mark McLeod : 28-04-2010 at 18:26. |
|
#3
|
||||
|
||||
|
Re: Older FRC autonomous code
Quote:
|
|
#4
|
|||
|
|||
|
Re: Older FRC autonomous code
Do you want a smart or dumb autonomous (sensors or none?)
If you don't want any sensors, then this should be a pretty straight forward task. If you do want sensors, it'll be a little more complicated. This is where you should start: http://kevin.org/frc/ |
|
#5
|
|||
|
|||
|
Re: Older FRC autonomous code
Hello to Mark
well i have the kevin watson version i think. and yes i wuold like to know how to drop in the autononmous code and also create if you cuodl help. basically on all three. i do have the default code working so i have the teleop working both tank ans arcade., i would just like to do the autononmous too. thanks john |
|
#6
|
|||
|
|||
|
Re: Older FRC autonomous code
and billbo911 yes if you could zip your code i would like that too if you could
thanks a bunch. john |
|
#7
|
||||
|
||||
|
Re: Older FRC autonomous code
|
|
#8
|
|||||
|
|||||
|
Re: Older FRC autonomous code
In the Watson version you drop your autonomous code into the file "autonomous.c", specifically into the routine "Autonomous()".
This routine gets executed ~38 times per second in sync with the driver station control transmission packets. You write your autonomous code in such a way that it does a little bit and goes away. When it gets called again it does a little bit more and goes away again. Two ways to dead reckon autonomous movements are:
Counting loops is accurate enough for what you're doing at first, and it's trivial to implement and understand right away, so you can start with that. On top of these methods of keeping track of time you might want a state machine to keep track of the steps you should be doing. Here's an example: Code:
// Drive forward, turn, return, and stop
void Autonomous()
{
static int counter=0; //keep track of loops to use as a crude timer - static keeps it around from call to call
static int autostate=1; //keep track of what step we're supposed to be doing
switch (autostate)
{
case 1: // Drive forward
pwm01 = pwm02 = 200;
pwm03 = pwm04 = 54; //motor is reversed
if (counter>38) //1 second
{
autostate = 2; // move on to the next step
counter = 0; // reset our timer for the next step
}
case 2: // Turnaround
pwm01 = pwm02 = 200;
pwm03 = pwm04 = 200; //motor is reversed
if (counter>76) //2 seconds
{
autostate = 3;
counter = 0;
}
case 3: // Drive forward (returning now)
pwm01 = pwm02 = 200;
pwm03 = pwm04 = 54; //motor is reversed
if (counter>38) //1 second
{
autostate = 4;
counter = 0;
}
case 4: // Stop - What to do when everything else is done
default: // also what to do if an invalid autostate occurs
pwm01 = pwm02 = pwm03 = pwm04 = 127; // Make sure the last thing you do is always stop
}
counter++;
}
Our team code from 2007 is here, but it's fairly complex as it implements a scripting system for autonomous, so I definitely wouldn't start learning at that level. Our robot was somewhat complex that year too. Last edited by Mark McLeod : 29-04-2010 at 14:09. |
|
#9
|
|||
|
|||
|
Re: Older FRC autonomous code
so after i open up the default workspace then i can open the autonomous.c and edit it there?
i think in the default code there is a place to drop in code but i forget which file i need to open up once the workspace is opened. i would like to start with the dumb code but actually it would be nice to do some 'smart" code ![]() thanks john |
|
#10
|
|||||
|
|||||
|
Re: Older FRC autonomous code
Quote:
Do you need instruction in using MPLAB and downloading code using IFI_Loader or do you already know about that or can figure it out? |
|
#11
|
|||
|
|||
|
Re: Older FRC autonomous code
no i can open the mplab and can upload from the ifi loader
thanks |
|
#12
|
|||
|
|||
|
Re: Older FRC autonomous code
mark i tried the following code from one of my students and it does not seem to work, i will try your code above.
any help is greatly appreciated. by the way i am opening up the user-routine_fast.c to modify the autonomous code is that correct? thanks // Drive forward, turn, return, and stop void Autonomous() { static int counter=0; //keep track of loops to use as a crude timer - static keeps it around from call to call static int autostate=1; //keep track of what step we're supposed to be doing switch (autostate) { case 1: // Drive forward pwm01 = pwm02 = 200; pwm03 = pwm04 = 54; //motor is reversed if (counter>38) //1 second { autostate = 2; // move on to the next step counter = 0; // reset our timer for the next step } case 2: // Turnaround pwm01 = pwm02 = 200; pwm03 = pwm04 = 200; //motor is reversed if (counter>76) //2 seconds { autostate = 3; counter = 0; } case 3: // Drive forward (returning now) pwm01 = pwm02 = 200; pwm03 = pwm04 = 54; //motor is reversed if (counter>38) //1 second { autostate = 4; counter = 0; } case 4: // Stop - What to do when everything else is done default: // also what to do if an invalid autostate occurs pwm01 = pwm02 = pwm03 = pwm04 = 127; // Make sure the last thing you do is always stop } counter++; } |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Autonomous 2010 FRC | Drucifur | Java | 10 | 14-02-2010 08:06 |
| FRC...autonomous or driver-controlled competition? | tribotec_ca88 | General Forum | 28 | 10-03-2005 14:47 |
| Autonomous code | PBoss | Programming | 7 | 14-01-2003 15:29 |
| Autonomous Code | Adrian Wong | Robotics Education and Curriculum | 1 | 18-11-2002 22:34 |