Package com.revrobotics
Class CANEncoder
- java.lang.Object
-
- com.revrobotics.CANEncoder
-
public class CANEncoder extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description CANEncoder(CANSparkMax device)
Constructs a CANPIDController.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
getPosition()
Get the position of the motor.double
getPositionConversionFactor()
Get the conversion factor for position of the encoder.double
getVelocity()
Get the velocity of the motor.double
getVelocityConversionFactor()
Get the conversion factor for velocity of the encoder.CANError
setPosition(double position)
Set the position of the encoder.CANError
setPositionConversionFactor(double factor)
Set the conversion factor for position of the encoder.CANError
setVelocityConversionFactor(double factor)
Set the conversion factor for velocity of the encoder.
-
-
-
Constructor Detail
-
CANEncoder
public CANEncoder(CANSparkMax device)
Constructs a CANPIDController.- Parameters:
device
- The Spark Max to which the encoder is attached.
-
-
Method Detail
-
getPosition
public double getPosition()
Get the position of the motor. This returns the native units of 'rotations'.- Returns:
- Number of rotations of the motor
-
getVelocity
public double getVelocity()
Get the velocity of the motor. This returns the native units of 'RPM'.- Returns:
- Number the RPM of the motor
-
setPosition
public CANError setPosition(double position)
Set the position of the encoder.- Parameters:
position
- Number of rotations of the motor- Returns:
- CANError Set to CANError.kOk if successful
-
setPositionConversionFactor
public CANError setPositionConversionFactor(double factor)
Set the conversion factor for position of the encoder. Multiplied by the native output units to give you position- Parameters:
factor
- The conversion factor to multiply the native units by- Returns:
- CANError Set to CANError.kOk if successful
-
setVelocityConversionFactor
public CANError setVelocityConversionFactor(double factor)
Set the conversion factor for velocity of the encoder. Multiplied by the native output units to give you velocity- Parameters:
factor
- The conversion factor to multiply the native units by- Returns:
- CANError Set to CANError.kOk if successful
-
getPositionConversionFactor
public double getPositionConversionFactor()
Get the conversion factor for position of the encoder. Multiplied by the native output units to give you position- Returns:
- The conversion factor for position
-
getVelocityConversionFactor
public double getVelocityConversionFactor()
Get the conversion factor for velocity of the encoder. Multiplied by the native output units to give you velocity- Returns:
- The conversion factor for velocity
-
-