Interface Devices


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/modules/robot.md

  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    get(Class<? extends T> type, String name)
    The device with this name and type.
    default com.qualcomm.robotcore.hardware.HardwareMap
    The OpMode's hardwareMap, for code that needs it whole (a path follower); null in tests.
    static Devices
    of(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap)
    The robot's devices, from the OpMode's hardwareMap.
    <T> T
    tryGet(Class<? extends T> type, String name)
    The device with this name and type, or null if there is none (for optional parts).
  • Method Details

    • get

      <T> T get(Class<? extends T> type, String name)
      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.class
      name - the configuration name (exact, case matters)
    • tryGet

      <T> T tryGet(Class<? extends T> type, String name)
      The device with this name and type, or null if there is none (for optional parts).
    • hardwareMap

      default com.qualcomm.robotcore.hardware.HardwareMap hardwareMap()
      The OpMode's hardwareMap, for code that needs it whole (a path follower); null in tests.
    • of

      static Devices of(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap)
      The robot's devices, from the OpMode's hardwareMap.
      Parameters:
      hardwareMap - the OpMode's hardwareMap