Robot and CommandOpMode
Organizing your code with the Robot class and CommandOpMode.
The Robot Class
// disable the Robot
Robot.disable();
// enable the Robot
Robot.enable();Creating a Robot Class
// ... in MyRobot.java (extends Robot)
// enum to specify opmode type
public enum OpModeType {
TELEOP, AUTO
}
// the constructor with a specified opmode type
public MyRobot(OpModeType type) {
if (type == OpModeType.TELEOP) {
initTele();
} else {
initAuto();
}
}
/*
* Initialize teleop or autonomous, depending on which is used
*/
public void initTele() {
// initialize teleop-specific scheduler
}
public void initAuto() {
// initialize auto-specific scheduler
}
// ... in your opmode
// our robot object
Robot m_robot = new MyRobot(MyRobot.OpModeType.TELEOP);