-
Notifications
You must be signed in to change notification settings - Fork 287
Open
Labels
Description
I think there is a strong case that this should be added to the Simple Autonomous Example in ZTR. Thoughts @Daltz333 / @Kevin-OConnor ? If not where would you put it instead?
Here is the simplest I can think of:
// Auto Time Contants
private Timer timer;
// Modify the numbers on the steps below to control how long each step lasts
private double step1Time = 2;
private double step2Time = step1Time + 3;
private double step3Time = step2Time + 3;
private double step4Time = step3Time + 4;
@Override
public void autonomousInit() {
timer = new Timer();
timer.start();
}
// Only one of the statements will run
if (timer.get() <= step1Time) {
// Do nothing so we don't get in someone else's way.
} else if (timer.get() <= step2Time) {
// Run the elevator and the shooter
m_elevator.set(elevatorSpeed);
m_shooter.set(shooterSpeed);
} else if (timer.get() <= step3Time) {
// Stop the elevator and the shooter. Drive backwards
m_elevator.set(0);
m_shooter.set(0);
m_robotDrive.arcadeDrive(-0.25, 0);
} else if (timer.get() <= step4Time) {
// Stop the drivetrain
m_robotDrive.arcadeDrive(0, 0);
}