Package lib.custom.sensors
Class CANEncoder
java.lang.Object
lib.custom.CustomCAN
lib.custom.sensors.CANSensor
lib.custom.sensors.CANEncoder
- All Implemented Interfaces:
CustomEncoder,NativeDerivativeSensor
Encoder over CAN Implements CustomEncoder generic encoder class
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCANEncoder(int id) CANEncoder(int id, boolean reverseDirection) CANEncoder(int id, boolean reverseDirection, double distancePerPulse) CANEncoder(int id, double distancePerPulse) CANEncoder(String name, int id) CANEncoder(String name, int id, boolean reverseDirection) CANEncoder(String name, int id, boolean reverseDirection, double distancePerPulse) CANEncoder(String name, int id, double distancePerPulse) -
Method Summary
Modifier and TypeMethodDescriptionbooleanGets direction of most recent movementbooleanReturns the most recent direction of movement (based on the speed)doubleGets current distancedoubleSets PID mode PIDSourceType is either PIDSourceType.kDisplacement or PIDSourceType.kRate.doubleReturns the scaled distance rotated by the encoder.doublegetRate()Gets ratedoubleReturns the rate of rotationbooleanGets inversion statebooleanReturns true when stoppedbooleanReturns true when stoppedvoidreset()Resets the distance traveled for the encodervoidvoidresetViaOffset(double setpoint) voidsetDistancePerPulse(double distancePerPulse) Sets the distance per pulsevoidsetReverseDirection(boolean reverseDirection) To the surprise of everyone, enables and disables reverse directionMethods inherited from class lib.custom.sensors.CANSensor
getSensorStatuses, readSensorMethods inherited from class lib.custom.CustomCAN
getName, read, readBuffer, readSafely, write, writeSafely
-
Field Details
-
RESET_NUMBER_TRIES
protected static final int RESET_NUMBER_TRIES- See Also:
-
-
Constructor Details
-
CANEncoder
-
CANEncoder
-
CANEncoder
-
CANEncoder
public CANEncoder(int id, boolean reverseDirection, double distancePerPulse) -
CANEncoder
-
CANEncoder
public CANEncoder(int id, boolean reverseDirection) -
CANEncoder
public CANEncoder(int id, double distancePerPulse) -
CANEncoder
public CANEncoder(int id)
-
-
Method Details
-
getDistancePerPulse
public double getDistancePerPulse()Sets PID mode PIDSourceType is either PIDSourceType.kDisplacement or PIDSourceType.kRate.- Specified by:
getDistancePerPulsein interfaceCustomEncoder
-
setDistancePerPulse
public void setDistancePerPulse(double distancePerPulse) Description copied from interface:CustomEncoderSets the distance per pulse- Specified by:
setDistancePerPulsein interfaceCustomEncoder
-
getReverseDirection
public boolean getReverseDirection()Description copied from interface:CustomEncoderGets inversion state- Specified by:
getReverseDirectionin interfaceCustomEncoder
-
setReverseDirection
public void setReverseDirection(boolean reverseDirection) Description copied from interface:CustomEncoderTo the surprise of everyone, enables and disables reverse direction- Specified by:
setReverseDirectionin interfaceCustomEncoder
-
getDistanceSafely
Returns the scaled distance rotated by the encoder.- Specified by:
getDistanceSafelyin interfaceCustomEncoder- Throws:
InvalidSensorException
-
getDirectionSafely
Returns the most recent direction of movement (based on the speed)- Specified by:
getDirectionSafelyin interfaceCustomEncoder- Throws:
InvalidSensorException
-
getRateSafely
Returns the rate of rotation- Specified by:
getRateSafelyin interfaceNativeDerivativeSensor- Throws:
InvalidSensorException
-
getStoppedSafely
public boolean getStoppedSafely()Returns true when stopped- Specified by:
getStoppedSafelyin interfaceCustomEncoder
-
reset
public void reset()Resets the distance traveled for the encoder- Specified by:
resetin interfaceCustomEncoder
-
resetViaOffset
public void resetViaOffset(double setpoint) -
resetViaOffset
public void resetViaOffset() -
getDistance
public double getDistance()Description copied from interface:CustomEncoderGets current distancedoes not indicate sensor errors
- Specified by:
getDistancein interfaceCustomEncoder
-
getDirection
public boolean getDirection()Description copied from interface:CustomEncoderGets direction of most recent movementdoes not indicate sensor errors
- Specified by:
getDirectionin interfaceCustomEncoder
-
getStopped
public boolean getStopped()Description copied from interface:CustomEncoderReturns true when stoppeddoes not indicate sensor errors
- Specified by:
getStoppedin interfaceCustomEncoder
-
getRate
public double getRate()Description copied from interface:NativeDerivativeSensorGets ratedoes not indicate sensor errors
- Specified by:
getRatein interfaceNativeDerivativeSensor
-