Package ftclib.sensor

Class FtcOctoQuad

java.lang.Object
ftclib.sensor.FtcOctoQuad
All Implemented Interfaces:
TrcEncoder, TrcOdometrySensor

public class FtcOctoQuad extends Object implements 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.
  • Field Details

    • moduleName

      private final String moduleName
    • odometrySensors

      private static final ArrayList<FtcOctoQuad> odometrySensors
    • octoQuad

      private static com.qualcomm.hardware.digitalchickenlabs.CachingOctoQuad octoQuad
    • tracer

      public final TrcDbgTrace tracer
    • instanceName

      private final String instanceName
    • encIndex

      private final int encIndex
    • wrapValueConverter

      private final TrcWrapValueConverter wrapValueConverter
    • odometry

      private final TrcOdometrySensor.Odometry 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

      public FtcOctoQuad(String instanceName, int encIndex, Double wrapValueLow, Double wrapValueHigh)
      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

      public FtcOctoQuad(String instanceName, int encIndex)
      Constructor: Creates an instance of the object.
      Parameters:
      instanceName - specifies the instance name.
      encIndex - specifies the encoder port index.
  • Method Details

    • ioTaskLoopBegin

      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.
      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 interface TrcEncoder
    • getRawPosition

      public double getRawPosition()
      This method reads the raw encoder position in encoder units (generally encoder counts).
      Specified by:
      getRawPosition in interface TrcEncoder
      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 interface TrcEncoder
      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 interface TrcEncoder
      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 interface TrcEncoder
      Returns:
      encoder velocity adjusted by scale.
    • setInverted

      public void setInverted(boolean inverted)
      This method reverses the direction of the encoder.
      Specified by:
      setInverted in interface TrcEncoder
      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 interface TrcEncoder
      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 interface TrcEncoder
      Parameters:
      scale - specifies the scale value.
      offset - specifies the offset value.
      zeroOffset - specifies the zero offset for absolute encoder.
    • getName

      public String getName()
      This method returns the instance name.
      Specified by:
      getName in interface TrcOdometrySensor
      Returns:
      instance name.
    • resetOdometry

      public void resetOdometry(boolean resetHardware)
      This method resets the odometry data and sensor.
      Specified by:
      resetOdometry in interface TrcOdometrySensor
      Parameters:
      resetHardware - specifies true to do a hardware reset, false to do a software reset (not used).
    • getOdometry

      public TrcOdometrySensor.Odometry getOdometry(int axisIndex)
      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 interface TrcOdometrySensor
      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.