phoenix6.mechanisms

Submodules

Package Contents

class phoenix6.mechanisms.MechanismState(*args, **kwds)

Bases: enum.Enum

Possible states of a mechanism.

OK = '0'

The mechanism is running normally.

DISABLED = '1'

The mechanism is temporarily disabled due to an issue.

REQUIRES_USER_ACTION = '2'

The mechanism is disabled and requires user action.

class phoenix6.mechanisms.DifferentialMotorConstants

Bases: Generic[MotorConfigsT]

All constants for setting up the motors of a differential mechanism.

can_bus_name: str = "''"

Name of the CAN bus the mechanism is on. Possible CAN bus strings are:

  • “rio” for the native roboRIO CAN bus

  • CANivore name or serial number

  • SocketCAN interface (non-FRC Linux only)

  • “*” for any CANivore seen by the program

  • empty string (default) to select the default for the system:
    • “rio” on roboRIO

    • “can0” on Linux

    • “*” on Windows

Note that all devices must be on the same CAN bus.

leader_id: int = '0'

CAN ID of the leader motor in the differential mechanism. The leader will have the differential output added to its regular output.

follower_id: int = '0'

CAN ID of the follower motor in the differential mechanism. The follower will have the differential output subtracted from its regular output.

alignment: phoenix6.signals.MotorAlignmentValue

The alignment of the differential leader and follower motors, ignoring the configured inverts.

sensor_to_differential_ratio: float = '1.0'

The ratio of sensor rotations to the differential mechanism’s difference output, where a ratio greater than 1 is a reduction.

When not using a separate sensor on the difference axis, the sensor is considered half of the difference between the two motor controllers’ mechanism positions/velocities. As a result, this should be set to the gear ratio on the difference axis in that scenario, or any gear ratio between the sensor and the mechanism differential when using another sensor source.

closed_loop_rate: phoenix6.units.hertz = '100'

The update rate of the closed-loop controllers. This determines the update rate of the differential leader’s DifferentialOutput status signal, the follower’s Position and Velocity signals, and the relevant signals for any other selected differential sensor.

leader_initial_configs: MotorConfigsT | None = 'None'

The initial configs used to configure the differential leader. The default value is the factory-default.

Users may change the initial configuration as they need. Any config that’s not referenced in the DifferentialMotorConstants class is available to be changed.

The list of configs that will be overwritten is as follows:

  • DifferentialSensorsConfigs (automatic based on the devices used)

follower_initial_configs: MotorConfigsT | None = 'None'

The initial configs used to configure the differential follower. The default value is the factory-default.

Users may change the initial configuration as they need. Any config that’s not referenced in the DifferentialMotorConstants class is available to be changed.

The list of configs that will be overwritten is as follows:

  • DifferentialSensorsConfigs (factory defaulted)

  • MotorOutputConfigs.inverted (determined from self.alignment and the self.leaderInitialConfigs invert)

If self.followerUsesCommonLeaderConfigs is set to true (default), the following configs are copied from self.leaderInitialConfigs:

  • AudioConfigs

  • CurrentLimitsConfigs

  • MotorOutputConfigs (except MotorOutputConfigs.inverted)

  • TorqueCurrentConfigs

  • VoltageConfigs

follower_uses_common_leader_configs: bool = 'True'

Whether the follower should overwrite some of its initial configs with common configs from the self.leaderInitialConfigs, such as current limits. The list of configs that are copied is documented in self.followerInitialConfigs.

with_can_bus_name(new_can_bus_name: str) DifferentialMotorConstants[MotorConfigsT]

Modifies the can_bus_name parameter and returns itself.

Name of the CAN bus the mechanism is on. Possible CAN bus strings are:

  • “rio” for the native roboRIO CAN bus

  • CANivore name or serial number

  • SocketCAN interface (non-FRC Linux only)

  • “*” for any CANivore seen by the program

  • empty string (default) to select the default for the system:
    • “rio” on roboRIO

    • “can0” on Linux

    • “*” on Windows

Note that all devices must be on the same CAN bus.

Parameters:

new_can_bus_name (str) – Parameter to modify

Returns:

this object

Return type:

DifferentialMotorConstants[MotorConfigsT]

with_leader_id(new_leader_id: int) DifferentialMotorConstants[MotorConfigsT]

Modifies the leader_id parameter and returns itself.

CAN ID of the leader motor in the differential mechanism. The leader will have the differential output added to its regular output.

Parameters:

new_leader_id (int) – Parameter to modify

Returns:

this object

Return type:

DifferentialMotorConstants[MotorConfigsT]

with_follower_id(new_follower_id: int) DifferentialMotorConstants[MotorConfigsT]

Modifies the follower_id parameter and returns itself.

CAN ID of the follower motor in the differential mechanism. The follower will have the differential output subtracted from its regular output.

Parameters:

new_follower_id (int) – Parameter to modify

Returns:

this object

Return type:

DifferentialMotorConstants[MotorConfigsT]

with_alignment(new_alignment: phoenix6.signals.MotorAlignmentValue) DifferentialMotorConstants[MotorConfigsT]

Modifies the alignment parameter and returns itself.

The alignment of the differential leader and follower motors, ignoring the configured inverts.

Parameters:

new_alignment (MotorAlignmentValue) – Parameter to modify

Returns:

this object

Return type:

DifferentialMotorConstants[MotorConfigsT]

