Package ftclib.sensor
Class FtcOctoQuad
java.lang.Object
ftclib.sensor.FtcOctoQuad
- All Implemented Interfaces:
TrcEncoder,TrcOdometrySensor
This class implements a wrapper to OctoQuad that supports up to 8 quadrature or PWM encoders. It implements the
TrcEncoder interface to allow compatibility to other types of encoders.
-
Nested Class Summary
Nested classes/interfaces inherited from interface trclib.sensor.TrcOdometrySensor
TrcOdometrySensor.Odometry -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final intprivate final Stringprivate final Stringprivate static com.qualcomm.hardware.digitalchickenlabs.CachingOctoQuadprivate final TrcOdometrySensor.Odometryprivate static final ArrayList<FtcOctoQuad>private doubleprivate doublefinal TrcDbgTraceprivate final TrcWrapValueConverterprivate double -
Constructor Summary
ConstructorsConstructorDescriptionFtcOctoQuad(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, String instanceName, int encIndex, Double wrapValueLow, Double wrapValueHigh) Constructor: Creates an instance of the object.FtcOctoQuad(String instanceName, int encIndex) Constructor: Creates an instance of the object.FtcOctoQuad(String instanceName, int encIndex, Double wrapValueLow, Double wrapValueHigh) Constructor: Creates an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptiongetName()This method returns the instance name.getOdometry(int axisIndex) This method returns a copy of the odometry data of the specified axis.doubleThis method reads the raw encoder position in encoder units (generally encoder counts).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.private voidioTaskLoopBegin(TrcRobot.RunMode runMode) This method is called by the IO task thread at the beginning of the IO loop so we can refresh the cache.booleanThis method checks if the encoder direction is inverted.booleanThis method checks if the Wrap Value Converter task is enabled.voidreset()This method resets the position of the specified encoder.voidresetOdometry(boolean resetHardware) This method resets the odometry data and sensor.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.voidsetWrapConverterEnabled(boolean enabled) This method enables/disables the Wrap Value Converter task.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface trclib.sensor.TrcOdometrySensor
getOdometries, getOdometry
-
Field Details
-
moduleName
-
odometrySensors
-
octoQuad
private static com.qualcomm.hardware.digitalchickenlabs.CachingOctoQuad octoQuad -
tracer
-
instanceName
-
encIndex
private final int encIndex -
wrapValueConverter
-
odometry
-
scale
private double scale -
offset
private double offset -
zeroOffset
private double zeroOffset
-
-
Constructor Details
-
FtcOctoQuad
public FtcOctoQuad(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, String instanceName, int encIndex, Double wrapValueLow, Double wrapValueHigh) Constructor: Creates an instance of the object.- Parameters:
hardwareMap- specifies the global hardware map.instanceName- specifies the instance name.encIndex- specifies the encoder port index.wrapValueLow- specifies the encoder wrap range low value, null if value is continuous.wrapValueHigh- specifies the encoder wrap range high value, null if value is continuous.
-
FtcOctoQuad
Constructor: Creates an instance of the object.- Parameters:
instanceName- specifies the instance name.encIndex- specifies the encoder port index.wrapValueLow- specifies the encoder wrap range low value, null if value is continuous.wrapValueHigh- specifies the encoder wrap range high value, null if value is continuous.
-
FtcOctoQuad
Constructor: Creates an instance of the object.- Parameters:
instanceName- specifies the instance name.encIndex- specifies the encoder port index.
-
-
Method Details
-
ioTaskLoopBegin
This method is called by the IO task thread at the beginning of the IO loop so we can refresh the cache.- Parameters:
runMode- specifies the robot run mode (not used).
-
setWrapConverterEnabled
public void setWrapConverterEnabled(boolean enabled) This method enables/disables the Wrap Value Converter task.- Parameters:
enabled- specifies true to enable wrap value converter, false to disable.
-
isWrapConverterEnabled
public boolean isWrapConverterEnabled()This method checks if the Wrap Value Converter task is enabled.- Returns:
- true if wrap value converter is enabled, false if disabled.
-
reset
public void reset()This method resets the position of the specified encoder.- Specified by:
resetin interfaceTrcEncoder
-
getRawPosition
public double getRawPosition()This method reads the raw encoder position in encoder units (generally encoder counts).- Specified by:
getRawPositionin interfaceTrcEncoder- Returns:
- raw position of the encoder in encoder units.
-
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 reversed, 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.
-
getName
This method returns the instance name.- Specified by:
getNamein interfaceTrcOdometrySensor- Returns:
- instance name.
-
resetOdometry
public void resetOdometry(boolean resetHardware) This method resets the odometry data and sensor.- Specified by:
resetOdometryin interfaceTrcOdometrySensor- Parameters:
resetHardware- specifies true to do a hardware reset, false to do a software reset (not used).
-
getOdometry
This method returns a copy of the odometry data of the specified axis. It must be a copy so it won't change while the caller is accessing the data fields.- Specified by:
getOdometryin interfaceTrcOdometrySensor- Parameters:
axisIndex- specifies the axis index if it is a multi-axes sensor, 0 if it is a single axis sensor (not used).- Returns:
- a copy of the odometry data of the specified axis.
-