Class CANcoderSimState
CANcoder
.-
Field Summary
FieldsModifier and TypeFieldDescriptionThe orientation of the CANcoder relative to the robot chassis. -
Constructor Summary
ConstructorsConstructorDescriptionCANcoderSimState
(CoreCANcoder device) Creates an object to control the state of the givenCANcoder
.CANcoderSimState
(CoreCANcoder device, ChassisReference orientation) Creates an object to control the state of the givenCANcoder
. -
Method Summary
Modifier and TypeMethodDescriptionaddPosition
(double dRotations) Adds to the simulated position of the CANcoder.addPosition
(Angle dPosition) Adds to the simulated position of the CANcoder.setMagnetHealth
(MagnetHealthValue value) Sets the simulated magnet health of the CANcoder.setRawPosition
(double rotations) Sets the simulated raw position of the CANcoder.setRawPosition
(Angle position) Sets the simulated raw position of the CANcoder.setSupplyVoltage
(double volts) Sets the simulated supply voltage of the CANcoder.setSupplyVoltage
(Voltage voltage) Sets the simulated supply voltage of the CANcoder.setVelocity
(double rps) Sets the simulated velocity of the CANcoder.setVelocity
(AngularVelocity velocity) Sets the simulated velocity of the CANcoder.
-
Field Details
-
Orientation
The orientation of the CANcoder relative to the robot chassis.This value should not be changed based on the CANcoder invert. Rather, this value should be changed when the mechanical linkage between the CANcoder and the robot changes.
-
-
Constructor Details
-
CANcoderSimState
Creates an object to control the state of the givenCANcoder
.This constructor defaults to a counter-clockwise positive orientation relative to the robot chassis.
Note the recommended method of accessing simulation features is to use
CoreCANcoder.getSimState()
- Parameters:
device
- Device to which this simulation state is attached
-
CANcoderSimState
Creates an object to control the state of the givenCANcoder
.Note the recommended method of accessing simulation features is to use
CoreCANcoder.getSimState()
- Parameters:
device
- Device to which this simulation state is attachedorientation
- Orientation of the device relative to the robot chassis
-
-
Method Details
-
setSupplyVoltage
Sets the simulated supply voltage of the CANcoder.The minimum allowed supply voltage is 4 V - values below this will be promoted to 4 V.
- Parameters:
volts
- The supply voltage in Volts- Returns:
- Status code
-
setSupplyVoltage
Sets the simulated supply voltage of the CANcoder.The minimum allowed supply voltage is 4 V - values below this will be promoted to 4 V.
- Parameters:
voltage
- The supply voltage- Returns:
- Status code
-
setRawPosition
Sets the simulated raw position of the CANcoder.Inputs to this function over time should be continuous, as user calls of
CoreCANcoder.setPosition(double)
will be accounted for in the callee.The CANcoder integrates this to calculate the true reported position.
When using the WPI Sim GUI, you will notice a readonly
position
and settablerawPositionInput
. The readonly signal is the emulated position which will match self-test in Tuner and the hardware API. Changes torawPositionInput
will be integrated into the emulated position. This way a simulator can modify the position without overriding hardware API calls for home-ing the sensor.- Parameters:
rotations
- The raw position in rotations- Returns:
- Status code
-
setRawPosition
Sets the simulated raw position of the CANcoder.Inputs to this function over time should be continuous, as user calls of
CoreCANcoder.setPosition(double)
will be accounted for in the callee.The CANcoder integrates this to calculate the true reported position.
When using the WPI Sim GUI, you will notice a readonly
position
and settablerawPositionInput
. The readonly signal is the emulated position which will match self-test in Tuner and the hardware API. Changes torawPositionInput
will be integrated into the emulated position. This way a simulator can modify the position without overriding hardware API calls for home-ing the sensor.- Parameters:
position
- The raw position- Returns:
- Status code
-
addPosition
Adds to the simulated position of the CANcoder.- Parameters:
dRotations
- The change in position in rotations- Returns:
- Status code
-
addPosition
Adds to the simulated position of the CANcoder.- Parameters:
dPosition
- The change in position- Returns:
- Status code
-
setVelocity
Sets the simulated velocity of the CANcoder.- Parameters:
rps
- The new velocity in rotations per second- Returns:
- Status code
-
setVelocity
Sets the simulated velocity of the CANcoder.- Parameters:
velocity
- The new velocity- Returns:
- Status code
-
setMagnetHealth
Sets the simulated magnet health of the CANcoder.- Parameters:
value
- The magnet health to simulate. This directly correlates to the red/green/orange state of the simulated LED.- Returns:
- Status code
-