Package lib.custom.sensors
Class EncoderPair
java.lang.Object
lib.custom.sensors.EncoderPair
- All Implemented Interfaces:
CustomEncoder,NativeDerivativeSensor
Amalgamates the data of several encoders for the purpose of controlling a
single motion controller.
The amalgamation will be the average. Verify before using this class that all the encoders will be rotating in the same direction with the same rate (before setDistancePerTick).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final doubleprotected static final double -
Constructor Summary
ConstructorsConstructorDescriptionEncoderPair(CustomEncoder encoder1, CustomEncoder encoder2) Amalgamates the data of two encoders for the purpose of controlling a single motion controller.EncoderPair(CustomEncoder encoder1, CustomEncoder encoder2, double distanceTolerance, double rateTolerance) Amalgamates the data of two encoders for the purpose of controlling a single motion controller. -
Method Summary
Modifier and TypeMethodDescriptiondoubledoublebooleanGets direction of most recent movementbooleanGets direction of most recent movementdoubleGets current distancedoubleGets the distance per pulsedoubleGets current distancedoublegetRate()Gets ratedoubledoubledoubleGets ratebooleanGet whether this entire encoder is inverted.booleanReturns true when stoppedbooleanReturns true when stoppedbooleanisInSync()booleanvoidreset()Resets the encodervoidsetDistancePerPulse(double distancePerPulse) Sets the distance per pulsevoidsetReverseDirection(boolean reverseDirection) Sets the direction inversion of all encoder substituents.
-
Field Details
-
DEFAULT_DISTANCE_TOLERANCE
protected static final double DEFAULT_DISTANCE_TOLERANCE- See Also:
-
DEFAULT_RATE_TOLERANCE
protected static final double DEFAULT_RATE_TOLERANCE- See Also:
-
-
Constructor Details
-
EncoderPair
public EncoderPair(CustomEncoder encoder1, CustomEncoder encoder2, double distanceTolerance, double rateTolerance) Amalgamates the data of two encoders for the purpose of controlling a single motion controller.The amalgamation will be the average. Verify before using this class that all the encoders will be rotating in the same direction with the same rate (before setDistancePerTick).
- Parameters:
encoder1- The first encoder to amalgamate.encoder2- The second encoder to amalgamate.distanceTolerance- The distance by which the encoders can be different before isInSync() returns falserateTolerance- The rate by which the encoders can be different before isInSync() returns false
-
EncoderPair
Amalgamates the data of two encoders for the purpose of controlling a single motion controller.The amalgamation will be the average. Verify before using this class that all the encoders will be rotating in the same direction with the same rate (before setDistancePerTick).
- Parameters:
encoder1- The first encoder to amalgamate.encoder2- The second encoder to amalgamate.
-
-
Method Details
-
getDistanceSafely
Description copied from interface:CustomEncoderGets current distance- Specified by:
getDistanceSafelyin interfaceCustomEncoder- Throws:
InvalidSensorException
-
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
-
getDirectionSafely
Description copied from interface:CustomEncoderGets direction of most recent movement- Specified by:
getDirectionSafelyin interfaceCustomEncoder- Throws:
InvalidSensorException
-
getStopped
public boolean getStopped()Description copied from interface:CustomEncoderReturns true when stoppeddoes not indicate sensor errors
- Specified by:
getStoppedin interfaceCustomEncoder
-
getStoppedSafely
Description copied from interface:CustomEncoderReturns true when stopped- Specified by:
getStoppedSafelyin interfaceCustomEncoder- Throws:
InvalidSensorException
-
getRateSafely
Description copied from interface:NativeDerivativeSensorGets rate- Specified by:
getRateSafelyin interfaceNativeDerivativeSensor- Throws:
InvalidSensorException
-
getRate
public double getRate()Description copied from interface:NativeDerivativeSensorGets ratedoes not indicate sensor errors
- Specified by:
getRatein interfaceNativeDerivativeSensor
-
getReverseDirection
public boolean getReverseDirection()Get whether this entire encoder is inverted.- Specified by:
getReverseDirectionin interfaceCustomEncoder- Returns:
- isInverted The state of inversion, true is inverted.
-
setReverseDirection
public void setReverseDirection(boolean reverseDirection) Sets the direction inversion of all encoder substituents. This respects the original inversion state of each encoder when constructed, and will only invert encoders if this.getReverseDirection() != the input.- Specified by:
setReverseDirectionin interfaceCustomEncoder- Parameters:
reverseDirection- The state of inversion, true is inverted.
-
getDistancePerPulse
public double getDistancePerPulse()Description copied from interface:CustomEncoderGets the distance per pulse- Specified by:
getDistancePerPulsein interfaceCustomEncoder
-
setDistancePerPulse
public void setDistancePerPulse(double distancePerPulse) Description copied from interface:CustomEncoderSets the distance per pulse- Specified by:
setDistancePerPulsein interfaceCustomEncoder
-
reset
public void reset()Description copied from interface:CustomEncoderResets the encoder- Specified by:
resetin interfaceCustomEncoder
-
getDifference
public double getDifference() -
getDifferenceSafely
- Throws:
InvalidSensorException
-
getRateDifference
public double getRateDifference() -
getRateDifferenceSafely
- Throws:
InvalidSensorException
-
isInSync
public boolean isInSync() -
isInSyncSafely
- Throws:
InvalidSensorException
-