Class SwerveEncoders.SwerveEncoder

java.lang.Object
org.team1126.lib.swerve.hardware.SwerveEncoders.SwerveEncoder
All Implemented Interfaces:
AutoCloseable
Enclosing class:
SwerveEncoders

public abstract static class SwerveEncoders.SwerveEncoder extends Object
A swerve module's absolute encoder. All units are in rotations.
  • Constructor Details

    • SwerveEncoder

      public SwerveEncoder()
  • Method Details

    • construct

      Constructs a swerve encoder. Wraps to support simulation if applicable.
      Parameters:
      ctor - The encoder's constructor.
      config - The general swerve API configuration.
      turnMotor - The turn motor associated with the encoder's module.
    • getPosition

      public abstract double getPosition()
      Gets the encoder's position in rotations.
    • hookStatus

      Some motor controllers can be configured to use external encoders as a feedback device for closed-loop control. This method returns a SwerveEncoders.SwerveEncoder.HookStatus that specifies if the encoder's corresponding turn motor has been configured to return an absolute position via its getPosition() method (SwerveEncoders.SwerveEncoder.HookStatus.readMotor), and/or accept an absolute position when setting its closed loop position target (SwerveEncoders.SwerveEncoder.HookStatus.applyAbsolute).
    • getAPI

      Object getAPI()
      Returns the device's underlying API.
    • getSignals

      default List<com.ctre.phoenix6.BaseStatusSignal> getSignals()
      Returns all Phoenix status signals in use by the hardware. Phoenix hardware should not invoke .refresh() on their status signals in their implementations. This method is required for the odometry thread to register signals to be refreshed automatically. Because signals are not thread safe, all returned signals should also be cloned in their initialization as to not interfere with telemetry, which is invoked on the main thread. The exception to this rule is IMU pitch and roll values, as they are only measured synchronously when calling SwerveAPI.refresh().
    • readError

      default boolean readError()
      If the device has encountered an error while reading inputs.