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 int
private final String
private final String
private static com.qualcomm.hardware.digitalchickenlabs.CachingOctoQuad
private final TrcOdometrySensor.Odometry
private static final ArrayList<FtcOctoQuad>
private double
private double
final TrcDbgTrace
private final TrcWrapValueConverter
private 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.double
This method reads the raw encoder position in encoder units (generally encoder counts).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.private void
ioTaskLoopBegin
(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.boolean
This method checks if the encoder direction is inverted.boolean
This method checks if the Wrap Value Converter task is enabled.void
reset()
This method resets the position of the specified encoder.void
resetOdometry
(boolean resetHardware) This method resets the odometry data and sensor.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.void
setWrapConverterEnabled
(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, wait
Methods 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:
reset
in interfaceTrcEncoder
-
getRawPosition
public double getRawPosition()This method reads the raw encoder position in encoder units (generally encoder counts).- Specified by:
getRawPosition
in 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:
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.
-
getName
This method returns the instance name.- Specified by:
getName
in interfaceTrcOdometrySensor
- Returns:
- instance name.
-
resetOdometry
public void resetOdometry(boolean resetHardware) This method resets the odometry data and sensor.- Specified by:
resetOdometry
in 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:
getOdometry
in 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.
-