phoenix6.sim.cancoder_sim_state#

Module Contents#

class phoenix6.sim.cancoder_sim_state.CANcoderSimState(device: phoenix6.hardware.core.core_cancoder.CoreCANcoder, orientation: phoenix6.sim.chassis_reference.ChassisReference = ChassisReference.CounterClockwise_Positive)#

Creates an object to control the state of a simulated CANcoder.

Note the recommended method of accessing simulation features is to use CANcoder.sim_state.

Parameters:
  • device (CoreCANcoder) – Device to which this simulation state is attached

  • orientation (ChassisReference) – Orientation of the device relative to the robot chassis

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.

set_supply_voltage(volts: phoenix6.units.volt) phoenix6.status_code.StatusCode#

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 (volt) – The supply voltage in Volts

Returns:

Status code

Return type:

StatusCode

set_raw_position(rotations: phoenix6.units.rotation) phoenix6.status_code.StatusCode#

Sets the simulated raw position of the CANcoder.

Inputs to this function over time should be continuous, as user calls of CANcoder.set_position 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 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:

StatusCode

add_position(drotations: phoenix6.units.rotation) phoenix6.status_code.StatusCode#

Adds to the simulated position of the CANcoder.

Parameters:

drotations (rotation) – The change in position in rotations

Returns:

Status code

Return type:

StatusCode

set_velocity(rps: phoenix6.units.rotations_per_second) phoenix6.status_code.StatusCode#

Sets the simulated velocity of the CANcoder.

Parameters:

rps (rotations_per_second) – The new velocity in rotations per second

Returns:

Status code

Return type:

StatusCode

set_magnet_health(value: phoenix6.signals.spn_enums.MagnetHealthValue) phoenix6.status_code.StatusCode#

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. :type value: MagnetHealthValue :returns: Status code :rtype: StatusCode