Class PWMAnalogEncoder
- java.lang.Object
-
- frc.robot.subsystems.swervedrive.swerve.SwerveEncoder<edu.wpi.first.wpilibj.AnalogEncoder>
-
- frc.robot.subsystems.swervedrive.swerve.encoders.PWMAnalogEncoder
-
public class PWMAnalogEncoder extends SwerveEncoder<edu.wpi.first.wpilibj.AnalogEncoder>
-
-
Field Summary
Fields Modifier and Type Field Description private booleanm_invertedprivate doublem_lastAngleprivate doublem_lastTimeprivate edu.wpi.first.wpilibj.Timerm_timerprivate doublem_velocity-
Fields inherited from class frc.robot.subsystems.swervedrive.swerve.SwerveEncoder
m_encoder
-
-
Constructor Summary
Constructors Constructor Description PWMAnalogEncoder(edu.wpi.first.wpilibj.AnalogEncoder encoder)Constructor for analog encoder Swerve Encoder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconfigure()Configure the absolute encoder if possible.voidfactoryDefault()Reset encoder to factory default settings, if possible.doublegetAbsolutePosition()Get the absolute position in degrees.com.ctre.phoenix.sensors.MagnetFieldStrengthgetMagnetFieldStrength()Get the magnetic field strength, if available.doublegetVelocity()Get the velocity of the absolute encoder in degrees per second.booleanreachable()Is the encoder reachable?voidsetInverted(boolean isInverted)Configure the sensor directionvoidsetOffset(double offset)Configure the magnetic offset for the AbsoluteEncoder.voidupdateVelocity()Updates the velocity every second.-
Methods inherited from class frc.robot.subsystems.swervedrive.swerve.SwerveEncoder
fromEncoder
-
-
-
-
Method Detail
-
updateVelocity
public void updateVelocity()
Updates the velocity every second.
-
configure
public void configure()
Configure the absolute encoder if possible.- Specified by:
configurein classSwerveEncoder<edu.wpi.first.wpilibj.AnalogEncoder>
-
factoryDefault
public void factoryDefault()
Reset encoder to factory default settings, if possible.- Specified by:
factoryDefaultin classSwerveEncoder<edu.wpi.first.wpilibj.AnalogEncoder>
-
getMagnetFieldStrength
public com.ctre.phoenix.sensors.MagnetFieldStrength getMagnetFieldStrength()
Get the magnetic field strength, if available.- Specified by:
getMagnetFieldStrengthin classSwerveEncoder<edu.wpi.first.wpilibj.AnalogEncoder>- Returns:
- CTRE MagneticFieldStrength Enum.
-
getAbsolutePosition
public double getAbsolutePosition()
Get the absolute position in degrees.- Specified by:
getAbsolutePositionin classSwerveEncoder<edu.wpi.first.wpilibj.AnalogEncoder>- Returns:
- Absolute position (0, 360]
-
getVelocity
public double getVelocity()
Get the velocity of the absolute encoder in degrees per second.- Specified by:
getVelocityin classSwerveEncoder<edu.wpi.first.wpilibj.AnalogEncoder>- Returns:
- Velocity in degrees per second.
-
setOffset
public void setOffset(double offset)
Configure the magnetic offset for the AbsoluteEncoder.- Specified by:
setOffsetin classSwerveEncoder<edu.wpi.first.wpilibj.AnalogEncoder>- Parameters:
offset- Offset in degrees.
-
reachable
public boolean reachable()
Is the encoder reachable?- Specified by:
reachablein classSwerveEncoder<edu.wpi.first.wpilibj.AnalogEncoder>- Returns:
- True if reachable, false otherwise.
-
setInverted
public void setInverted(boolean isInverted)
Configure the sensor direction- Specified by:
setInvertedin classSwerveEncoder<edu.wpi.first.wpilibj.AnalogEncoder>- Parameters:
isInverted- Inverted or not.
-
-