View Single Post
  #8   Spotlight this post!  
Unread 09-02-2012, 22:21
NS_Radication's Avatar
NS_Radication NS_Radication is offline
Student
AKA: Marco Schoener
FRC #1369 (Minotaur)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2009
Location: Tampa
Posts: 88
NS_Radication is an unknown quantity at this point
Re: Set command to run for a certain amount of time

You could try this. This worked for me when I had your EXACT problem.

Code:
public void autonomous()
{
    Timer.start() //starts a timer at 0 seconds
    while(isAutonomous() && isEnabled()) //run when autonomous is Clive and you are enabled
    {
        if(Timer.get() < time) //time is a double in terms of seconds
        {
            driveVariable.drive(speed, curve); //move robot at this speed with/without curve
        }
        Timer.delay(0.005); //does nothing for 5 seconds but helps refresh motors in loop
    }
    Timer.stop() //stops timer
}
Good luck and happy competition!
__________________
Team 1369
Senior
Head Programmer (Java)
Head Electrician
Reply With Quote