CTRE Phoenix 6 C++ 25.0.0-beta-4
|
Manages control of a two-axis differential mechanism. More...
#include <ctre/phoenix6/mechanisms/DifferentialMechanism.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 | |
DifferentialMechanism (hardware::TalonFX &differentialAddFX, hardware::TalonFX &differentialSubFX, bool motorDirectionsAlign) | |
Creates a new differential mechanism using the given two hardware::TalonFX devices. | |
DifferentialMechanism (hardware::TalonFX &differentialAddFX, hardware::TalonFX &differentialSubFX, bool motorDirectionsAlign, hardware::Pigeon2 &pigeon2, DifferentialPigeon2Source pigeonSource) | |
Creates a new differential mechanism using the given two hardware::TalonFX devices and a hardware::Pigeon2. | |
DifferentialMechanism (hardware::TalonFX &differentialAddFX, hardware::TalonFX &differentialSubFX, bool motorDirectionsAlign, hardware::CANcoder &cancoder) | |
Creates a new 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::DutyCycleOut AverageRequest, controls::PositionDutyCycle DifferentialRequest) |
Sets the control request for this mechanism. | |
ctre::phoenix::StatusCode | SetControl (controls::PositionDutyCycle AverageRequest, controls::PositionDutyCycle DifferentialRequest) |
Sets the control request for this mechanism. | |
ctre::phoenix::StatusCode | SetControl (controls::VelocityDutyCycle AverageRequest, controls::PositionDutyCycle DifferentialRequest) |
Sets the control request for this mechanism. | |
ctre::phoenix::StatusCode | SetControl (controls::MotionMagicDutyCycle AverageRequest, controls::PositionDutyCycle DifferentialRequest) |
Sets the control request for this mechanism. | |
ctre::phoenix::StatusCode | SetControl (controls::DutyCycleOut AverageRequest, controls::VelocityDutyCycle DifferentialRequest) |
Sets the control request for this mechanism. | |
ctre::phoenix::StatusCode | SetControl (controls::PositionDutyCycle AverageRequest, controls::VelocityDutyCycle DifferentialRequest) |
Sets the control request for this mechanism. | |
ctre::phoenix::StatusCode | SetControl (controls::VelocityDutyCycle AverageRequest, controls::VelocityDutyCycle DifferentialRequest) |
Sets the control request for this mechanism. | |
ctre::phoenix::StatusCode | SetControl (controls::MotionMagicDutyCycle AverageRequest, controls::VelocityDutyCycle DifferentialRequest) |
Sets the control request for this mechanism. | |
ctre::phoenix::StatusCode | SetControl (controls::VoltageOut AverageRequest, controls::PositionVoltage DifferentialRequest) |
Sets the control request for this mechanism. | |
ctre::phoenix::StatusCode | SetControl (controls::PositionVoltage AverageRequest, controls::PositionVoltage DifferentialRequest) |
Sets the control request for this mechanism. | |
ctre::phoenix::StatusCode | SetControl (controls::VelocityVoltage AverageRequest, controls::PositionVoltage DifferentialRequest) |
Sets the control request for this mechanism. | |
ctre::phoenix::StatusCode | SetControl (controls::MotionMagicVoltage AverageRequest, controls::PositionVoltage DifferentialRequest) |
Sets the control request for this mechanism. | |
ctre::phoenix::StatusCode | SetControl (controls::VoltageOut AverageRequest, controls::VelocityVoltage DifferentialRequest) |
Sets the control request for this mechanism. | |
ctre::phoenix::StatusCode | SetControl (controls::PositionVoltage AverageRequest, controls::VelocityVoltage DifferentialRequest) |
Sets the control request for this mechanism. | |
ctre::phoenix::StatusCode | SetControl (controls::VelocityVoltage AverageRequest, controls::VelocityVoltage DifferentialRequest) |
Sets the control request for this mechanism. | |
ctre::phoenix::StatusCode | SetControl (controls::MotionMagicVoltage AverageRequest, controls::VelocityVoltage DifferentialRequest) |
Sets the control request for this mechanism. | |
ctre::phoenix::StatusCode | SetControl (controls::TorqueCurrentFOC AverageRequest, controls::PositionTorqueCurrentFOC DifferentialRequest) |
Sets the control request for this mechanism. | |
ctre::phoenix::StatusCode | SetControl (controls::PositionTorqueCurrentFOC AverageRequest, controls::PositionTorqueCurrentFOC DifferentialRequest) |
Sets the control request for this mechanism. | |
ctre::phoenix::StatusCode | SetControl (controls::VelocityTorqueCurrentFOC AverageRequest, controls::PositionTorqueCurrentFOC DifferentialRequest) |
Sets the control request for this mechanism. | |
ctre::phoenix::StatusCode | SetControl (controls::MotionMagicTorqueCurrentFOC AverageRequest, controls::PositionTorqueCurrentFOC DifferentialRequest) |
Sets the control request for this mechanism. | |
ctre::phoenix::StatusCode | SetControl (controls::TorqueCurrentFOC AverageRequest, controls::VelocityTorqueCurrentFOC DifferentialRequest) |
Sets the control request for this mechanism. | |
ctre::phoenix::StatusCode | SetControl (controls::PositionTorqueCurrentFOC AverageRequest, controls::VelocityTorqueCurrentFOC DifferentialRequest) |
Sets the control request for this mechanism. | |
ctre::phoenix::StatusCode | SetControl (controls::VelocityTorqueCurrentFOC AverageRequest, controls::VelocityTorqueCurrentFOC DifferentialRequest) |
Sets the control request for this mechanism. | |
ctre::phoenix::StatusCode | SetControl (controls::MotionMagicTorqueCurrentFOC AverageRequest, controls::VelocityTorqueCurrentFOC DifferentialRequest) |
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 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.
|
strong |
Possible reasons for the mechanism to disable.
|
strong |
Possible reasons for the mechanism to require user action to resume control.
|
inline |
Creates a new 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 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.
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 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 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.
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 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 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.
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::DifferentialMechanism::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::DifferentialMechanism::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::DifferentialMechanism::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::DifferentialMechanism::SetCoastOut | ( | ) |
Request coast neutral output of mechanism.
The bridge is disabled and the rotor is allowed to coast.
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::DifferentialMechanism::SetControl | ( | controls::DutyCycleOut | AverageRequest, |
controls::PositionDutyCycle | DifferentialRequest ) |
Sets the control request for this mechanism.
AverageRequest | Average DutyCycleOut request of the mechanism. |
DifferentialRequest | Differential PositionDutyCycle request of the mechanism. Note: The UpdateFreqHz parameter for this control request will be ignored by the control frame. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::DifferentialMechanism::SetControl | ( | controls::DutyCycleOut | AverageRequest, |
controls::VelocityDutyCycle | DifferentialRequest ) |
Sets the control request for this mechanism.
AverageRequest | Average DutyCycleOut request of the mechanism. |
DifferentialRequest | Differential VelocityDutyCycle request of the mechanism. Note: The UpdateFreqHz parameter for this control request will be ignored by the control frame. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::DifferentialMechanism::SetControl | ( | controls::MotionMagicDutyCycle | AverageRequest, |
controls::PositionDutyCycle | DifferentialRequest ) |
Sets the control request for this mechanism.
AverageRequest | Average MotionMagicDutyCycle request of the mechanism. |
DifferentialRequest | Differential PositionDutyCycle request of the mechanism. Note: The UpdateFreqHz parameter for this control request will be ignored by the control frame. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::DifferentialMechanism::SetControl | ( | controls::MotionMagicDutyCycle | AverageRequest, |
controls::VelocityDutyCycle | DifferentialRequest ) |
Sets the control request for this mechanism.
AverageRequest | Average MotionMagicDutyCycle request of the mechanism. |
DifferentialRequest | Differential VelocityDutyCycle request of the mechanism. Note: The UpdateFreqHz parameter for this control request will be ignored by the control frame. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::DifferentialMechanism::SetControl | ( | controls::MotionMagicTorqueCurrentFOC | AverageRequest, |
controls::PositionTorqueCurrentFOC | DifferentialRequest ) |
Sets the control request for this mechanism.
AverageRequest | Average MotionMagicTorqueCurrentFOC request of the mechanism. |
DifferentialRequest | Differential PositionTorqueCurrentFOC request of the mechanism. Note: The UpdateFreqHz parameter for this control request will be ignored by the control frame. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::DifferentialMechanism::SetControl | ( | controls::MotionMagicTorqueCurrentFOC | AverageRequest, |
controls::VelocityTorqueCurrentFOC | DifferentialRequest ) |
Sets the control request for this mechanism.
AverageRequest | Average MotionMagicTorqueCurrentFOC request of the mechanism. |
DifferentialRequest | Differential VelocityTorqueCurrentFOC request of the mechanism. Note: The UpdateFreqHz parameter for this control request will be ignored by the control frame. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::DifferentialMechanism::SetControl | ( | controls::MotionMagicVoltage | AverageRequest, |
controls::PositionVoltage | DifferentialRequest ) |
Sets the control request for this mechanism.
AverageRequest | Average MotionMagicVoltage request of the mechanism. |
DifferentialRequest | Differential PositionVoltage request of the mechanism. Note: The UpdateFreqHz parameter for this control request will be ignored by the control frame. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::DifferentialMechanism::SetControl | ( | controls::MotionMagicVoltage | AverageRequest, |
controls::VelocityVoltage | DifferentialRequest ) |
Sets the control request for this mechanism.
AverageRequest | Average MotionMagicVoltage request of the mechanism. |
DifferentialRequest | Differential VelocityVoltage request of the mechanism. Note: The UpdateFreqHz parameter for this control request will be ignored by the control frame. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::DifferentialMechanism::SetControl | ( | controls::PositionDutyCycle | AverageRequest, |
controls::PositionDutyCycle | DifferentialRequest ) |
Sets the control request for this mechanism.
AverageRequest | Average PositionDutyCycle request of the mechanism. |
DifferentialRequest | Differential PositionDutyCycle request of the mechanism. Note: The UpdateFreqHz parameter for this control request will be ignored by the control frame. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::DifferentialMechanism::SetControl | ( | controls::PositionDutyCycle | AverageRequest, |
controls::VelocityDutyCycle | DifferentialRequest ) |
Sets the control request for this mechanism.
AverageRequest | Average PositionDutyCycle request of the mechanism. |
DifferentialRequest | Differential VelocityDutyCycle request of the mechanism. Note: The UpdateFreqHz parameter for this control request will be ignored by the control frame. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::DifferentialMechanism::SetControl | ( | controls::PositionTorqueCurrentFOC | AverageRequest, |
controls::PositionTorqueCurrentFOC | DifferentialRequest ) |
Sets the control request for this mechanism.
AverageRequest | Average PositionTorqueCurrentFOC request of the mechanism. |
DifferentialRequest | Differential PositionTorqueCurrentFOC request of the mechanism. Note: The UpdateFreqHz parameter for this control request will be ignored by the control frame. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::DifferentialMechanism::SetControl | ( | controls::PositionTorqueCurrentFOC | AverageRequest, |
controls::VelocityTorqueCurrentFOC | DifferentialRequest ) |
Sets the control request for this mechanism.
AverageRequest | Average PositionTorqueCurrentFOC request of the mechanism. |
DifferentialRequest | Differential VelocityTorqueCurrentFOC request of the mechanism. Note: The UpdateFreqHz parameter for this control request will be ignored by the control frame. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::DifferentialMechanism::SetControl | ( | controls::PositionVoltage | AverageRequest, |
controls::PositionVoltage | DifferentialRequest ) |
Sets the control request for this mechanism.
AverageRequest | Average PositionVoltage request of the mechanism. |
DifferentialRequest | Differential PositionVoltage request of the mechanism. Note: The UpdateFreqHz parameter for this control request will be ignored by the control frame. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::DifferentialMechanism::SetControl | ( | controls::PositionVoltage | AverageRequest, |
controls::VelocityVoltage | DifferentialRequest ) |
Sets the control request for this mechanism.
AverageRequest | Average PositionVoltage request of the mechanism. |
DifferentialRequest | Differential VelocityVoltage request of the mechanism. Note: The UpdateFreqHz parameter for this control request will be ignored by the control frame. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::DifferentialMechanism::SetControl | ( | controls::TorqueCurrentFOC | AverageRequest, |
controls::PositionTorqueCurrentFOC | DifferentialRequest ) |
Sets the control request for this mechanism.
AverageRequest | Average TorqueCurrentFOC request of the mechanism. |
DifferentialRequest | Differential PositionTorqueCurrentFOC request of the mechanism. Note: The UpdateFreqHz parameter for this control request will be ignored by the control frame. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::DifferentialMechanism::SetControl | ( | controls::TorqueCurrentFOC | AverageRequest, |
controls::VelocityTorqueCurrentFOC | DifferentialRequest ) |
Sets the control request for this mechanism.
AverageRequest | Average TorqueCurrentFOC request of the mechanism. |
DifferentialRequest | Differential VelocityTorqueCurrentFOC request of the mechanism. Note: The UpdateFreqHz parameter for this control request will be ignored by the control frame. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::DifferentialMechanism::SetControl | ( | controls::VelocityDutyCycle | AverageRequest, |
controls::PositionDutyCycle | DifferentialRequest ) |
Sets the control request for this mechanism.
AverageRequest | Average VelocityDutyCYcle request of the mechanism. |
DifferentialRequest | Differential PositionDutyCycle request of the mechanism. Note: The UpdateFreqHz parameter for this control request will be ignored by the control frame. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::DifferentialMechanism::SetControl | ( | controls::VelocityDutyCycle | AverageRequest, |
controls::VelocityDutyCycle | DifferentialRequest ) |
Sets the control request for this mechanism.
AverageRequest | Average VelocityDutyCycle request of the mechanism. |
DifferentialRequest | Differential VelocityDutyCycle request of the mechanism. Note: The UpdateFreqHz parameter for this control request will be ignored by the control frame. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::DifferentialMechanism::SetControl | ( | controls::VelocityTorqueCurrentFOC | AverageRequest, |
controls::PositionTorqueCurrentFOC | DifferentialRequest ) |
Sets the control request for this mechanism.
AverageRequest | Average VelocityTorqueCurrentFOC request of the mechanism. |
DifferentialRequest | Differential PositionTorqueCurrentFOC request of the mechanism. Note: The UpdateFreqHz parameter for this control request will be ignored by the control frame. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::DifferentialMechanism::SetControl | ( | controls::VelocityTorqueCurrentFOC | AverageRequest, |
controls::VelocityTorqueCurrentFOC | DifferentialRequest ) |
Sets the control request for this mechanism.
AverageRequest | Average VelocityTorqueCurrentFOC request of the mechanism. |
DifferentialRequest | Differential VelocityTorqueCurrentFOC request of the mechanism. Note: The UpdateFreqHz parameter for this control request will be ignored by the control frame. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::DifferentialMechanism::SetControl | ( | controls::VelocityVoltage | AverageRequest, |
controls::PositionVoltage | DifferentialRequest ) |
Sets the control request for this mechanism.
AverageRequest | Average VelocityVoltage request of the mechanism. |
DifferentialRequest | Differential PositionVoltage request of the mechanism. Note: The UpdateFreqHz parameter for this control request will be ignored by the control frame. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::DifferentialMechanism::SetControl | ( | controls::VelocityVoltage | AverageRequest, |
controls::VelocityVoltage | DifferentialRequest ) |
Sets the control request for this mechanism.
AverageRequest | Average VelocityVoltage request of the mechanism. |
DifferentialRequest | Differential VelocityVoltage request of the mechanism. Note: The UpdateFreqHz parameter for this control request will be ignored by the control frame. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::DifferentialMechanism::SetControl | ( | controls::VoltageOut | AverageRequest, |
controls::PositionVoltage | DifferentialRequest ) |
Sets the control request for this mechanism.
AverageRequest | Average VoltageOut request of the mechanism. |
DifferentialRequest | Differential PositionVoltage request of the mechanism. Note: The UpdateFreqHz parameter for this control request will be ignored by the control frame. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::DifferentialMechanism::SetControl | ( | controls::VoltageOut | AverageRequest, |
controls::VelocityVoltage | DifferentialRequest ) |
Sets the control request for this mechanism.
AverageRequest | Average VoltageOut request of the mechanism. |
DifferentialRequest | Differential VelocityVoltage request of the mechanism. Note: The UpdateFreqHz parameter for this control request will be ignored by the control frame. |
ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::DifferentialMechanism::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::DifferentialMechanism::SetStaticBrake | ( | ) |
Applies full neutral-brake on the mechanism by shorting motor leads together.
|
staticconstexpr |
The default number of retries for config applies.