Package frclib.sensor

Class FrcEncoder

java.lang.Object
edu.wpi.first.wpilibj.Encoder
frclib.sensor.FrcEncoder
All Implemented Interfaces:
edu.wpi.first.util.sendable.Sendable, edu.wpi.first.wpilibj.CounterBase, AutoCloseable, TrcEncoder

public class FrcEncoder extends edu.wpi.first.wpilibj.Encoder implements TrcEncoder
This interface specifies a common implementation of a generic encoder with which makes different tpes of encoders compatible with each other.
  • Nested Class Summary

    Nested classes/interfaces inherited from class edu.wpi.first.wpilibj.Encoder

    edu.wpi.first.wpilibj.Encoder.IndexingType

    Nested classes/interfaces inherited from interface edu.wpi.first.wpilibj.CounterBase

    edu.wpi.first.wpilibj.CounterBase.EncodingType
  • Field Summary

    Fields inherited from class edu.wpi.first.wpilibj.Encoder

    m_aSource, m_bSource, m_indexSource
  • Constructor Summary

    Constructors
    Constructor
    Description
    FrcEncoder(int channelA, int channelB, edu.wpi.first.wpilibj.CounterBase.EncodingType encodingType)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    This method reads the absolute position of the encoder.
    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.
    boolean
    This method checks if the encoder direction is inverted.
    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.

    Methods inherited from class edu.wpi.first.wpilibj.Encoder

    close, get, getDecodingScaleFactor, getDirection, getDistance, getDistancePerPulse, getEncodingScale, getFPGAIndex, getPeriod, getRate, getRaw, getSamplesToAverage, getStopped, initSendable, reset, setDistancePerPulse, setIndexSource, setIndexSource, setIndexSource, setIndexSource, setMaxPeriod, setMinRate, setReverseDirection, setSamplesToAverage, setSimDevice

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface trclib.sensor.TrcEncoder

    reset
  • Constructor Details

    • FrcEncoder

      public FrcEncoder(int channelA, int channelB, edu.wpi.first.wpilibj.CounterBase.EncodingType encodingType)
  • Method Details

    • getRawPosition

      public double getRawPosition()
      This method reads the absolute position of the encoder.
      Specified by:
      getRawPosition in interface TrcEncoder
      Returns:
      absolute position of the encoder.
    • 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 rerversed, 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.