phoenix6.mechanisms.simple_differential_mechanism¶
Module Contents¶
Attributes¶
- phoenix6.mechanisms.simple_differential_mechanism.MotorT¶
- class phoenix6.mechanisms.simple_differential_mechanism.SimpleDifferentialMechanism(motor_type: type[MotorT], constants: phoenix6.mechanisms.differential_constants.DifferentialMotorConstants)¶
- class phoenix6.mechanisms.simple_differential_mechanism.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.simple_differential_mechanism.SimpleDifferentialMechanism(motor_type: type[MotorT], constants: phoenix6.mechanisms.differential_constants.DifferentialMotorConstants, cancoder: phoenix6.hardware.cancoder.CANcoder, /)
- class phoenix6.mechanisms.simple_differential_mechanism.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.EnumPossible 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.EnumPossible 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:
- property disabled_reason: DisabledReasonValue¶
- Returns:
The reason for the mechanism being disabled
- Return type:
- property requires_user_reason: RequiresUserReasonValue¶
- Returns:
The reason for the mechanism requiring user action to resume control
- Return type:
- 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:
- 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:
- 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