Class DetachedEncoder
java.lang.Object
com.revrobotics.NativeResourceCleaner
com.revrobotics.encoder.DetachedEncoder
- All Implemented Interfaces:
RelativeEncoder, REVDevice
- Direct Known Subclasses:
SplineEncoder
public abstract class DetachedEncoder
extends NativeResourceCleaner
implements REVDevice, RelativeEncoder
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordstatic final recordstatic enumstatic final recordstatic final recordstatic final recordstatic final recordstatic final recordNested classes/interfaces inherited from class NativeResourceCleaner
NativeResourceCleaner.OnClean -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal DetachedEncoderAccessorAccessor for Detached encoder parameter values.protected long -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDetachedEncoder(int busId, int id, DetachedEncoder.Model model) Create a new object to control a Detached Encoder from a raw CAN bus ID.DetachedEncoder(org.wpilib.hardware.bus.CANPort canPort, int id, DetachedEncoder.Model model) Create a new object to control a Detached Encoder -
Method Summary
Modifier and TypeMethodDescriptionvoidClears all sticky faults.voidclose()Closes the Detached encoder controllervoidconfigure(DetachedEncoderConfig config, ResetMode resetMode) Set the configuration for the Detached encoder.getAngle()Get the absolute position of the encoder.org.wpilib.hardware.bus.CANPortGet the configured CAN port of the Detached Encoder.protected NativeResourceCleaner.OnCleanNote: it is important that no reference to 'this' is taken in the implementation.intGet the configured Device ID of the Detached encoder.Get the active faults that are currently present on the detached encoder.Get the firmware version of the detached encoder.getModel()Get the Model of this Detached Encoder Device.Get the position of the encoder.Get the absolute position of the encoder.Get the sticky faults that were present on the detached encoder at one point since the sticky faults were last cleared.Get the velocity of the encoder.setPosition(double position) Set the position of the encoder.Methods inherited from class NativeResourceCleaner
registerCleaner
-
Field Details
-
handle
protected long handle -
detachedEncoderAccessor
Accessor for Detached encoder parameter values. This object contains fields and methods to retrieve parameters that have been applied to the device. To set parameters, seeDetachedEncoderConfigandconfigure(DetachedEncoderConfig, com.revrobotics.ResetMode).NOTE: This uses calls that are blocking to retrieve parameters and should be used infrequently.
-
-
Constructor Details
-
DetachedEncoder
public DetachedEncoder(org.wpilib.hardware.bus.CANPort canPort, int id, DetachedEncoder.Model model) Create a new object to control a Detached Encoder- Parameters:
canPort- The CAN port this device is connected to.id- The device ID.model- The specific model of detached encoder
-
DetachedEncoder
Create a new object to control a Detached Encoder from a raw CAN bus ID. For internal tooling that manages buses not representable as a CANPort;getCanPort()will throw if the bus ID is not a valid CANPort value.- Parameters:
busId- The raw CAN bus ID this device is on.id- The device ID.model- The specific model of detached encoder
-
-
Method Details
-
getCanPort
public org.wpilib.hardware.bus.CANPort getCanPort()Get the configured CAN port of the Detached Encoder.- Returns:
- CANPort The CAN port this device is connected to
-
getDeviceId
public int getDeviceId()Get the configured Device ID of the Detached encoder.- Returns:
- int device ID
-
getModel
Get the Model of this Detached Encoder Device. Useful for determining if this is a MAXSpline, or other device- Returns:
- the model of this encoder
-
getPosition
Get the position of the encoder. This returns the native units of 'rotations'.- Specified by:
getPositionin interfaceRelativeEncoder- Returns:
- Number of rotations of the encoder
-
getAngle
-
getRawAngle
-
getVelocity
Get the velocity of the encoder. This returns the native units of 'RPM'.- Specified by:
getVelocityin interfaceRelativeEncoder- Returns:
- Number the RPM of the encoder
-
setPosition
Set the position of the encoder. The units are 'rotations'.- Specified by:
setPositionin interfaceRelativeEncoder- Parameters:
position- Number of rotations of the motor- Returns:
REVLibError.kOkif successful
-
getFaults
Get the active faults that are currently present on the detached encoder. Faults are fatal errors that prevent the encoder from functioning.- Returns:
- A struct with each fault and their active value
-
getStickyFaults
Get the sticky faults that were present on the detached encoder at one point since the sticky faults were last cleared. Faults are fatal errors that prevent the encoder from functioning.Sticky faults can be cleared with
clearFaults().- Returns:
- A struct with each fault and their sticky value
-
clearFaults
public void clearFaults()Clears all sticky faults. -
getFirmwareVersion
Get the firmware version of the detached encoder.- Returns:
- Firmware version object
-
configure
Set the configuration for the Detached encoder.If
resetModeis {com.revrobotics.ResetMode#kResetSafeParameters}, this method will reset safe writable parameters to their default values before setting the given configuration. The following parameters will not be reset by this action: CAN ID and Absolute (Duty Cycle) Zero Offset.- Parameters:
config- The desired Detached encoder configurationresetMode- Whether to reset safe parameters before setting the configuration
-
getStatus0
- Returns:
- periodic status 0, or null if it's not found
-
getStatus1
- Returns:
- periodic status 1, or null if it's not found
-
getStatus2
- Returns:
- periodic status 2, or null if it's not found
-
getStatus3
- Returns:
- periodic status 3, or null if it's not found
-
getStatus4
- Returns:
- periodic status 4, or null if it's not found
-
close
public void close()Closes the Detached encoder controller -
getCleanAction
Description copied from class:NativeResourceCleanerNote: it is important that no reference to 'this' is taken in the implementation.- Specified by:
getCleanActionin classNativeResourceCleaner- Returns:
- an action to run on clean
-