Thread: Autonomous Help
View Single Post
  #10   Spotlight this post!  
Unread 04-03-2013, 23:01
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,572
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Autonomous Help

Quote:
Originally Posted by Zer0 View Post
Hey maybe this can be some help.

public void autonomousPeriodic()
{
ShooterFront.set(50);
ShooterBack.set(50);
Timer.delay(3.0);
servo.setAngle(90);
Timer.delay(3.0);
servo.setAngle(180);
Timer.delay(3.0);
servo.setAngle(90);
Timer.delay(3.0);
servo.setAngle(180);
Timer.delay(3.0);
servo.setAngle(90);
Timer.delay(3.0);
servo.setAngle(180);
}

The Timer.delay(); sets the amount of time to wait before the execution of the next string of code.
This won't work in the iterative framework (but it will in the simple framework). The AutonomousPeriodic needs to execute quickly and then return. Here's an (untested) way to do the same thing, that will work in the iterative framework

Code:
    double startTime;
    public void autonomousInit() {
        startTime = Timer.getFPGATimestamp();
    }
    public void autonomousPeriodic() {
        if ((Timer.getFPGATimestamp() - startTime) < 3000)
        {
            ShooterFront.set(50);
            ShooterBack.set(50);
        }
        else if ((Timer.getFPGATimestamp() - startTime) < 6000)
        {
            servo.setAngle(90);
        }
        else if ((Timer.getFPGATimestamp() - startTime) < 9000)
        {
            servo.setAngle(180);
        }
   }
etc
Reply With Quote