Package com.crossbotics.ftchelper.robot
Interface Devices
- All Known Implementing Classes:
PretendDevices
public interface Devices
Where the modules find their motors, servos and sensors by configuration name. On the robot it is
the OpMode's
hardwareMap (of(HardwareMap)); tests give pretend devices instead.
You rarely need it yourself: RobotDefinition hands it to every module.
Docs: docs/reference/robot-java.md
-
Method Summary
Modifier and TypeMethodDescriptiondefault DoubleSupplierThe battery's voltage for code that runs every loop (the launcher's battery compensation): on the robotHw.batteryReader(com.qualcomm.robotcore.hardware.HardwareMap), which asks the hubs on the library's helper thread and never waits; in tests (no hardwareMap) it asksbatteryVolts()directly.default doubleThe battery's voltage now (volts), from the hubs (Hw.batteryVolts(com.qualcomm.robotcore.hardware.HardwareMap)); NaN with no voltage sensor (tests).<T> TThe device with this name and type.default com.qualcomm.robotcore.hardware.HardwareMapThe OpMode's hardwareMap, for code that needs it whole (a path follower); null in tests.default booleanTrue if the configuration has a device with this name, of any type.static Devicesof(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap) The robot's devices, from the OpMode's hardwareMap.<T> TThe device with this name and type, or null if there is none (for optional parts).
-
Method Details
-
get
The device with this name and type. Stops with a clear message (the names that DO exist) if it is not in the configuration.- Parameters:
type- the device type, e.g.DcMotorEx.classname- the configuration name (exact, case matters)
-
tryGet
The device with this name and type, or null if there is none (for optional parts). -
has
True if the configuration has a device with this name, of any type. Used for parts markedModule.optional(): one whose device is not there is left off instead of stopping INIT. Default: asks the hardwareMap; with no hardwareMap (pretend devices in tests) every name is there.- Parameters:
name- the configuration name (exact, case matters)
-
hardwareMap
default com.qualcomm.robotcore.hardware.HardwareMap hardwareMap()The OpMode's hardwareMap, for code that needs it whole (a path follower); null in tests. -
batteryVolts
default double batteryVolts()The battery's voltage now (volts), from the hubs (Hw.batteryVolts(com.qualcomm.robotcore.hardware.HardwareMap)); NaN with no voltage sensor (tests). Each call asks the hubs and waits (a few milliseconds): not for the loop. The launcher usesbatteryReader()instead. -
batteryReader
The battery's voltage for code that runs every loop (the launcher's battery compensation): on the robotHw.batteryReader(com.qualcomm.robotcore.hardware.HardwareMap), which asks the hubs on the library's helper thread and never waits; in tests (no hardwareMap) it asksbatteryVolts()directly. -
of
The robot's devices, from the OpMode's hardwareMap.- Parameters:
hardwareMap- the OpMode'shardwareMap
-