Class ExpansionHub

java.lang.Object
org.wpilib.hardware.expansionhub.ExpansionHub
All Implemented Interfaces:
AutoCloseable

public class ExpansionHub extends Object implements AutoCloseable
This class controls a REV ExpansionHub plugged in over USB to Systemcore.
  • Constructor Details

    • ExpansionHub

      public ExpansionHub(int usbId)
      Constructs a new ExpansionHub for a given USB ID

      Multiple instances can be constructed, but will point to the same backing object with a ref count.

      Parameters:
      usbId - The USB Port ID the hub is plugged into.
  • Method Details

    • close

      public void close()
      Closes an ExpansionHub object. Will not close any other instances until the last instance is closed.
      Specified by:
      close in interface AutoCloseable
    • makeServo

      public ExpansionHubServo makeServo(int channel)
      Constructs a servo at the requested channel on this hub.

      Only a single instance of each servo per hub can be constructed at a time.

      Parameters:
      channel - The servo channel
      Returns:
      Servo object
    • makeMotor

      public ExpansionHubMotor makeMotor(int channel)
      Constructs a motor at the requested channel on this hub.

      Only a single instance of each motor per hub can be constructed at a time.

      Parameters:
      channel - The motor channel
      Returns:
      Motor object
    • isHubConnected

      public boolean isHubConnected()
      Gets if the hub is currently connected over USB.
      Returns:
      True if hub connection, otherwise false
    • getUsbId

      public int getUsbId()
      Gets the USB ID of this hub.
      Returns:
      The USB ID