View Single Post
  #2   Spotlight this post!  
Unread 19-08-2012, 00:07
Ginto8's Avatar
Ginto8 Ginto8 is offline
Programming Lead
AKA: Joe Doyle
FRC #2729 (Storm)
Team Role: Programmer
 
Join Date: Oct 2010
Rookie Year: 2010
Location: Marlton, NJ
Posts: 174
Ginto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of light
Re: Switching between Kinect drive / Joystick drive / Autonomous drive

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.
Reply With Quote