phoenix6.sim.talon_fx_sim_state¶
Module Contents¶
- class phoenix6.sim.talon_fx_sim_state.TalonFXSimState(device: phoenix6.hardware.core.core_talon_fx.CoreTalonFX, orientation: phoenix6.sim.chassis_reference.ChassisReference = ChassisReference.COUNTER_CLOCKWISE_POSITIVE)¶
Creates an object to control the state of a simulated TalonFX.
Note the recommended method of accessing simulation features is to use TalonFX.sim_state.
For simulated PID control and current limits to behave correctly, self.set_raw_rotor_position and self.set_rotor_velocity must be updated periodically. This is typically done by sending the motor output from self.motor_voltage or self.torque_current to a physics simulator (such as WPILib’s DCMotorSim), which then calculates the new motor position and velocity.
- Parameters:
device (CoreTalonFX) – Device to which this simulation state is attached
orientation (ChassisReference) – Orientation of the device relative to the robot chassis
- class MotorType(*args, **kwds)¶
Bases:
enum.EnumRepresents the type of motor connected to the simulated Talon FX.
- KRAKEN_X60 = '0'¶
WCP Kraken X60
- KRAKEN_X44 = '1'¶
WCP Kraken X44
- property last_status_code: phoenix6.status_code.StatusCode¶
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
- Return type:
- property motor_voltage: phoenix6.units.volt¶
Gets the simulated output voltage of the motor.
- Returns:
Voltage applied to the motor in Volts
- Return type:
volt
- property torque_current: phoenix6.units.ampere¶
Gets the simulated output torque current of the motor.
Phoenix 6 simulation automatically calculates current.
- Returns:
Torque current applied to the motor in Amperes
- Return type:
ampere
- property supply_current: phoenix6.units.ampere¶
Gets the simulated supply current of the TalonFX.
Phoenix 6 simulation automatically calculates current.
- Returns:
Supply current of the TalonFX in Amperes
- Return type:
ampere
- orientation¶
The orientation of the TalonFX relative to the robot chassis.
This value should not be changed based on the TalonFX invert. Rather, this value should be changed when the mechanical linkage between the TalonFX and the robot changes.
- set_motor_type(motor_type: MotorType) phoenix6.status_code.StatusCode¶
Sets the type of motor connected to the simulated Talon FX.
- Parameters:
motor_type (MotorType) – The type of motor connected
- Returns:
Status code
- Return type:
- set_supply_voltage(volts: phoenix6.units.volt) phoenix6.status_code.StatusCode¶
Sets the simulated supply voltage of the TalonFX.
The minimum allowed supply voltage is 4 V - values below this will be promoted to 4 V.
- Parameters:
volts (volt) – The supply voltage in Volts
- Returns:
Status code
- Return type:
- set_forward_limit(closed: bool) phoenix6.status_code.StatusCode¶
Sets the simulated forward limit switch of the TalonFX.
- Parameters:
closed (bool) – Whether the limit switch is closed
- Returns:
Status code
- Return type:
- set_reverse_limit(closed: bool) phoenix6.status_code.StatusCode¶
Sets the simulated reverse limit switch of the TalonFX.
- Parameters:
closed (bool) – Whether the limit switch is closed
- Returns:
Status code
- Return type:
- set_raw_rotor_position(rotations: phoenix6.units.rotation) phoenix6.status_code.StatusCode¶
Sets the simulated raw rotor position of the TalonFX. This is the position of the rotor (before gear ratio) used for the RotorSensor feedback source.
Inputs to this function over time should be continuous, as user calls of TalonFX.set_position will be accounted for in the callee.
The TalonFX integrates this to calculate the true reported rotor position.
When using the WPI Sim GUI, you will notice a readonly position and settable rawPositionInput. The readonly signal is the emulated position which will match self-test in Tuner and the hardware API. Changes to rawPositionInput 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 (rotation) – The raw position in rotations
- Returns:
Status code
- Return type:
- add_rotor_position(drotations: phoenix6.units.rotation) phoenix6.status_code.StatusCode¶
Adds to the simulated rotor position of the TalonFX. This adds to the position of the rotor (before gear ratio) used for the RotorSensor feedback source.
- Parameters:
drotations (rotation) – The change in position in rotations
- Returns:
Status code
- Return type:
- set_rotor_velocity(rps: phoenix6.units.rotations_per_second) phoenix6.status_code.StatusCode¶
Sets the simulated rotor velocity of the TalonFX. This is the velocity of the rotor (before gear ratio) used for the RotorSensor feedback source.
- Parameters:
rps (rotations_per_second) – The new velocity in rotations per second
- Returns:
Status code
- Return type:
- set_rotor_acceleration(rpss: phoenix6.units.rotations_per_second_squared) phoenix6.status_code.StatusCode¶
Sets the simulated rotor acceleration of the TalonFX. This is the acceleration of the rotor (before gear ratio) used for the RotorSensor feedback source.
- Parameters:
rpss (rotations_per_second_squared) – The new acceleration in rotations per second²
- Returns:
Status code
- Return type: