Package frclib.sensor

Class FrcCanandmag

java.lang.Object
com.reduxrobotics.canand.CanandDevice
com.reduxrobotics.sensors.canandmag.Canandmag
frclib.sensor.FrcCanandmag
All Implemented Interfaces:
AutoCloseable, TrcEncoder

public class FrcCanandmag extends com.reduxrobotics.sensors.canandmag.Canandmag implements TrcEncoder
This class extends Canandmag and implements the FrcEncoder interface to allow compatibility to other types of encoders.
  • Field Summary

    Fields inherited from class com.reduxrobotics.sensors.canandmag.Canandmag

    absPosition, kCountsPerRotation, kCountsPerRotationPerSecond, position, status, velocity

    Fields inherited from class com.reduxrobotics.canand.CanandDevice

    lastMessageTs
  • Constructor Summary

    Constructors
    Constructor
    Description
    FrcCanandmag(String instanceName, int canId)
    Constructor: Creates an instance of the object.
  • 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
    This method resets the encoder position.
    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.
    This method returns the instance name.

    Methods inherited from class com.reduxrobotics.sensors.canandmag.Canandmag

    clearStickyFaults, getAbsPosition, getAbsPositionFrame, getActiveFaults, getAddress, getInternalSettingsManager, getMinimumFirmwareVersion, getPosition, getPositionFrame, getSettings, getSettings, getSettings, getSettingsAsync, getStatus, getStatusFrame, getStickyFaults, getTemperature, getVelocity, getVelocityFrame, handleMessage, magnetInRange, resetFactoryDefaults, resetFactoryDefaults, setAbsPosition, setAbsPosition, setAbsPosition, setPartyMode, setPosition, setPosition, setSettings, setSettings, setSettings, startFetchSettings, zeroAll, zeroAll

    Methods inherited from class com.reduxrobotics.canand.CanandDevice

    checkReceivedFirmwareVersion, close, getFirmwareVersion, isConnected, isConnected, preHandleMessage, sendCANMessage, sendCANMessage

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • FrcCanandmag

      public FrcCanandmag(String instanceName, int canId)
      Constructor: Creates an instance of the object.
      Parameters:
      instanceName - specifies the instance name.
      canId - specifies the CAN ID of the encoder.
  • Method Details

    • toString

      public String toString()
      This method returns the instance name.
      Overrides:
      toString in class com.reduxrobotics.canand.CanandDevice
      Returns:
      instance name.
    • reset

      public void reset()
      This method resets the encoder position.
      Specified by:
      reset in interface TrcEncoder
    • 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 in the range of [0.0, 1.0).
    • 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.