with_sensor_to_differential_ratio(new_sensor_to_differential_ratio: float) DifferentialMotorConstants[MotorConfigsT]

Modifies the sensor_to_differential_ratio parameter and returns itself.

The ratio of sensor rotations to the differential mechanism’s difference output, where a ratio greater than 1 is a reduction.

When not using a separate sensor on the difference axis, the sensor is considered half of the difference between the two motor controllers’ mechanism positions/velocities. As a result, this should be set to the gear ratio on the difference axis in that scenario, or any gear ratio between the sensor and the mechanism differential when using another sensor source.

Parameters:

new_sensor_to_differential_ratio (float) – Parameter to modify

Returns:

this object

Return type:

DifferentialMotorConstants[MotorConfigsT]

with_closed_loop_rate(new_closed_loop_rate: phoenix6.units.hertz) DifferentialMotorConstants[MotorConfigsT]

Modifies the closed_loop_rate parameter and returns itself.

The update rate of the closed-loop controllers. This determines the update rate of the differential leader’s DifferentialOutput status signal, the follower’s Position and Velocity signals, and the relevant signals for any other selected differential sensor.

Parameters:

new_closed_loop_rate (hertz) – Parameter to modify

Returns:

this object

Return type:

DifferentialMotorConstants[MotorConfigsT]

with_leader_initial_configs(new_leader_initial_configs: MotorConfigsT | None) DifferentialMotorConstants[MotorConfigsT]

Modifies the leader_initial_configs parameter and returns itself.

The initial configs used to configure the differential leader. The default value is the factory-default.

Users may change the initial configuration as they need. Any config that’s not referenced in the DifferentialMotorConstants class is available to be changed.

The list of configs that will be overwritten is as follows:

  • DifferentialSensorsConfigs (automatic based on the devices used)

Parameters:

new_leader_initial_configs (MotorConfigsT | None) – Parameter to modify

Returns:

this object

Return type:

DifferentialMotorConstants[MotorConfigsT]

with_follower_initial_configs(new_follower_initial_configs: MotorConfigsT | None) DifferentialMotorConstants[MotorConfigsT]

Modifies the follower_initial_configs parameter and returns itself.

The initial configs used to configure the differential follower. The default value is the factory-default.

Users may change the initial configuration as they need. Any config that’s not referenced in the DifferentialMotorConstants class is available to be changed.

The list of configs that will be overwritten is as follows:

  • DifferentialSensorsConfigs (factory defaulted)

  • MotorOutputConfigs.inverted (determined from self.alignment and the self.leaderInitialConfigs invert)

If self.followerUsesCommonLeaderConfigs is set to true (default), the following configs are copied from self.leaderInitialConfigs:

  • AudioConfigs

  • CurrentLimitsConfigs

  • MotorOutputConfigs (except MotorOutputConfigs.inverted)

  • TorqueCurrentConfigs

  • VoltageConfigs

Parameters:

new_follower_initial_configs (MotorConfigsT | None) – Parameter to modify

Returns:

this object

Return type:

DifferentialMotorConstants[MotorConfigsT]

with_follower_uses_common_leader_configs(new_follower_uses_common_leader_configs: bool) DifferentialMotorConstants[MotorConfigsT]

Modifies the follower_uses_common_leader_configs parameter and returns itself.

Whether the follower should overwrite some of its initial configs with common configs from the self.leaderInitialConfigs, such as current limits. The list of configs that are copied is documented in self.followerInitialConfigs.

Parameters:

new_follower_uses_common_leader_configs (bool) – Parameter to modify

Returns:

this object

Return type:

DifferentialMotorConstants[MotorConfigsT]

class phoenix6.mechanisms.DifferentialPigeon2Source(*args, **kwds)

Bases: enum.Enum

Sensor sources for a differential Pigeon 2.

YAW = '0'

Use the yaw component of the Pigeon 2.

PITCH = '1'

Use the pitch component of the Pigeon 2.

ROLL = '2'

Use the roll component of the Pigeon 2.

class phoenix6.mechanisms.DifferentialCANdiSource(*args, **kwds)

Bases: enum.Enum

Sensor sources for a differential CTR Electronics’ CANdi™ branded device.

PWM1 = '0'

Use a pulse-width encoder remotely attached to the Sensor Input 1 (S1IN).

PWM2 = '1'

Use a pulse-width encoder remotely attached to the Sensor Input 2 (S2IN).

QUADRATURE = '2'

Use a quadrature encoder remotely attached to the two Sensor Inputs.

class phoenix6.mechanisms.DifferentialMechanism(motor_type: type[MotorT], constants: phoenix6.mechanisms.differential_constants.DifferentialMotorConstants)
class phoenix6.mechanisms.DifferentialMechanism(motor_type: type[MotorT], constants: phoenix6.mechanisms.differential_constants.DifferentialMotorConstants, pigeon2: phoenix6.hardware.pigeon2.Pigeon2, pigeon_source: phoenix6.mechanisms.differential_constants.DifferentialPigeon2Source, /)
class phoenix6.mechanisms.DifferentialMechanism(motor_type: type[MotorT], constants: phoenix6.mechanisms.differential_constants.DifferentialMotorConstants, cancoder: phoenix6.hardware.cancoder.CANcoder, /)
class phoenix6.mechanisms.DifferentialMechanism(motor_type: type[MotorT], constants: phoenix6.mechanisms.differential_constants.DifferentialMotorConstants, candi: phoenix6.hardware.candi.CANdi, candi_source: phoenix6.mechanisms.differential_constants.DifferentialCANdiSource, /)

