phoenix6.mechanisms.differential_constants

Module Contents

Attributes

class phoenix6.mechanisms.differential_constants.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.differential_constants.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.

phoenix6.mechanisms.differential_constants.MotorConfigsT
class phoenix6.mechanisms.differential_constants.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]