mmolo
20-01-2014, 17:05
Hey everyone, my team is just starting to code our robot in Java. We have some decent Java experience, but we have a question about how autonomousPeriodic is ran. Basically, since the Periodic methods are going to be called every ~20ms if we have code like this:
public void autonomousPeriodic() {
drive.drive(0.5, 0.0);
Timer.delay(3000);
drive.drive(0.0, 0.0);
piston.set(true);
Timer.delay(2000);
piston.set(false);
}
Will this code be called every 20ms and attempt to drive forward and set the pistons 50 times per second?
If so I'm guessing we would just have to wrap it in an if statement that will set a boolean that it's checking to false as soon as it runs, so it only runs the first time.
Thanks in advance!
public void autonomousPeriodic() {
drive.drive(0.5, 0.0);
Timer.delay(3000);
drive.drive(0.0, 0.0);
piston.set(true);
Timer.delay(2000);
piston.set(false);
}
Will this code be called every 20ms and attempt to drive forward and set the pistons 50 times per second?
If so I'm guessing we would just have to wrap it in an if statement that will set a boolean that it's checking to false as soon as it runs, so it only runs the first time.
Thanks in advance!