Bases: Generic[MotorT]

Manages control of a two-axis differential mechanism.

This mechanism requires the devices to be Pro licensed and connected to a CAN FD bus. Unlicensed users and users on a CAN 2.0 bus can use the SimpleDifferentialMechanism instead with limited functionality.

A differential mechanism has two axes of motion, where the position along each axis is determined by two motors in separate gearboxes:

  • Driving both motors in a common direction causes the mechanism to move forward/reverse, up/down, etc.

    • This is the Average axis: position is determined by the average of the two motors’ positions.

  • Driving the motors in opposing directions causes the mechanism to twist or rotate left/right.

    • This is the Difference axis: rotation is determined by half the difference of the two motors’ positions.

class DisabledReasonValue(*args, **kwds)

Bases: enum.Enum

Possible reasons for the mechanism to disable.

NONE = '0'

No reason given.

MISSING_REMOTE_SENSOR = '1'

A remote sensor is not present on CAN Bus.

MISSING_DIFFERENTIAL_FX = '2'

The remote Talon FX used for differential control is not present on CAN Bus.

REMOTE_SENSOR_POS_OVERFLOW = '3'

A remote sensor position has overflowed. Because of the nature of remote sensors, it is possible for a remote sensor position to overflow beyond what is supported by the status signal frame. However, this is rare and cannot occur over the course of an FRC match under normal use.

DEVICE_HAS_RESET = '4'

A device or remote sensor has reset.

class RequiresUserReasonValue(*args, **kwds)

Bases: enum.Enum

Possible reasons for the mechanism to require user action to resume control.

NONE = '0'

No reason given.

REMOTE_SENSOR_POS_OVERFLOW = '1'

A remote sensor position has overflowed. Because of the nature of remote sensors, it is possible for a remote sensor position to overflow beyond what is supported by the status signal frame. However, this is rare and cannot occur over the course of an FRC match under normal use.

DEVICE_HAS_RESET = '2'

A device or remote sensor has reset.

property is_disabled: bool

Get whether the mechanism is currently disabled due to an issue.

Returns:

true if the mechanism is temporarily disabled

Return type:

bool

property requires_user_action: bool

Get whether the mechanism is currently disabled and requires user action to re-enable mechanism control.

Returns:

true if the mechanism is disabled and the user must manually perform an action

Return type:

bool

property mechanism_state: phoenix6.mechanisms.mechanism_state.MechanismState

Gets the state of the mechanism.

Returns:

MechanismState representing the state of the mechanism

Return type:

MechanismState

property disabled_reason: DisabledReasonValue
Returns:

The reason for the mechanism being disabled

Return type:

DisabledReasonValue

property requires_user_reason: RequiresUserReasonValue
Returns:

The reason for the mechanism requiring user action to resume control

Return type:

RequiresUserReasonValue

property leader: MotorT

Get the Talon FX that is differential leader. The differential leader calculates the output for the differential follower. The differential leader is also useful for fault detection, and it reports status signals for the differential controller.

Returns:

Differential leader Talon FX

property follower: MotorT

Get the Talon FX that is differential follower. The differential follower’s position and velocity are used by the differential leader for the differential controller.

Returns:

Differential follower Talon FX

config_neutral_mode(neutral_mode: phoenix6.signals.spn_enums.NeutralModeValue, timeout: phoenix6.units.second = 0.1) phoenix6.status_code.StatusCode

Configures the neutral mode to use for both motors in the mechanism.

Parameters:
  • neutral_mode (NeutralModeValue) – The state of the motor controller bridge when output is neutral or disabled

  • timeout (second) – Maximum amount of time to wait when performing each configuration

Returns:

Status code of the first failed config call, or OK if all succeeded

Return type:

StatusCode

periodic()

Call this method periodically to automatically protect against dangerous fault conditions and keep self.mechanism_state updated.

clear_user_requirement()

Indicate to the mechanism that the user has performed the required action to resume mechanism control.

get_average_position(refresh: bool = True) phoenix6.status_signal.StatusSignal[phoenix6.units.rotation]

Average component of the mechanism position.

  • Minimum Value: -16384.0

  • Maximum Value: 16383.999755859375

  • Default Value: 0

  • Units: rotations

This refreshes and returns a cached StatusSignal object.

Parameters:

refresh (bool) – Whether to refresh the StatusSignal before returning it; defaults to true

Returns:

DifferentialAveragePosition Status Signal Object

Return type:

StatusSignal[rotation]

get_average_velocity(refresh: bool = True) phoenix6.status_signal.StatusSignal[phoenix6.units.rotations_per_second]

Average component of the mechanism velocity.

  • Minimum Value: -512.0

  • Maximum Value: 511.998046875

  • Default Value: 0

  • Units: rotations per second

This refreshes and returns a cached StatusSignal object.

Parameters:

refresh (bool) – Whether to refresh the StatusSignal before returning it; defaults to true

Returns:

DifferentialAverageVelocity Status Signal Object

Return type:

StatusSignal[rotations_per_second]

get_differential_position(refresh: bool = True) phoenix6.status_signal.StatusSignal[phoenix6.units.rotation]

Differential component of the mechanism position.

  • Minimum Value: -16384.0

  • Maximum Value: 16383.999755859375

  • Default Value: 0

  • Units: rotations

