phoenix6.sim.candi_sim_state
¶
Module Contents¶
- class phoenix6.sim.candi_sim_state.CANdiSimState(device: phoenix6.hardware.core.core_candi.CoreCANdi, pwm1_orientation=ChassisReference.CounterClockwise_Positive, pwm2_orientation=ChassisReference.CounterClockwise_Positive, quadrature_orientation=ChassisReference.CounterClockwise_Positive, quadrature_edges_per_rotation=4096)¶
Creates an object to control the state of a simulated CANdi.
Note the recommended method of accessing simulation features is to use CANdi.sim_state.
- Parameters:
device (CoreCANdi) – Device to which this simulation state is attached
pwm1_orientation (ChassisReference) – The orientation of the PWM1 sensor relative to the robot chassis.
pwm2_orientation (ChassisReference) – The orientation of the PWM2 sensor relative to the robot chassis.
quadrature_orientation (ChassisReference) – The orientation of the Quadrature sensor relative to the robot chassis.
quadrature_edges_per_rotation (int) – The number of quadrature edges per sensor rotation for an external quadrature sensor attached to the CANdi.
- pwm1_orientation¶
The orientation of the PWM1 sensor relative to the robot chassis.
This value should not be changed based on the CANdi PWM1 invert. Rather, this value should be changed when the mechanical linkage between the sensor and the robot changes.
- pwm2_orientation¶
The orientation of the PWM2 sensor relative to the robot chassis.
This value should not be changed based on the CANdi PWM2 invert. Rather, this value should be changed when the mechanical linkage between the sensor and the robot changes.
- quadrature_orientation¶
The orientation of the Quadrature sensor relative to the robot chassis. <p> This value should not be changed based on the CANdi Quadrature invert. Rather, this value should be changed when the mechanical linkage between the sensor and the robot changes.
- quadrature_edges_per_rotation¶
The number of quadrature edges per sensor rotation for an external quadrature sensor attached to the CANdi.
- set_supply_voltage(volts: phoenix6.units.volt) phoenix6.status_code.StatusCode ¶
Sets the simulated supply voltage of the CANdi.
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_output_current(current: phoenix6.units.ampere) phoenix6.status_code.StatusCode ¶
Sets the simulated output current of the CANdi.
- Parameters:
current (ampere) – The output current
- Returns:
Status Code
- Return type:
- set_pwm1_rise_rise(time: phoenix6.units.second) phoenix6.status_code.StatusCode ¶
Sets the simulated PWM1 Rise to Rise timing of the CANdi.
- Parameters:
time (second) – The time between two Rise events
- Returns:
Status Code
- Return type:
- set_pwm1_rise_fall(time: phoenix6.units.second) phoenix6.status_code.StatusCode ¶
Sets the simulated PWM1 Rise to Fall timing of the CANdi.
- Parameters:
time (second) – The time between the Rise and Fall events in seconds
- Returns:
Status Code
- Return type:
- set_pwm1_connected(connected: bool) phoenix6.status_code.StatusCode ¶
Sets whether a PWM sensor is connected to the S1 pin.
- Parameters:
connected (bool) – True if sensor is connected
- Returns:
Status Code
- Return type:
- set_pwm1_position(position: phoenix6.units.rotation) phoenix6.status_code.StatusCode ¶
Sets the simulated pulse width position of the CANdi. This is the position of an external PWM encoder connected to the S1 pin.
- Parameters:
position (rotation) – The new position
- Returns:
Status Code
- Return type:
- set_pwm1_velocity(velocity: phoenix6.units.rotations_per_second) phoenix6.status_code.StatusCode ¶
Sets the simulated pulse width velocity of the CANdi. This is the velocity of an external PWM encoder connected to the S1 pin.
- Parameters:
velocity (rotations_per_second) – The new velocity
- Returns:
Status Code
- Return type:
- set_pwm2_rise_rise(time: phoenix6.units.second) phoenix6.status_code.StatusCode ¶
Sets the simulated PWM2 Rise to Rise timing of the CANdi.
- Parameters:
time (second) – The time between two Rise events
- Returns:
Status Code
- Return type:
- set_pwm2_rise_fall(time: phoenix6.units.second) phoenix6.status_code.StatusCode ¶
Sets the simulated PWM2 Rise to Fall timing of the CANdi.
- Parameters:
time (second) – The time between the Rise and Fall events in seconds
- Returns:
Status Code
- Return type:
- set_pwm2_connected(connected: bool) phoenix6.status_code.StatusCode ¶
Sets whether a PWM sensor is connected to the S2 pin.
- Parameters:
connected (bool) – True if sensor is connected
- Returns:
Status Code
- Return type:
- set_pwm2_position(position: phoenix6.units.rotation) phoenix6.status_code.StatusCode ¶
Sets the simulated pulse width position of the CANdi. This is the position of an external PWM encoder connected to the S2 pin.
- Parameters:
position (rotation) – The new position
- Returns:
Status Code
- Return type:
- set_pwm2_velocity(velocity: phoenix6.units.rotations_per_second) phoenix6.status_code.StatusCode ¶
Sets the simulated pulse width velocity of the CANdi. This is the velocity of an external PWM encoder connected to the S2 pin.
- Parameters:
velocity (rotations_per_second) – The new velocity
- Returns:
Status Code
- Return type:
- set_raw_quadrature_position(position: phoenix6.units.rotation) phoenix6.status_code.StatusCode ¶
Sets the simulated raw quadrature position of the CANdi.
Inputs to this function over time should be continuous, as user calls of CANdi.set_quadrature_position will be accounted for in the callee.
The CANdi 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.
- Parameters:
position (rotation) – The raw position
- Returns:
Status Code
- Return type:
- set_quadrature_velocity(velocity: phoenix6.units.rotations_per_second) phoenix6.status_code.StatusCode ¶
Sets the simulated pulse width velocity of the CANdi.
- Parameters:
velocity (rotations_per_second) – The new velocity
- Returns:
Status Code
- Return type:
- set_s1_state(state: phoenix6.signals.spn_enums.S1StateValue) phoenix6.status_code.StatusCode ¶
Sets the state of the S1 pin
- Parameters:
state (S1StateValue) – The state to set the S1 pin to
- Returns:
Status Code
- Return type:
- set_s2_state(state: phoenix6.signals.spn_enums.S2StateValue) phoenix6.status_code.StatusCode ¶
Sets the state of the S2 pin
- Parameters:
state (S2StateValue) – The state to St the S2 pin to
- Returns:
Status Code
- Return type: