SET-02: A part that is not on the robot yet - optional() and the COMPETITION warning
- Your robot needs: any robot.
- Starter bots that fit: goBILDA starter bot, REV DUO starter bot, AndyMark Robits starter bot, Studica starter bot.
- Library version: v0.17.0 or newer.
- The docs it tests: Robot module (the robot in five files), The simulator: a pretend Control Hub and Driver Hub.
Why
Robots are built in steps. With .optional(), a part whose device is not in the configuration yet is simply off: INIT goes on, its buttons are off, and actions and autonomous skip it. At an event the same thing could hide a misspelled configuration name, so in the COMPETITION profile it is a loud warning.
Safety
- Real robot: the other parts move as usual. Clear floor, a hand on STOP.
Setup
- A part in
Robot.javayou can take out of the configuration (an intake, a servo). Add.optional()to its line, for exampleintakeDeploy = add(Positioner.servo("intake_deploy").optional());. - An action or an autonomous step that uses it, and a button that uses it.
- Simulator: your robot from
Robot.java(:sim:fromRobot), then addmissing = intake_deploy(your device's name) as a line insimulator/robot.properties. - Real robot: a copy of the configuration on the Driver Station without that device (or with its name changed).
Steps
- INIT your TeleOp (PRACTICE profile). Read the note:
"intake_deploy" not in the configuration: IntakeDeploy is off (optional part). INIT does not stop. - Open the button map (GUIDE): the part's buttons say
- off: IntakeDeploy not on the robot. - START. Press the part's button: nothing moves, no error.
- Run the action (or the autonomous): it goes on, and its report says
skipped IntakeDeploy (not on the robot). - Choose the COMPETITION profile (the last line of an autonomous's INIT menu; it is saved on the hub). INIT TeleOp again: the very first line is
!! COMPETITION: "intake_deploy" not in the configuration: IntakeDeploy is OFF ..., and the button map says!! OFF. - Put the device back in the configuration (simulator: delete the
missingline). INIT: the part works, with no code change. - Take
.optional()off and remove the device again. INIT must stop and name the device. Put it back. Set the profile back to PRACTICE.
Pass rule
INIT goes on with the part off (steps 1 to 4, no error), the COMPETITION warning is the first line of the screen (1 of 1), and without optional() a missing device stops INIT (1 of 1).
Record
Write these down while you test. The report form has them as a list to fill in.
- the part (kind and device name) and simulator or real robot
- the INIT lines in PRACTICE and COMPETITION (copy them)
- the action's report line from step 4
- anything that moved, or an error, while the part was off
If your robot is different
Any part but the drive and the odometry can be optional. A part with several devices (a lift with a switch, a launcher with a feeder): only the first device decides. Try removing a second device too: INIT must stop and name it (half a part is a wiring mistake). Say what you tried.
Report your result
Pass, fail, or could not run: every result helps. The form opens on GitHub with this test filled in (a free GitHub account is needed). No student names, please.
Report resultNo reports for this test yet: yours would be the first. Every test's reports.
All tests · Next: AIM-03 Whole-robot aim - the robot turns to the goal while you drive
Something wrong on this page? Tell us with a short GitHub form.