This refreshes and returns a cached StatusSignal object.

Parameters:

refresh (bool) – Whether to refresh the StatusSignal before returning it; defaults to true

Returns:

DifferentialDifferencePosition Status Signal Object

Return type:

StatusSignal[rotation]

get_differential_velocity(refresh: bool = True) phoenix6.status_signal.StatusSignal[phoenix6.units.rotations_per_second]

Differential component of the mechanism velocity.

  • Minimum Value: -512.0

  • Maximum Value: 511.998046875

  • Default Value: 0

  • Units: rotations per second

This refreshes and returns a cached StatusSignal object.

Parameters:

refresh (bool) – Whether to refresh the StatusSignal before returning it; defaults to true

Returns:

DifferentialDifferenceVelocity Status Signal Object

Return type:

StatusSignal[rotations_per_second]

get_average_closed_loop_reference(refresh: bool = True) phoenix6.status_signal.StatusSignal[float]

Value that the average closed loop is targeting.

This is the value that the closed loop PID controller targets.

This refreshes and returns a cached StatusSignal object.

Parameters:

refresh (bool) – Whether to refresh the StatusSignal before returning it; defaults to true

Returns:

ClosedLoopReference Status Signal object

Return type:

StatusSignal[float]

get_average_closed_loop_reference_slope(refresh: bool = True) phoenix6.status_signal.StatusSignal[float]

Derivative of the target that the average closed loop is targeting.

This is the change in the closed loop reference. This may be used in the feed-forward calculation, the derivative-error, or in application of the signage for kS. Typically, this represents the target velocity during Motion Magic®.

This refreshes and returns a cached StatusSignal object.

Parameters:

refresh (bool) – Whether to refresh the StatusSignal before returning it; defaults to true

Returns:

ClosedLoopReferenceSlope Status Signal object

Return type:

StatusSignal[float]

get_average_closed_loop_error(refresh: bool = True) phoenix6.status_signal.StatusSignal[float]

The difference between target average reference and current measurement.

This is the value that is treated as the error in the PID loop.

This refreshes and returns a cached StatusSignal object.

Parameters:

refresh (bool) – Whether to refresh the StatusSignal before returning it; defaults to true

Returns:

ClosedLoopError Status Signal object

Return type:

StatusSignal[float]

get_differential_closed_loop_reference(refresh: bool = True) phoenix6.status_signal.StatusSignal[float]

Value that the differential closed loop is targeting.

This is the value that the differential closed loop PID controller targets (on the difference axis).

This refreshes and returns a cached StatusSignal object.

Parameters:

refresh (bool) – Whether to refresh the StatusSignal before returning it; defaults to true

Returns:

DifferentialClosedLoopReference Status Signal object

Return type:

StatusSignal[float]

get_differential_closed_loop_reference_slope(refresh: bool = True) phoenix6.status_signal.StatusSignal[float]

Derivative of the target that the differential closed loop is targeting.

This is the change in the closed loop reference (on the difference axis). This may be used in the feed-forward calculation, the derivative-error, or in application of the signage for kS. Typically, this represents the target velocity during Motion Magic®.

This refreshes and returns a cached StatusSignal object.

Parameters:

refresh (bool) – Whether to refresh the StatusSignal before returning it; defaults to true

Returns:

DifferentialClosedLoopReferenceSlope Status Signal object

Return type:

StatusSignal[float]

get_differential_closed_loop_error(refresh: bool = True) phoenix6.status_signal.StatusSignal[float]

The difference between target differential reference and current measurement.

This is the value that is treated as the error in the differential PID loop (on the difference axis).

This refreshes and returns a cached StatusSignal object.

Parameters:

refresh (bool) – Whether to refresh the StatusSignal before returning it; defaults to true

Returns:

DifferentialClosedLoopError Status Signal object

Return type:

StatusSignal[float]

set_position(avg_position: phoenix6.units.rotation, diff_position: phoenix6.units.rotation = 0.0, timeout: phoenix6.units.second = 0.1) phoenix6.status_code.StatusCode

Sets the position of the mechanism in rotations.

Parameters:
  • avg_position (rotation) – The average position of the mechanism, in rotations

  • diff_position (rotation) – The differential position of the mechanism, in rotations

  • timeout (second) – Maximum time to wait up to in seconds

Returns:

StatusCode of the set command

Return type:

StatusCode

set_neutral_out() phoenix6.status_code.StatusCode

Request neutral output of mechanism. The applied brake type is determined by the NeutralMode configuration of each device.

Since the NeutralMode configuration of devices may not align, users may prefer to use the self.set_coast_out() or self.set_static_brake() method.

@return Status Code of the request.

set_coast_out() phoenix6.status_code.StatusCode

Request coast neutral output of mechanism. The bridge is disabled and the rotor is allowed to coast.

@return Status Code of the request.

set_static_brake() phoenix6.status_code.StatusCode

Applies full neutral-brake on the mechanism by shorting motor leads together.

@return Status Code of the request.

