Class Module<M extends Module<M>>
- All Implemented Interfaces:
Subsystem
- Direct Known Subclasses:
Camera,Hood,Indexer,Intake,Launcher,Lights,MotorPositions,Pieces,PieceSensor,ServoPositions,Turret
Robot.java: an Intake, a Lift, a Claw...
Each module brings four things: its line in Robot.java, its section in Tunables.java,
its usual buttons (the lines Controls.java writes for it; added by themselves only with
useStandardButtons() true) and its lines in the simulator robot file.
lift = add(Lift.slide("lift").bottomSwitch("lift_bottom")); // in Robot.java's define()
The module's numbers come from the Tunables.java section with the device's name in
CamelCase: device "intake_deploy" reads Tunables.IntakeDeploy. Pick another section with
tunables(String).
<M extends Module<M>> lets each setting below hand back the module's own type, so
Lift.slide("lift").tunables("Slide") is still a Lift.
Docs: docs/reference/robot-java.md
-
Method Summary
Modifier and TypeMethodDescriptionvoidThe part's telemetry line; each module adds its own.The main device's configuration name, e.g.booleanTrue if it was markedoptional()in Robot.java.booleanTrue if the part is on the robot: false only for anoptional()part whose device was not in the configuration at INIT (true before INIT).How the part looks and where it sits (Shape), for the simulator's 3D view and size checks.name()The name shown on the Driver Station and the Tunables section: "Lift", "IntakeDeploy".optional()This part may not be on the robot yet.The main device's parts catalog id: a motor (Motors, e.g.partId()The parts catalog id given withpart(...)in Robot.java, or null.Reads this module's numbers from anotherTunables.javasection.zone()This part's zone for an interlock rule (Interlock): between two numbers, read from the rule's Tunables section as<part>Fromand<part>To(in the part's own units).This part's zone from<part>Aboveup (to the top of its range).This part's zone from<part>Belowdown.
-
Method Details
-
tunables
Reads this module's numbers from anotherTunables.javasection.- Parameters:
sectionName- the section's class name, e.g. "Slide"- Returns:
- this module
-
part
The main device's parts catalog id: a motor (Motors, e.g. "gobilda-5203-117") or a servo (Parts.servo(java.lang.String, double, double, double, double), e.g. "gobilda-2000-speed"). The simulator then moves a motor or servo like the real one. For a continuous-rotation (CR) servo the id is only a note in the robot file (the simulator turns every CR servo at one speed).- Parameters:
catalogId- the id; a typo stops with the list of known ids- Returns:
- this module
-
looks
How the part looks and where it sits (Shape), for the simulator's 3D view and size checks. This part moves them: an intake spins its rollers, a positioner swings its arm.- Parameters:
shapes- one or more, e.g.Shape.roller("offset-tubing-90").atMm(200, 0, 50).lengthMm(240)- Returns:
- this module
-
optional
This part may not be on the robot yet. If its device (the name inadd(...), e.g. "intake_deploy") is not in the robot configuration, INIT does not stop: it shows one note, and the part is "off" until it is added. Robots are built in steps: write the whole robot in Robot.java now, and each part starts working the day its device is in the configuration.intakeDeploy = add(Positioner.servo("intake_deploy").part("gobilda-2000-torque").optional()); // Robot.javaWhile it is off: every command to it is ignored (
isPresent()is false), its telemetry line is "-", anActionskips it (and the waits right after it) and goes on, its buttons show "off" on the button map, and an interlock rule with it is off. Its question methods never hold anything up: it counts as done and at its target, and never as running, ready or full. Only its FIRST device decides: if "intake_deploy" is there, every other device of the part must be too (half a part is a wiring mistake: INIT stops and says which). Not for the drive (a robot always drives).- Returns:
- this module
-
isOptional
public boolean isOptional()True if it was markedoptional()in Robot.java. -
isPresent
public boolean isPresent()True if the part is on the robot: false only for anoptional()part whose device was not in the configuration at INIT (true before INIT). Use it for code the library cannot see, e.g.if (robot.intakeDeploy.isPresent()) ...; buttons can use.needs(part). -
name
The name shown on the Driver Station and the Tunables section: "Lift", "IntakeDeploy". -
deviceName
The main device's configuration name, e.g. "lift". -
partId
The parts catalog id given withpart(...)in Robot.java, or null. -
zone
This part's zone for an interlock rule (Interlock): between two numbers, read from the rule's Tunables section as<part>Fromand<part>To(in the part's own units).keepApart("TurretLift", turret.zone(), lift.zoneAbove()); // Robot.java -
zoneAbove
This part's zone from<part>Aboveup (to the top of its range). Seezone(). -
zoneBelow
This part's zone from<part>Belowdown. Seezone(). -
addTelemetry
The part's telemetry line; each module adds its own.- Specified by:
addTelemetryin interfaceSubsystem
-