Package com.revrobotics.encoder
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 com.revrobotics.NativeResourceCleaner
NativeResourceCleaner.OnClean -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal DetachedEncoderAccessorAccessor for Detached encoder parameter values. -
Constructor Summary
ConstructorsConstructorDescriptionDetachedEncoder(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.doublegetAngle()Get the absolute position of the 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.doubleGet the position of the encoder.doubleGet 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.doubleGet the velocity of the encoder.setPosition(double position) Set the position of the encoder.Methods inherited from class com.revrobotics.NativeResourceCleaner
registerCleaner
-
Field Details
-
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
Create a new object to control a Detached Encoder- Parameters:
id- The device ID.model- The specific model of detached encoder
-
-
Method Details
-
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
public double getPosition()Get the position of the encoder. This returns the native units of 'rotations' by default, and can be changed by a scale factor usingDetachedEncoderConfig.positionConversionFactor(float).- Specified by:
getPositionin interfaceRelativeEncoder- Returns:
- Number of rotations of the encoder
-
getAngle
public double getAngle()Get the absolute position of the encoder. This returns the native units of 'rotations' [0, 1) by default, and can be changed by a scale factor usingDetachedEncoderConfig.positionConversionFactor(float).- Returns:
- Number of rotations of the encoder
-
getRawAngle
public double getRawAngle()Get the absolute position of the encoder. This returns the native units of 'rotations' [0, 1) without scaling from conversion factors.- Returns:
- Number of rotations of the encoder
-
getVelocity
public double getVelocity()Get the velocity of the encoder. This returns the native units of 'RPM' by default, and can be changed by a scale factor usingDetachedEncoderConfig.velocityConversionFactor(float).- Specified by:
getVelocityin interfaceRelativeEncoder- Returns:
- Number the RPM of the encoder
-
setPosition
Set the position of the encoder. By default the units are 'rotations' and can be changed by a scale factor usingDetachedEncoderConfig.positionConversionFactor(float).- 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.- 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
-