Class SwerveEncoder<AbsoluteEncoderType>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      AbsoluteEncoderType m_encoder
      The encoder can be directly referenced for configuration purposes of onboard PIDs.
    • Constructor Summary

      Constructors 
      Constructor Description
      SwerveEncoder()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract void configure()
      Configure the absolute encoder if possible.
      abstract void factoryDefault()
      Reset encoder to factory default settings, if possible.
      static <AbsoluteEncoderType>
      SwerveEncoder<?>
      fromEncoder​(AbsoluteEncoderType encoder)
      Get the SwerveEncoder class from the given encoder types
      abstract double getAbsolutePosition()
      Get the absolute position in degrees.
      abstract com.ctre.phoenix.sensors.MagnetFieldStrength getMagnetFieldStrength()
      Get the magnetic field strength, if available.
      abstract double getVelocity()
      Get the velocity of the absolute encoder in degrees per second.
      abstract boolean reachable()
      Is the encoder reachable?
      abstract void setInverted​(boolean isInverted)
      Configure the sensor direction
      abstract void setOffset​(double offset)
      Configure the magnetic offset for the AbsoluteEncoder.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • m_encoder

        public AbsoluteEncoderType m_encoder
        The encoder can be directly referenced for configuration purposes of onboard PIDs.
    • Constructor Detail

      • SwerveEncoder

        public SwerveEncoder()
    • Method Detail

      • fromEncoder

        public static <AbsoluteEncoderType> SwerveEncoder<?> fromEncoder​(AbsoluteEncoderType encoder)
        Get the SwerveEncoder class from the given encoder types
        Type Parameters:
        AbsoluteEncoderType - One of DutyCycleEncoder, AnalogEncoder, AbsoluteEncoder, and CANCoder
        Parameters:
        encoder - Encoder
        Returns:
        SwerveEncoder subclass
      • configure

        public abstract void configure()
        Configure the absolute encoder if possible.
      • factoryDefault

        public abstract void factoryDefault()
        Reset encoder to factory default settings, if possible.
      • getMagnetFieldStrength

        public abstract com.ctre.phoenix.sensors.MagnetFieldStrength getMagnetFieldStrength()
        Get the magnetic field strength, if available.
        Returns:
        CTRE MagneticFieldStrength Enum.
      • getAbsolutePosition

        public abstract double getAbsolutePosition()
        Get the absolute position in degrees.
        Returns:
        Absolute position (0, 360]
      • getVelocity

        public abstract double getVelocity()
        Get the velocity of the absolute encoder in degrees per second.
        Returns:
        Velocity in degrees per second.
      • setOffset

        public abstract void setOffset​(double offset)
        Configure the magnetic offset for the AbsoluteEncoder.
        Parameters:
        offset - Offset in degrees.
      • reachable

        public abstract boolean reachable()
        Is the encoder reachable?
        Returns:
        True if reachable, false otherwise.
      • setInverted

        public abstract void setInverted​(boolean isInverted)
        Configure the sensor direction
        Parameters:
        isInverted - Inverted or not.