Package swervelib.encoders
Class CanAndMagSwerve
java.lang.Object
swervelib.encoders.SwerveAbsoluteEncoder
swervelib.encoders.CanAndMagSwerve
- All Implemented Interfaces:
AutoCloseable
HELIUM
Canandmag from ReduxRobotics absolute encoder, attached through the CAN bus.-
Field Summary
FieldsModifier and TypeFieldDescriptioncom.reduxrobotics.sensors.canandmag.CanandmagTheCanandmagrepresenting the CANandMag on the CAN bus.com.reduxrobotics.sensors.canandmag.CanandmagSettingsTheCanandmagsettings object to use.Fields inherited from class swervelib.encoders.SwerveAbsoluteEncoder
maximumRetries, readingError -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidClear sticky faults on the encoder.voidclose()voidconfigure(boolean inverted) Configure the CANandMag to read from [0, 360) per second.voidReset the encoder to factory defaults.Get the instantiated absolute encoder Object.doubleGet the absolute position of the encoder.doubleGet the velocity in degrees/sec.booleansetAbsoluteEncoderOffset(double offset) Cannot set the offset of the CANandMag.
-
Field Details
-
encoder
public com.reduxrobotics.sensors.canandmag.Canandmag encoderTheCanandmagrepresenting the CANandMag on the CAN bus. -
settings
public com.reduxrobotics.sensors.canandmag.CanandmagSettings settingsTheCanandmagsettings object to use.
-
-
Constructor Details
-
CanAndMagSwerve
public CanAndMagSwerve(int canid) Create theCanandmag- Parameters:
canid- The CAN ID whenever the CANandMag is operating on the CANBus.
-
-
Method Details
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein classSwerveAbsoluteEncoder
-
factoryDefault
public void factoryDefault()Reset the encoder to factory defaults.This will not clear the stored zero offset.
- Specified by:
factoryDefaultin classSwerveAbsoluteEncoder
-
clearStickyFaults
public void clearStickyFaults()Clear sticky faults on the encoder.- Specified by:
clearStickyFaultsin classSwerveAbsoluteEncoder
-
configure
public void configure(boolean inverted) Configure the CANandMag to read from [0, 360) per second.- Specified by:
configurein classSwerveAbsoluteEncoder- Parameters:
inverted- Whether the encoder is inverted.
-
getAbsolutePosition
public double getAbsolutePosition()Get the absolute position of the encoder.- Specified by:
getAbsolutePositionin classSwerveAbsoluteEncoder- Returns:
- Absolute position in degrees from [0, 360).
-
getAbsoluteEncoder
Get the instantiated absolute encoder Object.- Specified by:
getAbsoluteEncoderin classSwerveAbsoluteEncoder- Returns:
- Absolute encoder object.
-
setAbsoluteEncoderOffset
public boolean setAbsoluteEncoderOffset(double offset) Cannot set the offset of the CANandMag.- Specified by:
setAbsoluteEncoderOffsetin classSwerveAbsoluteEncoder- Parameters:
offset- the offset the Absolute Encoder uses as the zero point.- Returns:
- true if setting the zero point succeeded, false otherwise
-
getVelocity
public double getVelocity()Get the velocity in degrees/sec.- Specified by:
getVelocityin classSwerveAbsoluteEncoder- Returns:
- velocity in degrees/sec.
-