Class TalonFXSSimState
TalonFXS.
For simulated PID control and current limits to behave correctly,
setRawRotorPosition(double) and setRotorVelocity(double) must be updated
periodically. This is typically done by sending the motor output from
getMotorVoltage() or getTorqueCurrent() to a physics
simulator (such as WPILib's DCMotorSim), which then calculates the
new motor position and velocity.
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe orientation of an external sensor attached to the TalonFXS relative to the robot chassis.The orientation of the motor attached to the TalonFXS relative to the robot chassis.doubleThe offset of an absolute external sensor attached to the Talon FXS relative to the robot chassis, in rotations.intThe number of quadrature edges per sensor rotation for an external quadrature sensor attached to the TalonFXS. -
Constructor Summary
ConstructorsConstructorDescriptionTalonFXSSimState(CoreTalonFXS device) Creates an object to control the state of the givenTalonFXS.TalonFXSSimState(CoreTalonFXS device, ChassisReference motorOrientation, ChassisReference extSensorOrientation) Creates an object to control the state of the givenTalonFXS. -
Method Summary
Modifier and TypeMethodDescriptionfinal StatusCodeaddQuadraturePosition(double dRotations) Adds to the simulated quadrature position of the TalonFXS.final StatusCodeaddQuadraturePosition(Angle dPosition) Adds to the simulated quadrature position of the TalonFXS.final StatusCodeaddRotorPosition(double dRotations) Adds to the simulated rotor position of the TalonFXS.final StatusCodeaddRotorPosition(Angle dPosition) Adds to the simulated rotor position of the TalonFXS.final doubleGets the simulated analog voltage of the TalonFXS.final VoltageGets the simulated analog voltage of the TalonFXS.final StatusCodeGets the last status code generated by a simulation function.final doubleGets the simulated output voltage of the motor.final VoltageGets the simulated output voltage of the motor as a unit type.final doubleGets the simulated supply current of the TalonFXS.final CurrentGets the simulated supply current of the TalonFXS as a unit type.final doubleGets the simulated output torque current of the motor.final CurrentGets the simulated output torque current of the motor as a unit type.final StatusCodesetAnalogVoltage(double voltage) Sets the simulated voltage of the analog input pin on the TalonFXS data port.final StatusCodesetAnalogVoltage(Voltage voltage) Sets the simulated voltage of the analog input pin on the TalonFXS data port.final StatusCodesetForwardLimit(boolean closed) Sets the simulated forward limit switch of the TalonFXS.final StatusCodesetPulseWidthPosition(double rotations) Sets the simulated pulse width position of the TalonFXS.final StatusCodesetPulseWidthPosition(Angle position) Sets the simulated pulse width position of the TalonFXS.final StatusCodesetPulseWidthVelocity(double rps) Sets the simulated pulse width velocity of the TalonFXS.final StatusCodesetPulseWidthVelocity(AngularVelocity velocity) Sets the simulated pulse width velocity of the TalonFXS.final StatusCodesetQuadratureAcceleration(double rpss) Sets the simulated quadrature acceleration of the TalonFXS.final StatusCodesetQuadratureAcceleration(AngularAcceleration acceleration) Sets the simulated quadrature acceleration of the TalonFXS.final StatusCodesetQuadratureVelocity(double rps) Sets the simulated quadrature velocity of the TalonFXS.final StatusCodesetQuadratureVelocity(AngularVelocity velocity) Sets the simulated quadrature velocity of the TalonFXS.final StatusCodesetRawQuadraturePosition(double rotations) Sets the simulated raw quadrature position of the TalonFXS.final StatusCodesetRawQuadraturePosition(Angle position) Sets the simulated raw quadrature position of the TalonFXS.final StatusCodesetRawRotorPosition(double rotations) Sets the simulated raw rotor position of the TalonFXS.final StatusCodesetRawRotorPosition(Angle position) Sets the simulated raw rotor position of the TalonFXS.final StatusCodesetReverseLimit(boolean closed) Sets the simulated reverse limit switch of the TalonFXS.final StatusCodesetRotorAcceleration(double rpss) Sets the simulated rotor acceleration of the TalonFXS.final StatusCodesetRotorAcceleration(AngularAcceleration acceleration) Sets the simulated rotor acceleration of the TalonFXS.final StatusCodesetRotorVelocity(double rps) Sets the simulated rotor velocity of the TalonFXS.final StatusCodesetRotorVelocity(AngularVelocity velocity) Sets the simulated rotor velocity of the TalonFXS.final StatusCodesetSupplyVoltage(double volts) Sets the simulated supply voltage of the TalonFXS.final StatusCodesetSupplyVoltage(Voltage voltage) Sets the simulated supply voltage of the TalonFXS.
-
Field Details
-
MotorOrientation
The orientation of the motor attached to the TalonFXS relative to the robot chassis. This include the Commutation sensor source.This value should not be changed based on the TalonFXS invert. Rather, this value should be changed when the mechanical linkage between the motor and the robot changes.
-
ExtSensorOrientation
The orientation of an external sensor attached to the TalonFXS relative to the robot chassis. This does NOT include the Commutation sensor source.This value should not be changed based on the TalonFXS invert. Rather, this value should be changed when the mechanical linkage between the external sensor and the robot changes.
-
PulseWidthSensorOffset
The offset of an absolute external sensor attached to the Talon FXS relative to the robot chassis, in rotations. This offset is subtracted from the Pulse Width position, allowing for a non-zero sensor offset config to behave correctly in simulation.This value should not be changed after initialization unless the mechanical linkage between the external sensor and the robot changes.
-
QuadratureEdgesPerRotation
The number of quadrature edges per sensor rotation for an external quadrature sensor attached to the TalonFXS.
-
-
Constructor Details
-
TalonFXSSimState
Creates an object to control the state of the givenTalonFXS.This constructor defaults to a counter-clockwise positive motor and external sensor orientation relative to the robot chassis.
Note the recommended method of accessing simulation features is to use
CoreTalonFXS.getSimState().- Parameters:
device- Device to which this simulation state is attached
-
TalonFXSSimState
public TalonFXSSimState(CoreTalonFXS device, ChassisReference motorOrientation, ChassisReference extSensorOrientation) Creates an object to control the state of the givenTalonFXS.Note the recommended method of accessing simulation features is to use
CoreTalonFXS.getSimState().- Parameters:
device- Device to which this simulation state is attachedmotorOrientation- Orientation of the motor (and commutation sensor) relative to the robot chassisextSensorOrientation- Orientation of the external sensor relative to the robot chassis
-
-
Method Details
-
getLastStatusCode
Gets the last status code generated by a simulation function.Not all functions return a status code but can potentially report errors. This function can be used to retrieve those status codes.
- Returns:
- Last status code generated by a simulation function
-
getMotorVoltage
Gets the simulated output voltage of the motor.- Returns:
- Voltage applied to the motor in Volts
-
getMotorVoltageMeasure
Gets the simulated output voltage of the motor as a unit type.- Returns:
- Voltage applied to the motor
-
getTorqueCurrent
Gets the simulated output torque current of the motor.Phoenix 6 simulation automatically calculates current.
- Returns:
- Torque current applied to the motor in Amperes
-
getTorqueCurrentMeasure
Gets the simulated output torque current of the motor as a unit type.Phoenix 6 simulation automatically calculates current.
- Returns:
- Torque current applied to the motor
-
getSupplyCurrent
Gets the simulated supply current of the TalonFXS.Phoenix 6 simulation automatically calculates current.
- Returns:
- Supply current of the TalonFXS in Amperes
-
getSupplyCurrentMeasure
Gets the simulated supply current of the TalonFXS as a unit type.Phoenix 6 simulation automatically calculates current.
- Returns:
- Supply current of the TalonFXS
-
getAnalogVoltage
Gets the simulated analog voltage of the TalonFXS.- Returns:
- Voltage of the simulated analog input pin on the TalonFXS.
-
getAnalogVoltageMeasure
Gets the simulated analog voltage of the TalonFXS.- Returns:
- Voltage of the simulated analog input pin on the TalonFXS.
-
setSupplyVoltage
Sets the simulated supply voltage of the TalonFXS.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 TalonFXS.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
-
setForwardLimit
Sets the simulated forward limit switch of the TalonFXS.- Parameters:
closed- Whether the limit switch is closed- Returns:
- Status code
-
setReverseLimit
Sets the simulated reverse limit switch of the TalonFXS.- Parameters:
closed- Whether the limit switch is closed- Returns:
- Status code
-
setRawRotorPosition
Sets the simulated raw rotor position of the TalonFXS. This is the position of the rotor (before gear ratio) used for the Commutation feedback source.Inputs to this function over time should be continuous, as user calls of
CoreTalonFXS.setPosition(double)will be accounted for in the callee.The TalonFXS integrates this to calculate the true reported rotor position.
When using the WPI Sim GUI, you will notice a readonly
positionand settablerawPositionInput. The readonly signal is the emulated position which will match self-test in Tuner and the hardware API. Changes torawPositionInputwill 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
-
setRawRotorPosition
Sets the simulated raw rotor position of the TalonFXS. This is the position of the rotor (before gear ratio) used for the Commutation feedback source.Inputs to this function over time should be continuous, as user calls of
CoreTalonFXS.setPosition(double)will be accounted for in the callee.The TalonFXS integrates this to calculate the true reported rotor position.
When using the WPI Sim GUI, you will notice a readonly
positionand settablerawPositionInput. The readonly signal is the emulated position which will match self-test in Tuner and the hardware API. Changes torawPositionInputwill 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
-
setAnalogVoltage
Sets the simulated voltage of the analog input pin on the TalonFXS data port.- Parameters:
voltage- Voltage of the pin- Returns:
- Status code
-
setAnalogVoltage
Sets the simulated voltage of the analog input pin on the TalonFXS data port.- Parameters:
voltage- Voltage of the pin- Returns:
- Status code
-
addRotorPosition
Adds to the simulated rotor position of the TalonFXS. This adds to the position of the rotor (before gear ratio) used for the Commutation feedback source.- Parameters:
dRotations- The change in position in rotations- Returns:
- Status code
-
addRotorPosition
Adds to the simulated rotor position of the TalonFXS. This adds to the position of the rotor (before gear ratio) used for the Commutation feedback source.- Parameters:
dPosition- The change in position- Returns:
- Status code
-
setRotorVelocity
Sets the simulated rotor velocity of the TalonFXS. This is the velocity of the rotor (before gear ratio) used for the Commutation feedback source.- Parameters:
rps- The new velocity in rotations per second- Returns:
- Status code
-
setRotorVelocity
Sets the simulated rotor velocity of the TalonFXS. This is the velocity of the rotor (before gear ratio) used for the Commutation feedback source.- Parameters:
velocity- The new velocity- Returns:
- Status code
-
setRotorAcceleration
Sets the simulated rotor acceleration of the TalonFXS. This is the acceleration of the rotor (before gear ratio) used for the Commutation feedback source.- Parameters:
rpss- The new acceleration in rotations per second²- Returns:
- Status code
-
setRotorAcceleration
Sets the simulated rotor acceleration of the TalonFXS. This is the acceleration of the rotor (before gear ratio) used for the Commutation feedback source.- Parameters:
acceleration- The new acceleration- Returns:
- Status code
-
setRawQuadraturePosition
Sets the simulated raw quadrature position of the TalonFXS. This is the position of an external quadrature encoder after any gear ratio between the rotor and the sensor.Inputs to this function over time should be continuous, as user calls of
CoreTalonFXS.setPosition(double)will be accounted for in the callee.The TalonFXS integrates this to calculate the true reported quadrature position.
When using the WPI Sim GUI, you will notice a readonly
positionand settablerawPositionInput. The readonly signal is the emulated position which will match self-test in Tuner and the hardware API. Changes torawPositionInputwill 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
-
setRawQuadraturePosition
Sets the simulated raw quadrature position of the TalonFXS. This is the position of an external quadrature encoder after any gear ratio between the rotor and the sensor.Inputs to this function over time should be continuous, as user calls of
CoreTalonFXS.setPosition(double)will be accounted for in the callee.The TalonFXS integrates this to calculate the true reported quadrature position.
When using the WPI Sim GUI, you will notice a readonly
positionand settablerawPositionInput. The readonly signal is the emulated position which will match self-test in Tuner and the hardware API. Changes torawPositionInputwill 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
-
addQuadraturePosition
Adds to the simulated quadrature position of the TalonFXS. This adds to the position of an external quadrature encoder after any gear ratio between the rotor and the sensor.- Parameters:
dRotations- The change in position in rotations- Returns:
- Status code
-
addQuadraturePosition
Adds to the simulated quadrature position of the TalonFXS. This adds to the position of an external quadrature encoder after any gear ratio between the rotor and the sensor.- Parameters:
dPosition- The change in position- Returns:
- Status code
-
setQuadratureVelocity
Sets the simulated quadrature velocity of the TalonFXS. This is the velocity of an external quadrature encoder after any gear ratio between the rotor and the sensor.- Parameters:
rps- The new velocity in rotations per second- Returns:
- Status code
-
setQuadratureVelocity
Sets the simulated quadrature velocity of the TalonFXS. This is the velocity of an external quadrature encoder after any gear ratio between the rotor and the sensor.- Parameters:
velocity- The new velocity- Returns:
- Status code
-
setQuadratureAcceleration
Sets the simulated quadrature acceleration of the TalonFXS. This is the acceleration of an external quadrature encoder after any gear ratio between the rotor and the sensor.- Parameters:
rpss- The new acceleration in rotations per second²- Returns:
- Status code
-
setQuadratureAcceleration
Sets the simulated quadrature acceleration of the TalonFXS. This is the acceleration of an external quadrature encoder after any gear ratio between the rotor and the sensor.- Parameters:
acceleration- The new acceleration- Returns:
- Status code
-
setPulseWidthPosition
Sets the simulated pulse width position of the TalonFXS. This is the position of an external PWM encoder after any gear ratio between the rotor and the sensor.- Parameters:
rotations- The new position in rotations- Returns:
- Status code
-
setPulseWidthPosition
Sets the simulated pulse width position of the TalonFXS. This is the position of an external PWM encoder after any gear ratio between the rotor and the sensor.- Parameters:
position- The new position- Returns:
- Status code
-
setPulseWidthVelocity
Sets the simulated pulse width velocity of the TalonFXS. This is the position of an external PWM encoder after any gear ratio between the rotor and the sensor.- Parameters:
rps- The new velocity in rotations per second- Returns:
- Status code
-
setPulseWidthVelocity
Sets the simulated pulse width velocity of the TalonFXS. This is the position of an external PWM encoder after any gear ratio between the rotor and the sensor.- Parameters:
velocity- The new velocity- Returns:
- Status code
-