set_control(average_request: phoenix6.controls.duty_cycle_out.DutyCycleOut, differential_request: phoenix6.controls.position_duty_cycle.PositionDutyCycle, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.position_duty_cycle.PositionDutyCycle, differential_request: phoenix6.controls.position_duty_cycle.PositionDutyCycle, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.velocity_duty_cycle.VelocityDutyCycle, differential_request: phoenix6.controls.position_duty_cycle.PositionDutyCycle, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.motion_magic_duty_cycle.MotionMagicDutyCycle, differential_request: phoenix6.controls.position_duty_cycle.PositionDutyCycle, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.motion_magic_expo_duty_cycle.MotionMagicExpoDutyCycle, differential_request: phoenix6.controls.position_duty_cycle.PositionDutyCycle, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.motion_magic_velocity_duty_cycle.MotionMagicVelocityDutyCycle, differential_request: phoenix6.controls.position_duty_cycle.PositionDutyCycle, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.duty_cycle_out.DutyCycleOut, differential_request: phoenix6.controls.velocity_duty_cycle.VelocityDutyCycle, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.position_duty_cycle.PositionDutyCycle, differential_request: phoenix6.controls.velocity_duty_cycle.VelocityDutyCycle, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.velocity_duty_cycle.VelocityDutyCycle, differential_request: phoenix6.controls.velocity_duty_cycle.VelocityDutyCycle, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.motion_magic_duty_cycle.MotionMagicDutyCycle, differential_request: phoenix6.controls.velocity_duty_cycle.VelocityDutyCycle, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.motion_magic_expo_duty_cycle.MotionMagicExpoDutyCycle, differential_request: phoenix6.controls.velocity_duty_cycle.VelocityDutyCycle, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.motion_magic_velocity_duty_cycle.MotionMagicVelocityDutyCycle, differential_request: phoenix6.controls.velocity_duty_cycle.VelocityDutyCycle, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.duty_cycle_out.DutyCycleOut, differential_request: phoenix6.controls.duty_cycle_out.DutyCycleOut, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.position_duty_cycle.PositionDutyCycle, differential_request: phoenix6.controls.duty_cycle_out.DutyCycleOut, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.velocity_duty_cycle.VelocityDutyCycle, differential_request: phoenix6.controls.duty_cycle_out.DutyCycleOut, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.motion_magic_duty_cycle.MotionMagicDutyCycle, differential_request: phoenix6.controls.duty_cycle_out.DutyCycleOut, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.motion_magic_expo_duty_cycle.MotionMagicExpoDutyCycle, differential_request: phoenix6.controls.duty_cycle_out.DutyCycleOut, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.motion_magic_velocity_duty_cycle.MotionMagicVelocityDutyCycle, differential_request: phoenix6.controls.duty_cycle_out.DutyCycleOut, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.voltage_out.VoltageOut, differential_request: phoenix6.controls.position_voltage.PositionVoltage, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.position_voltage.PositionVoltage, differential_request: phoenix6.controls.position_voltage.PositionVoltage, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.velocity_voltage.VelocityVoltage, differential_request: phoenix6.controls.position_voltage.PositionVoltage, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.motion_magic_voltage.MotionMagicVoltage, differential_request: phoenix6.controls.position_voltage.PositionVoltage, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.motion_magic_expo_voltage.MotionMagicExpoVoltage, differential_request: phoenix6.controls.position_voltage.PositionVoltage, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.motion_magic_velocity_voltage.MotionMagicVelocityVoltage, differential_request: phoenix6.controls.position_voltage.PositionVoltage, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.voltage_out.VoltageOut, differential_request: phoenix6.controls.velocity_voltage.VelocityVoltage, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.position_voltage.PositionVoltage, differential_request: phoenix6.controls.velocity_voltage.VelocityVoltage, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.velocity_voltage.VelocityVoltage, differential_request: phoenix6.controls.velocity_voltage.VelocityVoltage, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.motion_magic_voltage.MotionMagicVoltage, differential_request: phoenix6.controls.velocity_voltage.VelocityVoltage, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.motion_magic_expo_voltage.MotionMagicExpoVoltage, differential_request: phoenix6.controls.velocity_voltage.VelocityVoltage, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.motion_magic_velocity_voltage.MotionMagicVelocityVoltage, differential_request: phoenix6.controls.velocity_voltage.VelocityVoltage, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.voltage_out.VoltageOut, differential_request: phoenix6.controls.voltage_out.VoltageOut, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.position_voltage.PositionVoltage, differential_request: phoenix6.controls.voltage_out.VoltageOut, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.velocity_voltage.VelocityVoltage, differential_request: phoenix6.controls.voltage_out.VoltageOut, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.motion_magic_voltage.MotionMagicVoltage, differential_request: phoenix6.controls.voltage_out.VoltageOut, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.motion_magic_expo_voltage.MotionMagicExpoVoltage, differential_request: phoenix6.controls.voltage_out.VoltageOut, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.motion_magic_velocity_voltage.MotionMagicVelocityVoltage, differential_request: phoenix6.controls.voltage_out.VoltageOut, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.torque_current_foc.TorqueCurrentFOC, differential_request: phoenix6.controls.position_torque_current_foc.PositionTorqueCurrentFOC, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.position_torque_current_foc.PositionTorqueCurrentFOC, differential_request: phoenix6.controls.position_torque_current_foc.PositionTorqueCurrentFOC, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.velocity_torque_current_foc.VelocityTorqueCurrentFOC, differential_request: phoenix6.controls.position_torque_current_foc.PositionTorqueCurrentFOC, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.motion_magic_torque_current_foc.MotionMagicTorqueCurrentFOC, differential_request: phoenix6.controls.position_torque_current_foc.PositionTorqueCurrentFOC, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.motion_magic_expo_torque_current_foc.MotionMagicExpoTorqueCurrentFOC, differential_request: phoenix6.controls.position_torque_current_foc.PositionTorqueCurrentFOC, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.motion_magic_velocity_torque_current_foc.MotionMagicVelocityTorqueCurrentFOC, differential_request: phoenix6.controls.position_torque_current_foc.PositionTorqueCurrentFOC, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.torque_current_foc.TorqueCurrentFOC, differential_request: phoenix6.controls.velocity_torque_current_foc.VelocityTorqueCurrentFOC, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.position_torque_current_foc.PositionTorqueCurrentFOC, differential_request: phoenix6.controls.velocity_torque_current_foc.VelocityTorqueCurrentFOC, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.velocity_torque_current_foc.VelocityTorqueCurrentFOC, differential_request: phoenix6.controls.velocity_torque_current_foc.VelocityTorqueCurrentFOC, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.motion_magic_torque_current_foc.MotionMagicTorqueCurrentFOC, differential_request: phoenix6.controls.velocity_torque_current_foc.VelocityTorqueCurrentFOC, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.motion_magic_expo_torque_current_foc.MotionMagicExpoTorqueCurrentFOC, differential_request: phoenix6.controls.velocity_torque_current_foc.VelocityTorqueCurrentFOC, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.motion_magic_velocity_torque_current_foc.MotionMagicVelocityTorqueCurrentFOC, differential_request: phoenix6.controls.velocity_torque_current_foc.VelocityTorqueCurrentFOC, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.torque_current_foc.TorqueCurrentFOC, differential_request: phoenix6.controls.torque_current_foc.TorqueCurrentFOC, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.position_torque_current_foc.PositionTorqueCurrentFOC, differential_request: phoenix6.controls.torque_current_foc.TorqueCurrentFOC, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.velocity_torque_current_foc.VelocityTorqueCurrentFOC, differential_request: phoenix6.controls.torque_current_foc.TorqueCurrentFOC, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.motion_magic_torque_current_foc.MotionMagicTorqueCurrentFOC, differential_request: phoenix6.controls.torque_current_foc.TorqueCurrentFOC, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.motion_magic_expo_torque_current_foc.MotionMagicExpoTorqueCurrentFOC, differential_request: phoenix6.controls.torque_current_foc.TorqueCurrentFOC, /) phoenix6.status_code.StatusCode
set_control(average_request: phoenix6.controls.motion_magic_velocity_torque_current_foc.MotionMagicVelocityTorqueCurrentFOC, differential_request: phoenix6.controls.torque_current_foc.TorqueCurrentFOC, /) phoenix6.status_code.StatusCode
class phoenix6.mechanisms.SimpleDifferentialMechanism(motor_type: type[MotorT], constants: phoenix6.mechanisms.differential_constants.DifferentialMotorConstants)
class phoenix6.mechanisms.SimpleDifferentialMechanism(motor_type: type[MotorT], constants: phoenix6.mechanisms.differential_constants.DifferentialMotorConstants, pigeon2: phoenix6.hardware.pigeon2.Pigeon2, pigeon_source: phoenix6.mechanisms.differential_constants.DifferentialPigeon2Source, /)
class phoenix6.mechanisms.SimpleDifferentialMechanism(motor_type: type[MotorT], constants: phoenix6.mechanisms.differential_constants.DifferentialMotorConstants, cancoder: phoenix6.hardware.cancoder.CANcoder, /)
class phoenix6.mechanisms.SimpleDifferentialMechanism(motor_type: type[MotorT], constants: phoenix6.mechanisms.differential_constants.DifferentialMotorConstants, candi: phoenix6.hardware.candi.CANdi, candi_source: phoenix6.mechanisms.differential_constants.DifferentialCANdiSource, /)

