Package com.revrobotics.sim
Class SparkAbsoluteEncoderSim
java.lang.Object
com.revrobotics.sim.SparkAbsoluteEncoderSim
-
Constructor Summary
ConstructorDescriptionSparkAbsoluteEncoderSim
(SparkFlex motor) Create a Spark Absolute Encoder simulation object for a Spark Flex.SparkAbsoluteEncoderSim
(SparkMax motor) Create a Spark Absolute Encoder simulation object for a Spark MAX. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Get the inversion state of the sensordouble
Get the position of the sensor, with the conversion factor applieddouble
Get the position conversion factor of the sensor (1 by default)double
Get the velocity of the sensor, with the conversion factor applieddouble
Get the velocity conversion factor of the sensor (1 by default)double
Get the zero offset of the sensorvoid
iterate
(double velocity, double dt) Move the sensor at the input velocityvoid
setInverted
(boolean inverted) Set the inversion state of the sensorvoid
setPosition
(double position) Set the position of the sensor, after your conversion factorvoid
setPositionConversionFactor
(double positionConversionFactor) Set the position conversion factor of the sensor (1 by default)void
setVelocity
(double velocity) Set the velocity of the sensor, after the conversion factorvoid
setVelocityConversionFactor
(double velocityConversionFactor) Set the velocity conversion factor of the sensor (1 by default)void
setZeroOffset
(double zeroOffset) Set the zero offset of the sensor
-
Constructor Details
-
SparkAbsoluteEncoderSim
Create a Spark Absolute Encoder simulation object for a Spark MAX. This will allow you to read/write data from the simulated sensor and view it in the Sim GUI.- Parameters:
motor
- The CANSparkMax associated with the sensor
-
SparkAbsoluteEncoderSim
Create a Spark Absolute Encoder simulation object for a Spark Flex. This will allow you to read/write data from the simulated sensor and view it in the Sim GUI.- Parameters:
motor
- The CANSparkFlex associated with the sensor
-
-
Method Details
-
setPosition
public void setPosition(double position) Set the position of the sensor, after your conversion factor- Parameters:
position
- the position to set
-
getPosition
public double getPosition()Get the position of the sensor, with the conversion factor applied- Returns:
- the position of the sensor
-
setVelocity
public void setVelocity(double velocity) Set the velocity of the sensor, after the conversion factor- Parameters:
velocity
- the velocity to set
-
getVelocity
public double getVelocity()Get the velocity of the sensor, with the conversion factor applied- Returns:
- the velocity of the sensor
-
setInverted
public void setInverted(boolean inverted) Set the inversion state of the sensor- Parameters:
inverted
- if the sensor is inverted or not
-
getInverted
public boolean getInverted()Get the inversion state of the sensor- Returns:
- if the sensor is inverted or not
-
setZeroOffset
public void setZeroOffset(double zeroOffset) Set the zero offset of the sensor- Parameters:
zeroOffset
- the zero offset to apply
-
getZeroOffset
public double getZeroOffset()Get the zero offset of the sensor- Returns:
- the zero offset of the sensor
-
setPositionConversionFactor
public void setPositionConversionFactor(double positionConversionFactor) Set the position conversion factor of the sensor (1 by default)- Parameters:
positionConversionFactor
- the factor to apply
-
getPositionConversionFactor
public double getPositionConversionFactor()Get the position conversion factor of the sensor (1 by default)- Returns:
- the conversion factor
-
setVelocityConversionFactor
public void setVelocityConversionFactor(double velocityConversionFactor) Set the velocity conversion factor of the sensor (1 by default)- Parameters:
velocityConversionFactor
- the factor to apply
-
getVelocityConversionFactor
public double getVelocityConversionFactor()Get the velocity conversion factor of the sensor (1 by default)- Returns:
- the conversion factor
-
iterate
public void iterate(double velocity, double dt) Move the sensor at the input velocity- Parameters:
velocity
- the velocity of the sensordt
- the time interval of the calculation
-