Package ftclib.sensor
Class FtcAnalogEncoder
java.lang.Object
ftclib.sensor.FtcAnalogEncoder
- All Implemented Interfaces:
TrcEncoder
This class implements an Analog Absolute Encoders that implements the TrcEncoder interface to allow compatibility
to other types of encoders.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final FtcAnalogInput
private final String
private double
private double
private double
final TrcDbgTrace
private final TrcWrapValueConverter
private double
-
Constructor Summary
ConstructorsConstructorDescriptionFtcAnalogEncoder
(String instanceName) Constructor: Creates an instance of the object.FtcAnalogEncoder
(String instanceName, TrcFilter[] filters) Constructor: Creates an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptiondouble
This method reads the normalized analog input of the encoder.double
This method reads the raw encoder velocity in encoder units per second.double
This method reads the raw voltage from the analog input of the encoder.double
This method returns the encoder position adjusted by scale and offset.double
This method returns the encoder velocity adjusted by scale.boolean
This method checks if the Cardinal Converter task is enabled.boolean
This method checks if the encoder direction is inverted.void
reset()
This method resets the encoder revolution counter (Cardinal Converter).void
setEnabled
(boolean enabled) This method enables/disables the Wrap Value Converter task.void
setInverted
(boolean inverted) This method reverses the direction of the encoder.void
setScaleAndOffset
(double scale, double offset, double zeroOffset) This method sets the encoder scale and offset.
-
Field Details
-
tracer
-
instanceName
-
analogInput
-
wrapValueConverter
-
sign
private double sign -
scale
private double scale -
offset
private double offset -
zeroOffset
private double zeroOffset
-
-
Constructor Details
-
FtcAnalogEncoder
Constructor: Creates an instance of the object.- Parameters:
instanceName
- specifies the instance name.filters
- specifies an array of filter objects, one for each axis, to filter sensor data. If no filter is used, this can be set to null.
-
FtcAnalogEncoder
Constructor: Creates an instance of the object.- Parameters:
instanceName
- specifies the instance name.
-
-
Method Details
-
setEnabled
public void setEnabled(boolean enabled) This method enables/disables the Wrap Value Converter task.- Parameters:
enabled
- specifies true to enable wrap value converter, false to disable.
-
isEnabled
public boolean isEnabled()This method checks if the Cardinal Converter task is enabled.- Returns:
- true if cardinal converter is enabled, false if disabled.
-
getRawVoltage
public double getRawVoltage()This method reads the raw voltage from the analog input of the encoder.- Returns:
- raw voltage of the analog encoder.
-
reset
public void reset()This method resets the encoder revolution counter (Cardinal Converter).- Specified by:
reset
in interfaceTrcEncoder
-
getRawPosition
public double getRawPosition()This method reads the normalized analog input of the encoder.- Specified by:
getRawPosition
in interfaceTrcEncoder
- Returns:
- normalized input of the encoder in the unit of percent rotation (0 to 1).
-
getScaledPosition
public double getScaledPosition()This method returns the encoder position adjusted by scale and offset.- Specified by:
getScaledPosition
in 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:
getRawVelocity
in 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:
getScaledVelocity
in interfaceTrcEncoder
- Returns:
- encoder velocity adjusted by scale.
-
setInverted
public void setInverted(boolean inverted) This method reverses the direction of the encoder.- Specified by:
setInverted
in 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:
isInverted
in interfaceTrcEncoder
- Returns:
- true if encoder direction is reversed, false otherwise.
-
setScaleAndOffset
public void setScaleAndOffset(double scale, double offset, double zeroOffset) This method sets the encoder scale and offset.- Specified by:
setScaleAndOffset
in interfaceTrcEncoder
- Parameters:
scale
- specifies the scale value.offset
- specifies the offset value.zeroOffset
- specifies the zero offset for absolute encoder.
-