:py:mod:`phoenix6.mechanisms` ============================= .. py:module:: phoenix6.mechanisms Submodules ---------- .. toctree:: :titlesonly: :maxdepth: 1 differential_constants/index.rst differential_mechanism/index.rst mechanism_state/index.rst simple_differential_mechanism/index.rst Package Contents ---------------- .. py:class:: MechanismState(*args, **kwds) Bases: :py:obj:`enum.Enum` Possible states of a mechanism. .. py:attribute:: OK :value: '0' The mechanism is running normally. .. py:attribute:: DISABLED :value: '1' The mechanism is temporarily disabled due to an issue. .. py:attribute:: REQUIRES_USER_ACTION :value: '2' The mechanism is disabled and requires user action. .. py:class:: DifferentialMotorConstants Bases: :py:obj:`Generic`\ [\ :py:obj:`MotorConfigsT`\ ] All constants for setting up the motors of a differential mechanism. .. py:attribute:: can_bus_name :type: str :value: "''" 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. .. py:attribute:: leader_id :type: int :value: '0' CAN ID of the leader motor in the differential mechanism. The leader will have the differential output added to its regular output. .. py:attribute:: follower_id :type: int :value: '0' CAN ID of the follower motor in the differential mechanism. The follower will have the differential output subtracted from its regular output. .. py:attribute:: alignment :type: phoenix6.signals.MotorAlignmentValue The alignment of the differential leader and follower motors, ignoring the configured inverts. .. py:attribute:: sensor_to_differential_ratio :type: float :value: '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. .. py:attribute:: closed_loop_rate :type: phoenix6.units.hertz :value: '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. .. py:attribute:: leader_initial_configs :type: MotorConfigsT | None :value: '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) .. py:attribute:: follower_initial_configs :type: MotorConfigsT | None :value: '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 .. py:attribute:: follower_uses_common_leader_configs :type: bool :value: '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. .. py:method:: 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. :param new_can_bus_name: Parameter to modify :type new_can_bus_name: str :returns: this object :rtype: DifferentialMotorConstants[MotorConfigsT] .. py:method:: 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. :param new_leader_id: Parameter to modify :type new_leader_id: int :returns: this object :rtype: DifferentialMotorConstants[MotorConfigsT] .. py:method:: 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. :param new_follower_id: Parameter to modify :type new_follower_id: int :returns: this object :rtype: DifferentialMotorConstants[MotorConfigsT] .. py:method:: 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. :param new_alignment: Parameter to modify :type new_alignment: MotorAlignmentValue :returns: this object :rtype: DifferentialMotorConstants[MotorConfigsT] .. py:method:: 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. :param new_sensor_to_differential_ratio: Parameter to modify :type new_sensor_to_differential_ratio: float :returns: this object :rtype: DifferentialMotorConstants[MotorConfigsT] .. py:method:: 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. :param new_closed_loop_rate: Parameter to modify :type new_closed_loop_rate: hertz :returns: this object :rtype: DifferentialMotorConstants[MotorConfigsT] .. py:method:: 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) :param new_leader_initial_configs: Parameter to modify :type new_leader_initial_configs: MotorConfigsT | None :returns: this object :rtype: DifferentialMotorConstants[MotorConfigsT] .. py:method:: 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 :param new_follower_initial_configs: Parameter to modify :type new_follower_initial_configs: MotorConfigsT | None :returns: this object :rtype: DifferentialMotorConstants[MotorConfigsT] .. py:method:: 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. :param new_follower_uses_common_leader_configs: Parameter to modify :type new_follower_uses_common_leader_configs: bool :returns: this object :rtype: DifferentialMotorConstants[MotorConfigsT] .. py:class:: DifferentialPigeon2Source(*args, **kwds) Bases: :py:obj:`enum.Enum` Sensor sources for a differential Pigeon 2. .. py:attribute:: YAW :value: '0' Use the yaw component of the Pigeon 2. .. py:attribute:: PITCH :value: '1' Use the pitch component of the Pigeon 2. .. py:attribute:: ROLL :value: '2' Use the roll component of the Pigeon 2. .. py:class:: DifferentialCANdiSource(*args, **kwds) Bases: :py:obj:`enum.Enum` Sensor sources for a differential CTR Electronics' CANdi™ branded device. .. py:attribute:: PWM1 :value: '0' Use a pulse-width encoder remotely attached to the Sensor Input 1 (S1IN). .. py:attribute:: PWM2 :value: '1' Use a pulse-width encoder remotely attached to the Sensor Input 2 (S2IN). .. py:attribute:: QUADRATURE :value: '2' Use a quadrature encoder remotely attached to the two Sensor Inputs. .. py:class:: DifferentialMechanism(motor_type: type[MotorT], constants: phoenix6.mechanisms.differential_constants.DifferentialMotorConstants) DifferentialMechanism(motor_type: type[MotorT], constants: phoenix6.mechanisms.differential_constants.DifferentialMotorConstants, pigeon2: phoenix6.hardware.pigeon2.Pigeon2, pigeon_source: phoenix6.mechanisms.differential_constants.DifferentialPigeon2Source, /) DifferentialMechanism(motor_type: type[MotorT], constants: phoenix6.mechanisms.differential_constants.DifferentialMotorConstants, cancoder: phoenix6.hardware.cancoder.CANcoder, /) DifferentialMechanism(motor_type: type[MotorT], constants: phoenix6.mechanisms.differential_constants.DifferentialMotorConstants, candi: phoenix6.hardware.candi.CANdi, candi_source: phoenix6.mechanisms.differential_constants.DifferentialCANdiSource, /) Bases: :py:obj:`Generic`\ [\ :py:obj:`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. .. py:class:: DisabledReasonValue(*args, **kwds) Bases: :py:obj:`enum.Enum` Possible reasons for the mechanism to disable. .. py:attribute:: NONE :value: '0' No reason given. .. py:attribute:: MISSING_REMOTE_SENSOR :value: '1' A remote sensor is not present on CAN Bus. .. py:attribute:: MISSING_DIFFERENTIAL_FX :value: '2' The remote Talon FX used for differential control is not present on CAN Bus. .. py:attribute:: REMOTE_SENSOR_POS_OVERFLOW :value: '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. .. py:attribute:: DEVICE_HAS_RESET :value: '4' A device or remote sensor has reset. .. py:class:: RequiresUserReasonValue(*args, **kwds) Bases: :py:obj:`enum.Enum` Possible reasons for the mechanism to require user action to resume control. .. py:attribute:: NONE :value: '0' No reason given. .. py:attribute:: REMOTE_SENSOR_POS_OVERFLOW :value: '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. .. py:attribute:: DEVICE_HAS_RESET :value: '2' A device or remote sensor has reset. .. py:property:: is_disabled :type: bool Get whether the mechanism is currently disabled due to an issue. :returns: true if the mechanism is temporarily disabled :rtype: bool .. py:property:: requires_user_action :type: 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 :rtype: bool .. py:property:: mechanism_state :type: phoenix6.mechanisms.mechanism_state.MechanismState Gets the state of the mechanism. :returns: MechanismState representing the state of the mechanism :rtype: MechanismState .. py:property:: disabled_reason :type: DisabledReasonValue :returns: The reason for the mechanism being disabled :rtype: DisabledReasonValue .. py:property:: requires_user_reason :type: RequiresUserReasonValue :returns: The reason for the mechanism requiring user action to resume control :rtype: RequiresUserReasonValue .. py:property:: leader :type: 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 .. py:property:: follower :type: 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 .. py:method:: 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. :param neutral_mode: The state of the motor controller bridge when output is neutral or disabled :type neutral_mode: NeutralModeValue :param timeout: Maximum amount of time to wait when performing each configuration :type timeout: second :returns: Status code of the first failed config call, or OK if all succeeded :rtype: StatusCode .. py:method:: periodic() Call this method periodically to automatically protect against dangerous fault conditions and keep self.mechanism_state updated. .. py:method:: clear_user_requirement() Indicate to the mechanism that the user has performed the required action to resume mechanism control. .. py:method:: 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. :param refresh: Whether to refresh the StatusSignal before returning it; defaults to true :type refresh: bool :returns: DifferentialAveragePosition Status Signal Object :rtype: StatusSignal[rotation] .. py:method:: 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. :param refresh: Whether to refresh the StatusSignal before returning it; defaults to true :type refresh: bool :returns: DifferentialAverageVelocity Status Signal Object :rtype: StatusSignal[rotations_per_second] .. py:method:: 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. :param refresh: Whether to refresh the StatusSignal before returning it; defaults to true :type refresh: bool :returns: DifferentialDifferencePosition Status Signal Object :rtype: StatusSignal[rotation] .. py:method:: 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. :param refresh: Whether to refresh the StatusSignal before returning it; defaults to true :type refresh: bool :returns: DifferentialDifferenceVelocity Status Signal Object :rtype: StatusSignal[rotations_per_second] .. py:method:: 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. :param refresh: Whether to refresh the StatusSignal before returning it; defaults to true :type refresh: bool :returns: ClosedLoopReference Status Signal object :rtype: StatusSignal[float] .. py:method:: 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. :param refresh: Whether to refresh the StatusSignal before returning it; defaults to true :type refresh: bool :returns: ClosedLoopReferenceSlope Status Signal object :rtype: StatusSignal[float] .. py:method:: 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. :param refresh: Whether to refresh the StatusSignal before returning it; defaults to true :type refresh: bool :returns: ClosedLoopError Status Signal object :rtype: StatusSignal[float] .. py:method:: 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. :param refresh: Whether to refresh the StatusSignal before returning it; defaults to true :type refresh: bool :returns: DifferentialClosedLoopReference Status Signal object :rtype: StatusSignal[float] .. py:method:: 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. :param refresh: Whether to refresh the StatusSignal before returning it; defaults to true :type refresh: bool :returns: DifferentialClosedLoopReferenceSlope Status Signal object :rtype: StatusSignal[float] .. py:method:: 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. :param refresh: Whether to refresh the StatusSignal before returning it; defaults to true :type refresh: bool :returns: DifferentialClosedLoopError Status Signal object :rtype: StatusSignal[float] .. py:method:: 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. :param avg_position: The average position of the mechanism, in rotations :type avg_position: rotation :param diff_position: The differential position of the mechanism, in rotations :type diff_position: rotation :param timeout: Maximum time to wait up to in seconds :type timeout: second :returns: StatusCode of the set command :rtype: StatusCode .. py:method:: 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. .. py:method:: 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. .. py:method:: 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. .. py:method:: 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 .. py:class:: SimpleDifferentialMechanism(motor_type: type[MotorT], constants: phoenix6.mechanisms.differential_constants.DifferentialMotorConstants) SimpleDifferentialMechanism(motor_type: type[MotorT], constants: phoenix6.mechanisms.differential_constants.DifferentialMotorConstants, pigeon2: phoenix6.hardware.pigeon2.Pigeon2, pigeon_source: phoenix6.mechanisms.differential_constants.DifferentialPigeon2Source, /) SimpleDifferentialMechanism(motor_type: type[MotorT], constants: phoenix6.mechanisms.differential_constants.DifferentialMotorConstants, cancoder: phoenix6.hardware.cancoder.CANcoder, /) SimpleDifferentialMechanism(motor_type: type[MotorT], constants: phoenix6.mechanisms.differential_constants.DifferentialMotorConstants, candi: phoenix6.hardware.candi.CANdi, candi_source: phoenix6.mechanisms.differential_constants.DifferentialCANdiSource, /) Bases: :py:obj:`Generic`\ [\ :py:obj:`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. .. py:class:: DisabledReasonValue(*args, **kwds) Bases: :py:obj:`enum.Enum` Possible reasons for the mechanism to disable. .. py:attribute:: NONE :value: '0' No reason given. .. py:attribute:: MISSING_REMOTE_SENSOR :value: '1' A remote sensor is not present on CAN Bus. .. py:attribute:: MISSING_DIFFERENTIAL_FX :value: '2' The remote Talon FX used for differential control is not present on CAN Bus. .. py:attribute:: REMOTE_SENSOR_POS_OVERFLOW :value: '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. .. py:attribute:: DEVICE_HAS_RESET :value: '4' A device or remote sensor has reset. .. py:class:: RequiresUserReasonValue(*args, **kwds) Bases: :py:obj:`enum.Enum` Possible reasons for the mechanism to require user action to resume control. .. py:attribute:: NONE :value: '0' No reason given. .. py:attribute:: REMOTE_SENSOR_POS_OVERFLOW :value: '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. .. py:attribute:: DEVICE_HAS_RESET :value: '2' A device or remote sensor has reset. .. py:property:: is_disabled :type: bool Get whether the mechanism is currently disabled due to an issue. :returns: true if the mechanism is temporarily disabled :rtype: bool .. py:property:: requires_user_action :type: 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 :rtype: bool .. py:property:: mechanism_state :type: phoenix6.mechanisms.mechanism_state.MechanismState Gets the state of the mechanism. :returns: MechanismState representing the state of the mechanism :rtype: MechanismState .. py:property:: disabled_reason :type: DisabledReasonValue :returns: The reason for the mechanism being disabled :rtype: DisabledReasonValue .. py:property:: requires_user_reason :type: RequiresUserReasonValue :returns: The reason for the mechanism requiring user action to resume control :rtype: RequiresUserReasonValue .. py:property:: leader :type: 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 .. py:property:: follower :type: 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 .. py:method:: 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. :param neutral_mode: The state of the motor controller bridge when output is neutral or disabled :type neutral_mode: NeutralModeValue :param timeout: Maximum amount of time to wait when performing each configuration :type timeout: second :returns: Status code of the first failed config call, or OK if all succeeded :rtype: StatusCode .. py:method:: periodic() Call this method periodically to automatically protect against dangerous fault conditions and keep self.mechanism_state updated. .. py:method:: clear_user_requirement() Indicate to the mechanism that the user has performed the required action to resume mechanism control. .. py:method:: 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. :param refresh: Whether to refresh the StatusSignal before returning it; defaults to true :type refresh: bool :returns: DifferentialAveragePosition Status Signal Object :rtype: StatusSignal[rotation] .. py:method:: 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. :param refresh: Whether to refresh the StatusSignal before returning it; defaults to true :type refresh: bool :returns: DifferentialAverageVelocity Status Signal Object :rtype: StatusSignal[rotations_per_second] .. py:method:: 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. :param refresh: Whether to refresh the StatusSignal before returning it; defaults to true :type refresh: bool :returns: DifferentialDifferencePosition Status Signal Object :rtype: StatusSignal[rotation] .. py:method:: 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. :param refresh: Whether to refresh the StatusSignal before returning it; defaults to true :type refresh: bool :returns: DifferentialDifferenceVelocity Status Signal Object :rtype: StatusSignal[rotations_per_second] .. py:method:: 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. :param refresh: Whether to refresh the StatusSignal before returning it; defaults to true :type refresh: bool :returns: ClosedLoopReference Status Signal object :rtype: StatusSignal[float] .. py:method:: 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. :param refresh: Whether to refresh the StatusSignal before returning it; defaults to true :type refresh: bool :returns: ClosedLoopReferenceSlope Status Signal object :rtype: StatusSignal[float] .. py:method:: 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. :param refresh: Whether to refresh the StatusSignal before returning it; defaults to true :type refresh: bool :returns: ClosedLoopError Status Signal object :rtype: StatusSignal[float] .. py:method:: 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. :param refresh: Whether to refresh the StatusSignal before returning it; defaults to true :type refresh: bool :returns: DifferentialClosedLoopReference Status Signal object :rtype: StatusSignal[float] .. py:method:: 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. :param refresh: Whether to refresh the StatusSignal before returning it; defaults to true :type refresh: bool :returns: DifferentialClosedLoopReferenceSlope Status Signal object :rtype: StatusSignal[float] .. py:method:: 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. :param refresh: Whether to refresh the StatusSignal before returning it; defaults to true :type refresh: bool :returns: DifferentialClosedLoopError Status Signal object :rtype: StatusSignal[float] .. py:method:: 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. :param avg_position: The average position of the mechanism, in rotations :type avg_position: rotation :param diff_position: The differential position of the mechanism, in rotations :type diff_position: rotation :param timeout: Maximum time to wait up to in seconds :type timeout: second :returns: StatusCode of the set command :rtype: StatusCode .. py:method:: 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. .. py:method:: 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. .. py:method:: 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. .. py:method:: 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