Package trclib.sensor
Class TrcAbsoluteEncoder
java.lang.Object
trclib.dataprocessor.TrcWrapValueConverter
trclib.sensor.TrcAbsoluteEncoder
- All Implemented Interfaces:
TrcEncoder
This class implements a generic Absolute Encoder that implements the TrcEncoder interface to allow compatibility
to other types of encoders. It extends TrcWrapValueConverter that monitors the crossovers of the encoder value
and convert it to a continuous value.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate doubleprivate doubleprivate doubleprivate doubleFields inherited from class trclib.dataprocessor.TrcWrapValueConverter
instanceName, valueSupplier -
Constructor Summary
ConstructorsConstructorDescriptionTrcAbsoluteEncoder(String instanceName, DoubleSupplier valueSupplier, double rangeLow, double rangeHigh) Constructor: Creates an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptiondoubleThis method returns the raw value of the encoder without the crossover count.doubleThis method reads the raw encoder velocity in encoder units per second.doubleThis method returns the encoder position adjusted by scale and offset.doubleThis method returns the encoder velocity adjusted by scale.booleanThis method checks if the encoder direction is inverted.voidreset()This method resets the encoder revolution counter.voidsetInverted(boolean inverted) This method reverses the direction of the encoder.voidsetScaleAndOffset(double scale, double offset, double zeroOffset) This method sets the encoder scale and offset.Methods inherited from class trclib.dataprocessor.TrcWrapValueConverter
getContinuousValue, isTaskEnabled, resetConverter, setTaskEnabled, toString
-
Field Details
-
sign
private double sign -
scale
private double scale -
offset
private double offset -
zeroOffset
private double zeroOffset
-
-
Constructor Details
-
TrcAbsoluteEncoder
public TrcAbsoluteEncoder(String instanceName, DoubleSupplier valueSupplier, double rangeLow, double rangeHigh) Constructor: Creates an instance of the object.- Parameters:
instanceName- specifies the instance name.valueSupplier- specifies the method to call to get the encoder value.rangeLow- specifies the low range of the value.rangeHigh- specifies the high range of the value.
-
-
Method Details
-
reset
public void reset()This method resets the encoder revolution counter.- Specified by:
resetin interfaceTrcEncoder
-
getRawPosition
public double getRawPosition()This method returns the raw value of the encoder without the crossover count.- Specified by:
getRawPositionin interfaceTrcEncoder- Returns:
- raw encoder value.
-
getScaledPosition
public double getScaledPosition()This method returns the encoder position adjusted by scale and offset.- Specified by:
getScaledPositionin interfaceTrcEncoder- Returns:
- encoder position adjusted by scale and offset.
-
getRawVelocity
public double getRawVelocity()This method reads the raw encoder velocity in encoder units per second.- Specified by:
getRawVelocityin interfaceTrcEncoder- Returns:
- raw encoder velocity in encoder units per second.
-
getScaledVelocity
public double getScaledVelocity()This method returns the encoder velocity adjusted by scale.- Specified by:
getScaledVelocityin interfaceTrcEncoder- Returns:
- encoder velocity adjusted by scale.
-
setInverted
public void setInverted(boolean inverted) This method reverses the direction of the encoder.- Specified by:
setInvertedin interfaceTrcEncoder- Parameters:
inverted- specifies true to reverse the encoder direction, false otherwise.
-
isInverted
public boolean isInverted()This method checks if the encoder direction is inverted.- Specified by:
isInvertedin interfaceTrcEncoder- Returns:
- true if encoder direction is rerversed, false otherwise.
-
setScaleAndOffset
public void setScaleAndOffset(double scale, double offset, double zeroOffset) This method sets the encoder scale and offset.- Specified by:
setScaleAndOffsetin interfaceTrcEncoder- Parameters:
scale- specifies the scale value.offset- specifies the offset value.zeroOffset- specifies the zero offset for absolute encoder.
-