:py:mod:`phoenix6.sim.talon_fxs_sim_state` ========================================== .. py:module:: phoenix6.sim.talon_fxs_sim_state Module Contents --------------- .. py:class:: TalonFXSSimState(device: phoenix6.hardware.core.core_talon_fxs.CoreTalonFXS, motor_orientation: phoenix6.sim.chassis_reference.ChassisReference = ChassisReference.COUNTER_CLOCKWISE_POSITIVE, ext_sensor_orientation: phoenix6.sim.chassis_reference.ChassisReference = ChassisReference.COUNTER_CLOCKWISE_POSITIVE) Creates an object to control the state of a simulated TalonFXS. Note the recommended method of accessing simulation features is to use TalonFXS.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. :param device: Device to which this simulation state is attached :type device: CoreTalonFXS :param motor_orientation: Orientation of the motor (and commutation sensor) relative to the robot chassis :type motor_rientation: ChassisReference :param ext_sensor_orientation: Orientation of the external sensor relative to the robot chassis :type ext_sensor_orientation: ChassisReference .. py:property:: last_status_code :type: 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 :rtype: StatusCode .. py:property:: motor_voltage :type: phoenix6.units.volt Gets the simulated output voltage of the motor. :returns: Voltage applied to the motor in Volts :rtype: volt .. py:property:: torque_current :type: 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 :rtype: ampere .. py:property:: supply_current :type: phoenix6.units.ampere Gets the simulated supply current of the TalonFXS. Phoenix 6 simulation automatically calculates current. :returns: Supply current of the TalonFXS in Amperes :rtype: ampere .. py:property:: analog_voltage :type: phoenix6.units.volt Gets the simulated analog voltage of the TalonFXS. :returns: Voltage of the simulated analog input pin on the TalonFXS. :rtype: volt .. py:attribute:: motor_orientation 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. .. py:attribute:: ext_sensor_orientation 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. .. py:attribute:: pulse_width_sensor_offset :type: phoenix6.units.rotation :value: '0.0' 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. .. py:attribute:: quadrature_edges_per_rotation :type: int :value: '4096' The number of quadrature edges per sensor rotation for an external quadrature sensor attached to the TalonFXS. .. py:method:: set_supply_voltage(volts: phoenix6.units.volt) -> phoenix6.status_code.StatusCode 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. :param volts: The supply voltage in Volts :type volts: volt :returns: Status code :rtype: StatusCode .. py:method:: set_forward_limit(closed: bool) -> phoenix6.status_code.StatusCode Sets the simulated forward limit switch of the TalonFXS. :param closed: Whether the limit switch is closed :type closed: bool :returns: Status code :rtype: StatusCode .. py:method:: set_reverse_limit(closed: bool) -> phoenix6.status_code.StatusCode Sets the simulated reverse limit switch of the TalonFXS. :param closed: Whether the limit switch is closed :type closed: bool :returns: Status code :rtype: StatusCode .. py:method:: set_raw_rotor_position(rotations: phoenix6.units.rotation) -> phoenix6.status_code.StatusCode 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 TalonFXS.set_position 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 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. :param rotations: The raw position in rotations :type rotations: rotation :returns: Status code :rtype: StatusCode .. py:method:: add_rotor_position(drotations: phoenix6.units.rotation) -> phoenix6.status_code.StatusCode 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. :param drotations: The change in position in rotations :type drotations: rotation :returns: Status code :rtype: StatusCode .. py:method:: set_rotor_velocity(rps: phoenix6.units.rotations_per_second) -> phoenix6.status_code.StatusCode Sets the simulated rotor velocity of the TalonFXS. This is the velocity of the rotor (before gear ratio) used for the Commutation feedback source. :param rps: The new velocity in rotations per second :type rps: rotations_per_second :returns: Status code :rtype: StatusCode .. py:method:: set_rotor_acceleration(rpss: phoenix6.units.rotations_per_second_squared) -> phoenix6.status_code.StatusCode Sets the simulated rotor acceleration of the TalonFXS. This is the acceleration of the rotor (before gear ratio) used for the Commutation feedback source. :param rpss: The new acceleration in rotations per second² :type rpss: rotations_per_second_squared :returns: Status code :rtype: StatusCode .. py:method:: set_raw_quadrature_position(rotations: phoenix6.units.rotation) -> phoenix6.status_code.StatusCode 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 TalonFXS.set_position 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 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. :param rotations: The raw position in rotations :type rotations: rotation :returns: Status code :rtype: StatusCode .. py:method:: add_quadrature_position(drotations: phoenix6.units.rotation) -> phoenix6.status_code.StatusCode 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. :param drotations: The change in position in rotations :type drotations: rotation :returns: Status code :rtype: StatusCode .. py:method:: set_quadrature_velocity(rps: phoenix6.units.rotations_per_second) -> phoenix6.status_code.StatusCode 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. :param rps: The new velocity in rotations per second :type rps: rotations_per_second :returns: Status code :rtype: StatusCode .. py:method:: set_quadrature_acceleration(rpss: phoenix6.units.rotations_per_second_squared) -> phoenix6.status_code.StatusCode 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. :param rpss: The new acceleration in rotations per second² :type rpss: rotations_per_second_squared :returns: Status code :rtype: StatusCode .. py:method:: set_pulse_width_position(rotations: phoenix6.units.rotation) -> phoenix6.status_code.StatusCode 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. :param rotations: The new position in rotations :type rotations: rotation :returns: Status code :rtype: StatusCode .. py:method:: set_pulse_width_velocity(rps: phoenix6.units.rotations_per_second) -> phoenix6.status_code.StatusCode 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. :param rps: The new velocity in rotations per second :type rps: rotations_per_second :returns: Status code :rtype: StatusCode .. py:method:: set_analog_voltage(volts: phoenix6.units.volt) -> phoenix6.status_code.StatusCode Sets the simulated voltage of the analog input pin on the TalonFXS data port. :param volts: Voltage of the pin :type volts: volt :returns: Status code :rtype: StatusCode