Quote:
Originally Posted by Zer0
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