Class ServoHub


public class ServoHub extends ServoHubLowLevel
  • Field Details

  • Constructor Details

    • ServoHub

      public ServoHub(int busId, int deviceId)
      Create a new object to control a ServoHub Servo Controller
      Parameters:
      busId - The bus ID.
      deviceId - The device ID.
  • Method Details

    • configure

      public REVLibError configure(ServoHubConfig config, ServoHub.ResetMode resetMode)
      Set the configuration for the ServoHub.

      If resetMode is ServoHub.ResetMode.kResetSafeParameters, this method will reset safe writable parameters to their default values before setting the given configuration.

      Parameters:
      config - The desired ServoHub configuration
      resetMode - Whether to reset safe parameters before setting the configuration
      Returns:
      REVLibError.kOk if successful
    • configureAsync

      public REVLibError configureAsync(ServoHubConfig config, ServoHub.ResetMode resetMode)
      Set the configuration for the ServoHub without waiting for a response.

      If resetMode is ServoHub.ResetMode.kResetSafeParameters, this method will reset safe writable parameters to their default values before setting the given configuration.

      NOTE: This method will immediately return REVLibError.kOk and the action will be done in the background. Any errors that occur will be reported to the driver station.

      Parameters:
      config - The desired ServoHub configuration
      resetMode - Whether to reset safe parameters before setting the configuration
      Returns:
      REVLibError.kOk
      See Also:
    • hasActiveFault

      public boolean hasActiveFault()
      Get whether the ServoHub has one or more active faults.
      Returns:
      true if there is an active fault
      See Also:
    • hasStickyFault

      public boolean hasStickyFault()
      Get whether the ServoHub has one or more sticky faults.
      Returns:
      true if there is a sticky fault
      See Also:
    • hasActiveWarning

      public boolean hasActiveWarning()
      Get whether the ServoHub has one or more active warnings.
      Returns:
      true if there is an active warning
      See Also:
    • hasStickyWarning

      public boolean hasStickyWarning()
      Get whether the ServoHub has one or more sticky warnings.
      Returns:
      true if there is a sticky warning
      See Also:
    • getFaults

      public ServoHub.Faults getFaults()
      Get the active faults that are currently present on the ServoHub. Faults are fatal errors that prevent the motor from running.
      Returns:
      A struct with each fault and their active value
    • getStickyFaults

      public ServoHub.Faults getStickyFaults()
      Get the sticky faults that were present on the ServoHub at one point since the sticky faults were last cleared. Faults are fatal errors that prevent the motor from running.

      Sticky faults can be cleared with clearFaults().

      Returns:
      A struct with each fault and their sticky value
    • getWarnings

      public ServoHub.Warnings getWarnings()
      Get the active warnings that are currently present on the ServoHub. Warnings are non-fatal errors.
      Returns:
      A struct with each warning and their active value
    • getStickyWarnings

      public ServoHub.Warnings getStickyWarnings()
      Get the sticky warnings that were present on the ServoHub at one point since the sticky warnings were last cleared. Warnings are non-fatal errors.

      Sticky warnings can be cleared with clearFaults().

      Returns:
      A struct with each warning and their sticky value
    • clearFaults

      public REVLibError clearFaults()
      Clears all sticky faults.
      Returns:
      REVLibError.kOk if successful
    • getDeviceVoltage

      public double getDeviceVoltage()
      Returns:
      The voltage fed into the servo controller.
    • getDeviceCurrent

      public double getDeviceCurrent()
      Returns:
      The servo controller's output current in Amps.
    • getServoVoltage

      public double getServoVoltage()
      Returns:
      The voltage fed to the actual servos.
    • getServoChannel

      public ServoChannel getServoChannel(ServoChannel.ChannelId channelId)
      Returns an object to control a specific servo channel.
      Parameters:
      channelId - The specific servo channel to get
      Returns:
      The specified ServoChannel
    • setBankPulsePeriod

      public REVLibError setBankPulsePeriod(ServoHub.Bank bank, int pulsePeriod_us)
      Set the Pulse Period for servo channels 0-2 or servo channels 3-5.
      Parameters:
      bank - The bank of channels (0-2 or 3-5) to set
      pulsePeriod_us - The pulse period in microseconds
      Returns:
      REVLibError.kOk if successful