Class CANCoderSwerve
- java.lang.Object
-
- frc.robot.subsystems.swervedrive2.swervelib.encoders.SwerveAbsoluteEncoder
-
- frc.robot.subsystems.swervedrive2.swervelib.encoders.CANCoderSwerve
-
public class CANCoderSwerve extends SwerveAbsoluteEncoder
Swerve Absolute Encoder for CTRE CANCoders.
-
-
Field Summary
Fields Modifier and Type Field Description com.ctre.phoenix.sensors.WPI_CANCoderencoderCANCoder with WPILib sendable and support.
-
Constructor Summary
Constructors Constructor Description CANCoderSwerve(int id)Initialize the CANCoder on the standard CANBus.CANCoderSwerve(int id, String canbus)Initialize the CANCoder on the CANivore.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearStickyFaults()Clear sticky faults on the encoder.voidconfigure(boolean inverted)Configure the absolute encoder to read from [0, 360) per second.voidfactoryDefault()Reset the encoder to factory defaults.ObjectgetAbsoluteEncoder()Get the instantiated absolute encoder Object.doublegetAbsolutePosition()Get the absolute position of the encoder.
-
-
-
Constructor Detail
-
CANCoderSwerve
public CANCoderSwerve(int id)
Initialize the CANCoder on the standard CANBus.- Parameters:
id- CAN ID.
-
CANCoderSwerve
public CANCoderSwerve(int id, String canbus)Initialize the CANCoder on the CANivore.- Parameters:
id- CAN ID.canbus- CAN bus to initialize it on.
-
-
Method Detail
-
factoryDefault
public void factoryDefault()
Reset the encoder to factory defaults.- 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 absolute encoder 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
public Object getAbsoluteEncoder()
Get the instantiated absolute encoder Object.- Specified by:
getAbsoluteEncoderin classSwerveAbsoluteEncoder- Returns:
- Absolute encoder object.
-
-