Code:
public class Robot extends IterativeRobot {
Scheduler scheduler;
Command autonomousCommand,teleopCommand;
public void robotInit() {
scheduler = Scheduler.getInstance();
CommandBase.init();
autonomousCommand = new AutonomousCommand();
teleopCommand = new TeleopCommand();
}
public void autonomousInit() {
teleopCommand.cancel();
autonomousCommand.start();
}
public void autonomousPeriodic() {
scheduler.run();
}
public void teleopInit() {
autonomousCommand.cancel();
teleopCommand.start();
}
public void teleopPeriodic() {
scheduler.run();
}
public void disabledInit() {
teleopCommand.cancel();
autonomousCommand.cancel();
}
}
This will cause teleopCommand to run only during teleop, autonomousCommand in only autonomous, and neither in disabled. AutonomousCommand and TeleopCommand can be defined by you or changed to whatever you want, as long as they inherit Command.