Bases: Generic[MotorT]

Manages control of a simple two-axis differential mechanism.

This mechanism provides limited differential functionality. Pro users on a CAN FD bus can use the DifferentialMechanism instead for full functionality.

A differential mechanism has two axes of motion, where the position along each axis is determined by two motors in separate gearboxes:

  • Driving both motors in a common direction causes the mechanism to move forward/reverse, up/down, etc.

    • This is the Average axis: position is determined by the average of the two motors’ positions.

  • Driving the motors in opposing directions causes the mechanism to twist or rotate left/right.

    • This is the Difference axis: rotation is determined by half the difference of the two motors’ positions.

class DisabledReasonValue(*args, **kwds)

Bases: enum.Enum

Possible reasons for the mechanism to disable.

NONE = '0'

No reason given.

MISSING_REMOTE_SENSOR = '1'

A remote sensor is not present on CAN Bus.

MISSING_DIFFERENTIAL_FX = '2'

The remote Talon FX used for differential control is not present on CAN Bus.

REMOTE_SENSOR_POS_OVERFLOW = '3'

A remote sensor position has overflowed. Because of the nature of remote sensors, it is possible for a remote sensor position to overflow beyond what is supported by the status signal frame. However, this is rare and cannot occur over the course of an FRC match under normal use.

DEVICE_HAS_RESET = '4'

A device or remote sensor has reset.

class RequiresUserReasonValue(*args, **kwds)

Bases: enum.Enum

Possible reasons for the mechanism to require user action to resume control.

NONE = '0'

No reason given.

REMOTE_SENSOR_POS_OVERFLOW = '1'

