CTRE Phoenix 6 C++ 25.0.0-beta-4
|
Manages control of a simple two-axis differential mechanism. More...
#include <ctre/phoenix6/mechanisms/SimpleDifferentialMechanism.hpp>
Public Types | |
enum class | DifferentialPigeon2Source { Yaw , Pitch , Roll } |
Sensor sources for a differential Pigeon 2. More... | |
enum class | DisabledReason { None , MissingRemoteSensor , MissingDifferentialFX , RemoteSensorPosOverflow , DeviceHasReset } |
Possible reasons for the mechanism to disable. More... | |
enum class | RequiresUserReason { None , RemoteSensorPosOverflow , DeviceHasReset } |
Possible reasons for the mechanism to require user action to resume control. More... | |
Public Member Functions | |
SimpleDifferentialMechanism (hardware::TalonFX &differentialAddFX, hardware::TalonFX &differentialSubFX, bool motorDirectionsAlign) | |
Creates a new simple differential mechanism using the given two hardware::TalonFX devices. | |
SimpleDifferentialMechanism (hardware::TalonFX &differentialAddFX, hardware::TalonFX &differentialSubFX, bool motorDirectionsAlign, hardware::Pigeon2 &pigeon2, DifferentialPigeon2Source pigeonSource) | |
Creates a new simple differential mechanism using the given two hardware::TalonFX devices and a hardware::Pigeon2. | |
SimpleDifferentialMechanism (hardware::TalonFX &differentialAddFX, hardware::TalonFX &differentialSubFX, bool motorDirectionsAlign, hardware::CANcoder &cancoder) | |
Creates a new simple differential mechanism using the given two hardware::TalonFX devices and a hardware::CANcoder. | |
hardware::TalonFX & | GetDifferentialLeader () |
Get the Talon FX that is differential leader. | |
hardware::TalonFX const & | GetDifferentialLeader () const |
Get the Talon FX that is differential leader. | |
hardware::TalonFX & | GetDifferentialFollower () |
Get the Talon FX that is differential follower. | |
hardware::TalonFX const & | GetDifferentialFollower () const |
Get the Talon FX that is differential follower. | |
ctre::phoenix::StatusCode | ApplyConfigs (int numRetries=kDefaultConfigRetries) |
Apply the mechanism configs to the devices. | |
void | Periodic () |
Call this method periodically to keep the mechanism state updated. | |
bool | IsDisabled () const |
Get whether the mechanism is currently disabled due to an issue. | |
bool | RequiresUserAction () const |
Get whether the mechanism is currently disabled and requires user action to re-enable mechanism control. | |
MechanismState | GetMechanismState () const |
Gets the state of the mechanism. | |
void | ClearUserRequirement () |
Indicate to the mechanism that the user has performed the required action to resume mechanism control. | |
DisabledReason | GetDisabledReason () const |
RequiresUserReason | GetRequiresUserReason () const |
ctre::phoenix::StatusCode | SetNeutralOut () |
Request neutral output of mechanism. | |
ctre::phoenix::StatusCode | SetCoastOut () |
Request coast neutral output of mechanism. | |
ctre::phoenix::StatusCode | SetStaticBrake () |
Applies full neutral-brake on the mechanism by shorting motor leads together. | |
ctre::phoenix::StatusCode | SetControl (controls::DifferentialDutyCycle _diffAddFXRequest) |
Sets the control request for this mechanism. | |
ctre::phoenix::StatusCode | SetControl (controls::DifferentialVoltage _diffAddFXRequest) |
Sets the control request for this mechanism. | |
ctre::phoenix::StatusCode | SetControl (controls::DifferentialPositionDutyCycle _diffAddFXRequest) |
Sets the control request for this mechanism. | |
ctre::phoenix::StatusCode | SetControl (controls::DifferentialPositionVoltage _diffAddFXRequest) |
Sets the control request for this mechanism. | |
ctre::phoenix::StatusCode | SetControl (controls::DifferentialVelocityDutyCycle _diffAddFXRequest) |
Sets the control request for this mechanism. | |
ctre::phoenix::StatusCode | SetControl (controls::DifferentialVelocityVoltage _diffAddFXRequest) |
Sets the control request for this mechanism. | |
ctre::phoenix::StatusCode | SetControl (controls::DifferentialMotionMagicDutyCycle _diffAddFXRequest) |
Sets the control request for this mechanism. | |
ctre::phoenix::StatusCode | SetControl (controls::DifferentialMotionMagicVoltage _diffAddFXRequest) |
Sets the control request for this mechanism. | |
Static Public Attributes | |
static constexpr int | kDefaultConfigRetries = 5 |
The default number of retries for config applies. | |
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
class instead for full functionality.
|
strong |
Possible reasons for the mechanism to disable.
Possible reasons for the mechanism to require user action to resume control.
|
inline |
Creates a new simple differential mechanism using the given two hardware::TalonFX devices.
The mechanism will use the average of the two Talon FX sensors on the primary axis, and the difference between the two Talon FX sensors on the differential axis.
This mechanism provides limited differential functionality. Pro users on a CAN FD bus can use the DifferentialMechanism
class instead for full functionality.
differentialAddFX | The Talon FX that will have the differential output added to its regular output. |
differentialSubFX | The Talon FX that will have the differential output subtracted from its regular output. |
motorDirectionsAlign | Whether the differential motors' directions are aligned. |
|
inline |
Creates a new simple differential mechanism using the given two hardware::TalonFX devices and a hardware::Pigeon2.
The mechanism will use the average of the two Talon FX sensors on the primary axis, and the selected Pigeon 2 sensor source on the differential axis.
This mechanism provides limited differential functionality. Pro users on a CAN FD bus can use the DifferentialMechanism
class instead for full functionality.
differentialAddFX | The Talon FX that will have the differential output added to its regular output. |
differentialSubFX | The Talon FX that will have the differential output subtracted from its regular output. |
motorDirectionsAlign | Whether the differential motors' directions are aligned. |
pigeon2 | The Pigeon 2 to use for the differential axis. |
pigeonSource | The sensor source to use for the Pigeon 2 (Yaw, Pitch, or Roll). |
|
inline |
Creates a new simple differential mechanism using the given two hardware::TalonFX devices and a hardware::CANcoder.
The mechanism will use the average of the two Talon FX sensors on the primary axis, and the CANcoder position/velocity on the differential axis.
This mechanism provides limited differential functionality. Pro users on a CAN FD bus can use the DifferentialMechanism
class instead for full functionality.
differentialAddFX | The Talon FX that will have the differential output added to its regular output. |
differentialSubFX | The Talon FX that will have the differential output subtracted from its regular output. |
motorDirectionsAlign | Whether the differential motors' directions are aligned. |
cancoder | The CANcoder to use for the differential axis. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::SimpleDifferentialMechanism::ApplyConfigs | ( | int | numRetries = kDefaultConfigRetries | ) |
Apply the mechanism configs to the devices.
This should be called after applying all other configs to the devices.
If the user does not call this function by the time SetControl is called, SetControl will apply the configs once.
numRetries | Number of retries when applying the configs |
void ctre::phoenix6::mechanisms::SimpleDifferentialMechanism::ClearUserRequirement | ( | ) |
Indicate to the mechanism that the user has performed the required action to resume mechanism control.
|
inline |
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.
|
inline |
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.
|
inline |
Get the Talon FX that is differential leader.
The differential leader calculates the output for the differential follower. The differential leader is also used for fault detection, and it reports status signals for the differential controller.
|
inline |
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.
|
inline |
|
inline |
Gets the state of the mechanism.
|
inline |
|
inline |
Get whether the mechanism is currently disabled due to an issue.
void ctre::phoenix6::mechanisms::SimpleDifferentialMechanism::Periodic | ( | ) |
Call this method periodically to keep the mechanism state updated.
|
inline |
Get whether the mechanism is currently disabled and requires user action to re-enable mechanism control.
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::SimpleDifferentialMechanism::SetCoastOut | ( | ) |
Request coast neutral output of mechanism.
The bridge is disabled and the rotor is allowed to coast.
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::SimpleDifferentialMechanism::SetControl | ( | controls::DifferentialDutyCycle | _diffAddFXRequest | ) |
Sets the control request for this mechanism.
_diffAddFXRequest | Request a specified motor duty cycle with a differential position closed-loop. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::SimpleDifferentialMechanism::SetControl | ( | controls::DifferentialMotionMagicDutyCycle | _diffAddFXRequest | ) |
Sets the control request for this mechanism.
_diffAddFXRequest | Requests Motion MagicĀ® to target a final position using a motion profile, and PID to a differential position setpoint. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::SimpleDifferentialMechanism::SetControl | ( | controls::DifferentialMotionMagicVoltage | _diffAddFXRequest | ) |
Sets the control request for this mechanism.
_diffAddFXRequest | Requests Motion MagicĀ® to target a final position using a motion profile, and PID to a differential position setpoint. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::SimpleDifferentialMechanism::SetControl | ( | controls::DifferentialPositionDutyCycle | _diffAddFXRequest | ) |
Sets the control request for this mechanism.
_diffAddFXRequest | Request PID to target position with a differential position setpoint. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::SimpleDifferentialMechanism::SetControl | ( | controls::DifferentialPositionVoltage | _diffAddFXRequest | ) |
Sets the control request for this mechanism.
_diffAddFXRequest | Request PID to target position with a differential position setpoint |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::SimpleDifferentialMechanism::SetControl | ( | controls::DifferentialVelocityDutyCycle | _diffAddFXRequest | ) |
Sets the control request for this mechanism.
_diffAddFXRequest | Request PID to target velocity with a differential position setpoint. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::SimpleDifferentialMechanism::SetControl | ( | controls::DifferentialVelocityVoltage | _diffAddFXRequest | ) |
Sets the control request for this mechanism.
_diffAddFXRequest | Request PID to target velocity with a differential position setpoint. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::SimpleDifferentialMechanism::SetControl | ( | controls::DifferentialVoltage | _diffAddFXRequest | ) |
Sets the control request for this mechanism.
_diffAddFXRequest | Request a specified voltage with a differential position closed-loop. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::SimpleDifferentialMechanism::SetNeutralOut | ( | ) |
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 SetCoastOut()
or SetStaticBrake()
method.
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::SimpleDifferentialMechanism::SetStaticBrake | ( | ) |
Applies full neutral-brake on the mechanism by shorting motor leads together.
|
staticconstexpr |
The default number of retries for config applies.