Package frclib.sensor
Class FrcEncoder
java.lang.Object
edu.wpi.first.wpilibj.Encoder
frclib.sensor.FrcEncoder
- All Implemented Interfaces:
edu.wpi.first.util.sendable.Sendable
,edu.wpi.first.wpilibj.CounterBase
,AutoCloseable
,TrcEncoder
This interface specifies a common implementation of a generic encoder with which makes different tpes of encoders
compatible with each other.
-
Nested Class Summary
Nested classes/interfaces inherited from class edu.wpi.first.wpilibj.Encoder
edu.wpi.first.wpilibj.Encoder.IndexingType
Nested classes/interfaces inherited from interface edu.wpi.first.wpilibj.CounterBase
edu.wpi.first.wpilibj.CounterBase.EncodingType
-
Field Summary
Fields inherited from class edu.wpi.first.wpilibj.Encoder
m_aSource, m_bSource, m_indexSource
-
Constructor Summary
ConstructorsConstructorDescriptionFrcEncoder
(int channelA, int channelB, edu.wpi.first.wpilibj.CounterBase.EncodingType encodingType) -
Method Summary
Modifier and TypeMethodDescriptiondouble
This method reads the absolute position of the encoder.double
This method reads the raw encoder velocity in encoder units per second.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 encoder direction is inverted.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.Methods inherited from class edu.wpi.first.wpilibj.Encoder
close, get, getDecodingScaleFactor, getDirection, getDistance, getDistancePerPulse, getEncodingScale, getFPGAIndex, getPeriod, getRate, getRaw, getSamplesToAverage, getStopped, initSendable, reset, setDistancePerPulse, setIndexSource, setIndexSource, setIndexSource, setIndexSource, setMaxPeriod, setMinRate, setReverseDirection, setSamplesToAverage, setSimDevice
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface trclib.sensor.TrcEncoder
reset
-
Constructor Details
-
FrcEncoder
public FrcEncoder(int channelA, int channelB, edu.wpi.first.wpilibj.CounterBase.EncodingType encodingType)
-
-
Method Details
-
getRawPosition
public double getRawPosition()This method reads the absolute position of the encoder.- Specified by:
getRawPosition
in interfaceTrcEncoder
- Returns:
- absolute position of the encoder.
-
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 rerversed, 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.
-