A remote sensor position has overflowed. Because of the nature of remote sensors, it is possible for a remote sensor position to overflow beyond what is supported by the status signal frame. However, this is rare and cannot occur over the course of an FRC match under normal use.

DEVICE_HAS_RESET = '2'

A device or remote sensor has reset.

property is_disabled: bool

Get whether the mechanism is currently disabled due to an issue.

Returns:

true if the mechanism is temporarily disabled

Return type:

bool

property requires_user_action: bool

Get whether the mechanism is currently disabled and requires user action to re-enable mechanism control.

Returns:

true if the mechanism is disabled and the user must manually perform an action

Return type:

bool

property mechanism_state: phoenix6.mechanisms.mechanism_state.MechanismState

Gets the state of the mechanism.

Returns:

MechanismState representing the state of the mechanism

Return type:

MechanismState

property disabled_reason: DisabledReasonValue
Returns:

The reason for the mechanism being disabled

Return type:

DisabledReasonValue

property requires_user_reason: RequiresUserReasonValue
Returns:

The reason for the mechanism requiring user action to resume control

Return type:

RequiresUserReasonValue

property leader: MotorT

Get the Talon FX that is differential leader. The differential leader calculates the output for the differential follower. The differential leader is also useful for fault detection, and it reports status signals for the differential controller.

Returns:

Differential leader Talon FX

property follower: MotorT

Get the Talon FX that is differential follower. The differential follower’s position and velocity are used by the differential leader for the differential controller.

Returns:

Differential follower Talon FX

config_neutral_mode(neutral_mode: phoenix6.signals.spn_enums.NeutralModeValue, timeout: phoenix6.units.second = 0.1) phoenix6.status_code.StatusCode

Configures the neutral mode to use for both motors in the mechanism.

Parameters:
  • neutral_mode (NeutralModeValue) – The state of the motor controller bridge when output is neutral or disabled

  • timeout (second) – Maximum amount of time to wait when performing each configuration

Returns:

Status code of the first failed config call, or OK if all succeeded

Return type:

StatusCode

periodic()

Call this method periodically to automatically protect against dangerous fault conditions and keep self.mechanism_state updated.

clear_user_requirement()

Indicate to the mechanism that the user has performed the required action to resume mechanism control.

get_average_position(refresh: bool = True) phoenix6.status_signal.StatusSignal[phoenix6.units.rotation]

Average component of the mechanism position.

  • Minimum Value: -16384.0

  • Maximum Value: 16383.999755859375

  • Default Value: 0

  • Units: rotations

This refreshes and returns a cached StatusSignal object.

Parameters:

refresh (bool) – Whether to refresh the StatusSignal before returning it; defaults to true

Returns:

DifferentialAveragePosition Status Signal Object

Return type:

StatusSignal[rotation]

get_average_velocity(refresh: bool = True) phoenix6.status_signal.StatusSignal[phoenix6.units.rotations_per_second]

Average component of the mechanism velocity.

  • Minimum Value: -512.0

  • Maximum Value: 511.998046875

  • Default Value: 0

  • Units: rotations per second

This refreshes and returns a cached StatusSignal object.

Parameters:

refresh (bool) – Whether to refresh the StatusSignal before returning it; defaults to true

Returns:

DifferentialAverageVelocity Status Signal Object

Return type:

StatusSignal[rotations_per_second]

get_differential_position(refresh: bool = True) phoenix6.status_signal.StatusSignal[phoenix6.units.rotation]

Differential component of the mechanism position.

  • Minimum Value: -16384.0

  • Maximum Value: 16383.999755859375

  • Default Value: 0

  • Units: rotations

This refreshes and returns a cached StatusSignal object.

Parameters:

refresh (bool) – Whether to refresh the StatusSignal before returning it; defaults to true

Returns:

DifferentialDifferencePosition Status Signal Object

Return type:

StatusSignal[rotation]

get_differential_velocity(refresh: bool = True) phoenix6.status_signal.StatusSignal[phoenix6.units.rotations_per_second]

Differential component of the mechanism velocity.

  • Minimum Value: -512.0

  • Maximum Value: 511.998046875

  • Default Value: 0

  • Units: rotations per second

This refreshes and returns a cached StatusSignal object.

Parameters:

refresh (bool) – Whether to refresh the StatusSignal before returning it; defaults to true

Returns:

DifferentialDifferenceVelocity Status Signal Object

Return type:

StatusSignal[rotations_per_second]

get_average_closed_loop_reference(refresh: bool = True) phoenix6.status_signal.StatusSignal[float]

Value that the average closed loop is targeting.

This is the value that the closed loop PID controller targets.

This refreshes and returns a cached StatusSignal object.

Parameters:

refresh (bool) – Whether to refresh the StatusSignal before returning it; defaults to true

Returns:

ClosedLoopReference Status Signal object

Return type:

StatusSignal[float]

get_average_closed_loop_reference_slope(refresh: bool = True) phoenix6.status_signal.StatusSignal[float]

Derivative of the target that the average closed loop is targeting.

This is the change in the closed loop reference. This may be used in the feed-forward calculation, the derivative-error, or in application of the signage for kS. Typically, this represents the target velocity during Motion Magic®.

This refreshes and returns a cached StatusSignal object.

Parameters:

refresh (bool) – Whether to refresh the StatusSignal before returning it; defaults to true

Returns:

