Package com.revrobotics.servohub
Class ServoHub
java.lang.Object
com.revrobotics.servohub.ServoHubLowLevel
com.revrobotics.servohub.ServoHub
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
static class
static enum
static class
Nested classes/interfaces inherited from class com.revrobotics.servohub.ServoHubLowLevel
ServoHubLowLevel.FirmwareVersion, ServoHubLowLevel.PeriodicStatus0, ServoHubLowLevel.PeriodicStatus1, ServoHubLowLevel.PeriodicStatus2, ServoHubLowLevel.PeriodicStatus3, ServoHubLowLevel.PeriodicStatus4
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal ServoHubConfigAccessor
Accessor for ServoHub parameter values.Fields inherited from class com.revrobotics.servohub.ServoHubLowLevel
servoHubHandle
-
Constructor Summary
ConstructorsConstructorDescriptionServoHub
(int busId, int deviceId) Create a new object to control a ServoHub Servo Controller -
Method Summary
Modifier and TypeMethodDescriptionClears all sticky faults.configure
(ServoHubConfig config, ServoHub.ResetMode resetMode) Set the configuration for the ServoHub.configureAsync
(ServoHubConfig config, ServoHub.ResetMode resetMode) Set the configuration for the ServoHub without waiting for a response.double
double
Get the active faults that are currently present on the ServoHub.getServoChannel
(ServoChannel.ChannelId channelId) Returns an object to control a specific servo channel.double
Get the sticky faults that were present on the ServoHub at one point since the sticky faults were last cleared.Get the sticky warnings that were present on the ServoHub at one point since the sticky warnings were last cleared.Get the active warnings that are currently present on the ServoHub.boolean
Get whether the ServoHub has one or more active faults.boolean
Get whether the ServoHub has one or more active warnings.boolean
Get whether the ServoHub has one or more sticky faults.boolean
Get whether the ServoHub has one or more sticky warnings.setBankPulsePeriod
(ServoHub.Bank bank, int pulsePeriod_us) Set the Pulse Period for servo channels 0-2 or servo channels 3-5.Methods inherited from class com.revrobotics.servohub.ServoHubLowLevel
close, createSimFaultManager, getBusId, getControlFramePeriodMs, getDeviceId, getFirmwareVersion, getFirmwareVersionString, getPeriodicStatus0, getPeriodicStatus1, getPeriodicStatus2, getPeriodicStatus3, getPeriodicStatus4, setCANMaxRetries, setCANTimeout, setControlFramePeriodMs, setPeriodicFrameTimeout, throwIfClosed
-
Field Details
-
configAccessor
Accessor for ServoHub parameter values. This object contains fields and methods to retrieve parameters that have been applied to the device. To set parameters, seeServoHubConfig
andconfigure(ServoHubConfig, ServoHub.ResetMode)
.NOTE: This uses calls that are blocking to retrieve parameters and should be used infrequently.
-
-
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
Set the configuration for the ServoHub.If
resetMode
isServoHub.ResetMode.kResetSafeParameters
, this method will reset safe writable parameters to their default values before setting the given configuration.- Parameters:
config
- The desired ServoHub configurationresetMode
- Whether to reset safe parameters before setting the configuration- Returns:
REVLibError.kOk
if successful
-
configureAsync
Set the configuration for the ServoHub without waiting for a response.If
resetMode
isServoHub.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 configurationresetMode
- 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
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
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
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
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
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
Returns an object to control a specific servo channel.- Parameters:
channelId
- The specific servo channel to get- Returns:
- The specified ServoChannel
-
setBankPulsePeriod
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 setpulsePeriod_us
- The pulse period in microseconds- Returns:
REVLibError.kOk
if successful
-