OpModes
Each way the robot can run is its own class, marked with an annotation. Project Setup generated one marked @Teleop. On branch mech-2-Commands you edit it so the controller's buttons run the commands you just wrote.
- The three commands on each mechanism from Writing Commands, building clean.
- The
robot.armandrobot.flywheelfields from Mechanisms.
What mechanism are you working on?
The lesson below is written for the one you pick. Switch back any time to read it for the other.
The generated MyTeleop
Open src/main/java/first/robot/opmode/MyTeleop.java. The New Project Creator wrote it with @Teleop on the class, and that annotation is the whole registration. The framework finds every annotated class on its own, and the driver station lists each one by name. There is no RobotContainer in this project and nothing else to edit.
The generated file holds five empty methods with comments in them: disabledPeriodic, start, periodic, end and close. A teleop built from commands needs none of them, and you replace the whole class below. Edit this file rather than making a new one. A second @Teleop class puts two teleops on the driver station.
MyAuto.java beside it is marked @Autonomous and stays empty for now. Autonomous routines arrive in Workshop 4, where Coroutines writes the first one.
Check your work
Run WPILib: Build Robot Code. Nothing moves until Hardware Simulation, so check the file as well as the build.
You should see
BUILD SUCCESSFULas the last line of the terminal.- One hit when you search the
opmodefolder for@Teleop. - A
whileFalseon every binding line you kept.
cannot find symbol: variable flywheel, or arm, means a binding names a mechanism your Robot does not build. Delete that line.
Check yourself
You release the right trigger. What is the flywheel doing a moment later?
Instead of editing MyTeleop, a teammate makes a new TeleopOpMode.java with @Teleop on it and the same bindings. What goes wrong?
You built only the arm, and the build stops on cannot find symbol: variable flywheel. What do you change?
The driver switches from Teleop to Autonomous. What happens to the bindings made in MyTeleop's constructor?