ClosedLoopReferenceSlope Status Signal object

Return type:

StatusSignal[float]

get_average_closed_loop_error(refresh: bool = True) phoenix6.status_signal.StatusSignal[float]

The difference between target average reference and current measurement.

This is the value that is treated as the error in the PID loop.

This refreshes and returns a cached StatusSignal object.

Parameters:

refresh (bool) – Whether to refresh the StatusSignal before returning it; defaults to true

Returns:

ClosedLoopError Status Signal object

Return type:

StatusSignal[float]

get_differential_closed_loop_reference(refresh: bool = True) phoenix6.status_signal.StatusSignal[float]

Value that the differential closed loop is targeting.

This is the value that the differential closed loop PID controller targets (on the difference axis).

This refreshes and returns a cached StatusSignal object.

Parameters:

refresh (bool) – Whether to refresh the StatusSignal before returning it; defaults to true

Returns:

DifferentialClosedLoopReference Status Signal object

Return type:

StatusSignal[float]

get_differential_closed_loop_reference_slope(refresh: bool = True) phoenix6.status_signal.StatusSignal[float]

Derivative of the target that the differential closed loop is targeting.

This is the change in the closed loop reference (on the difference axis). This may be used in the feed-forward calculation, the derivative-error, or in application of the signage for kS. Typically, this represents the target velocity during Motion Magic®.

This refreshes and returns a cached StatusSignal object.

Parameters:

refresh (bool) – Whether to refresh the StatusSignal before returning it; defaults to true

Returns:

DifferentialClosedLoopReferenceSlope Status Signal object

Return type:

StatusSignal[float]

get_differential_closed_loop_error(refresh: bool = True) phoenix6.status_signal.StatusSignal[float]

The difference between target differential reference and current measurement.

This is the value that is treated as the error in the differential PID loop (on the difference axis).

This refreshes and returns a cached StatusSignal object.

Parameters:

refresh (bool) – Whether to refresh the StatusSignal before returning it; defaults to true

Returns:

DifferentialClosedLoopError Status Signal object

Return type:

StatusSignal[float]

set_position(avg_position: phoenix6.units.rotation, diff_position: phoenix6.units.rotation = 0.0, timeout: phoenix6.units.second = 0.1) phoenix6.status_code.StatusCode

Sets the position of the mechanism in rotations.

Parameters:
  • avg_position (rotation) – The average position of the mechanism, in rotations

  • diff_position (rotation) – The differential position of the mechanism, in rotations

  • timeout (second) – Maximum time to wait up to in seconds

Returns:

StatusCode of the set command

Return type:

StatusCode

set_neutral_out() phoenix6.status_code.StatusCode

Request neutral output of mechanism. The applied brake type is determined by the NeutralMode configuration of each device.

Since the NeutralMode configuration of devices may not align, users may prefer to use the self.set_coast_out() or self.set_static_brake() method.

@return Status Code of the request.

set_coast_out() phoenix6.status_code.StatusCode

Request coast neutral output of mechanism. The bridge is disabled and the rotor is allowed to coast.

@return Status Code of the request.

set_static_brake() phoenix6.status_code.StatusCode

Applies full neutral-brake on the mechanism by shorting motor leads together.

@return Status Code of the request.

set_control(diff_leader_fx_request: phoenix6.controls.differential_duty_cycle.DifferentialDutyCycle, /) phoenix6.status_code.StatusCode
set_control(diff_leader_fx_request: phoenix6.controls.differential_voltage.DifferentialVoltage, /) phoenix6.status_code.StatusCode
set_control(diff_leader_fx_request: phoenix6.controls.differential_position_duty_cycle.DifferentialPositionDutyCycle, /) phoenix6.status_code.StatusCode
set_control(diff_leader_fx_request: phoenix6.controls.differential_position_voltage.DifferentialPositionVoltage, /) phoenix6.status_code.StatusCode
set_control(diff_leader_fx_request: phoenix6.controls.differential_velocity_duty_cycle.DifferentialVelocityDutyCycle, /) phoenix6.status_code.StatusCode
set_control(diff_leader_fx_request: phoenix6.controls.differential_velocity_voltage.DifferentialVelocityVoltage, /) phoenix6.status_code.StatusCode
set_control(diff_leader_fx_request: phoenix6.controls.differential_motion_magic_duty_cycle.DifferentialMotionMagicDutyCycle, /) phoenix6.status_code.StatusCode
set_control(diff_leader_fx_request: phoenix6.controls.differential_motion_magic_voltage.DifferentialMotionMagicVoltage, /) phoenix6.status_code.StatusCode
set_control(diff_leader_fx_request: phoenix6.controls.differential_motion_magic_expo_duty_cycle.DifferentialMotionMagicExpoDutyCycle, /) phoenix6.status_code.StatusCode
set_control(diff_leader_fx_request: phoenix6.controls.differential_motion_magic_expo_voltage.DifferentialMotionMagicExpoVoltage, /) phoenix6.status_code.StatusCode
set_control(diff_leader_fx_request: phoenix6.controls.differential_motion_magic_velocity_duty_cycle.DifferentialMotionMagicVelocityDutyCycle, /) phoenix6.status_code.StatusCode
set_control(diff_leader_fx_request: phoenix6.controls.differential_motion_magic_velocity_voltage.DifferentialMotionMagicVelocityVoltage, /) phoenix6.status_code.StatusCode