|
CTRE Phoenix 6 C++ 26.0.0-beta-1
|
Manages control of a simple two-axis differential mechanism. More...
#include <ctre/phoenix6/mechanisms/SimpleDifferentialMechanism.hpp>
Public Types | |
| enum class | DisabledReasonValue { None , MissingRemoteSensor , MissingDifferentialFX , RemoteSensorPosOverflow , DeviceHasReset } |
| Possible reasons for the mechanism to disable. More... | |
| enum class | RequiresUserReasonValue { None , RemoteSensorPosOverflow , DeviceHasReset } |
| Possible reasons for the mechanism to require user action to resume control. More... | |
Public Member Functions | |
| SimpleDifferentialMechanism (DifferentialMotorConstants< typename MotorT::Configuration > const &constants) | |
| Creates a new simple differential mechanism using two hardware::traits::CommonTalon devices. | |
| SimpleDifferentialMechanism (DifferentialMotorConstants< typename MotorT::Configuration > const &constants, hardware::Pigeon2 &pigeon2, DifferentialPigeon2Source pigeonSource) | |
| Creates a new simple differential mechanism using two hardware::traits::CommonTalon devices and a hardware::Pigeon2. | |
| SimpleDifferentialMechanism (DifferentialMotorConstants< typename MotorT::Configuration > const &constants, hardware::CANcoder &cancoder) | |
| Creates a new simple differential mechanism using two hardware::traits::CommonTalon devices and a hardware::CANcoder. | |
| SimpleDifferentialMechanism (DifferentialMotorConstants< typename MotorT::Configuration > const &constants, hardware::CANdi &candi, DifferentialCANdiSource candiSource) | |
| Creates a new simple differential mechanism using two hardware::traits::CommonTalon devices and a hardware::CANdi. | |
| ctre::phoenix::StatusCode | ConfigNeutralMode (signals::NeutralModeValue neutralMode, units::second_t timeoutSeconds=100_ms) |
| Configures the neutral mode to use for both motors in the mechanism. | |
| void | Periodic () |
| Call this method periodically to automatically protect against dangerous fault conditions and keep GetMechanismState() 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. | |
| DisabledReasonValue | GetDisabledReason () const |
| RequiresUserReasonValue | GetRequiresUserReason () const |
| StatusSignal< units::turn_t > & | GetAveragePosition (bool refresh=true) |
| Average component of the mechanism position. | |
| StatusSignal< units::turns_per_second_t > & | GetAverageVelocity (bool refresh=true) |
| Average component of the mechanism velocity. | |
| StatusSignal< units::turn_t > & | GetDifferentialPosition (bool refresh=true) |
| Differential component of the mechanism position. | |
| StatusSignal< units::turns_per_second_t > & | GetDifferentialVelocity (bool refresh=true) |
| Differential component of the mechanism velocity. | |
| StatusSignal< double > & | GetAverageClosedLoopReference (bool refresh=true) |
| Value that the average closed loop is targeting. | |
| StatusSignal< double > & | GetAverageClosedLoopReferenceSlope (bool refresh=true) |
| Derivative of the target that the average closed loop is targeting. | |
| StatusSignal< double > & | GetAverageClosedLoopError (bool refresh=true) |
| The difference between target average reference and current measurement. | |
| StatusSignal< double > & | GetDifferentialClosedLoopReference (bool refresh=true) |
| Value that the differential closed loop is targeting. | |
| StatusSignal< double > & | GetDifferentialClosedLoopReferenceSlope (bool refresh=true) |
| Derivative of the target that the differential closed loop is targeting. | |
| StatusSignal< double > & | GetDifferentialClosedLoopError (bool refresh=true) |
| The difference between target differential reference and current measurement. | |
| ctre::phoenix::StatusCode | SetPosition (units::turn_t avgPosition, units::turn_t diffPosition=0_tr, units::time::second_t timeoutSeconds=0.100_s) |
| Sets the position of the mechanism in rotations. | |
| MotorT & | GetLeader () |
| Get the Talon FX that is differential leader. | |
| MotorT const & | GetLeader () const |
| Get the Talon FX that is differential leader. | |
| MotorT & | GetFollower () |
| Get the Talon FX that is differential follower. | |
| MotorT const & | GetFollower () const |
| Get the Talon FX that is differential follower. | |
| 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 const &diffLeaderFXRequest) |
| Sets the control request for this mechanism. | |
| ctre::phoenix::StatusCode | SetControl (controls::DifferentialVoltage const &diffLeaderFXRequest) |
| Sets the control request for this mechanism. | |
| ctre::phoenix::StatusCode | SetControl (controls::DifferentialPositionDutyCycle const &diffLeaderFXRequest) |
| Sets the control request for this mechanism. | |
| ctre::phoenix::StatusCode | SetControl (controls::DifferentialPositionVoltage const &diffLeaderFXRequest) |
| Sets the control request for this mechanism. | |
| ctre::phoenix::StatusCode | SetControl (controls::DifferentialVelocityDutyCycle const &diffLeaderFXRequest) |
| Sets the control request for this mechanism. | |
| ctre::phoenix::StatusCode | SetControl (controls::DifferentialVelocityVoltage const &diffLeaderFXRequest) |
| Sets the control request for this mechanism. | |
| ctre::phoenix::StatusCode | SetControl (controls::DifferentialMotionMagicDutyCycle const &diffLeaderFXRequest) |
| Sets the control request for this mechanism. | |
| ctre::phoenix::StatusCode | SetControl (controls::DifferentialMotionMagicVoltage const &diffLeaderFXRequest) |
| Sets the control request for this mechanism. | |
| ctre::phoenix::StatusCode | SetControl (controls::DifferentialMotionMagicExpoDutyCycle const &diffLeaderFXRequest) |
| Sets the control request for this mechanism. | |
| ctre::phoenix::StatusCode | SetControl (controls::DifferentialMotionMagicExpoVoltage const &diffLeaderFXRequest) |
| Sets the control request for this mechanism. | |
| ctre::phoenix::StatusCode | SetControl (controls::DifferentialMotionMagicVelocityDutyCycle const &diffLeaderFXRequest) |
| Sets the control request for this mechanism. | |
| ctre::phoenix::StatusCode | SetControl (controls::DifferentialMotionMagicVelocityVoltage const &diffLeaderFXRequest) |
| Sets the control request for this mechanism. | |
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:
|
strong |
Possible reasons for the mechanism to disable.
|
strong |
Possible reasons for the mechanism to require user action to resume control.
| ctre::phoenix6::mechanisms::SimpleDifferentialMechanism< MotorT >::SimpleDifferentialMechanism | ( | DifferentialMotorConstants< typename MotorT::Configuration > const & | constants | ) |
Creates a new simple differential mechanism using two hardware::traits::CommonTalon devices.
The mechanism will use the average of the two Talon FX sensors on the primary axis, and half of 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.
| constants | Constants used to construct the mechanism |
| ctre::phoenix6::mechanisms::SimpleDifferentialMechanism< MotorT >::SimpleDifferentialMechanism | ( | DifferentialMotorConstants< typename MotorT::Configuration > const & | constants, |
| hardware::Pigeon2 & | pigeon2, | ||
| DifferentialPigeon2Source | pigeonSource ) |
Creates a new simple differential mechanism using two hardware::traits::CommonTalon 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.
| constants | Constants used to construct the mechanism |
| pigeon2 | The Pigeon 2 to use for the differential axis |
| pigeonSource | The sensor source to use for the Pigeon 2 (Yaw, Pitch, or Roll) |
| ctre::phoenix6::mechanisms::SimpleDifferentialMechanism< MotorT >::SimpleDifferentialMechanism | ( | DifferentialMotorConstants< typename MotorT::Configuration > const & | constants, |
| hardware::CANcoder & | cancoder ) |
Creates a new simple differential mechanism using two hardware::traits::CommonTalon 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.
| constants | Constants used to construct the mechanism |
| cancoder | The CANcoder to use for the differential axis |
| ctre::phoenix6::mechanisms::SimpleDifferentialMechanism< MotorT >::SimpleDifferentialMechanism | ( | DifferentialMotorConstants< typename MotorT::Configuration > const & | constants, |
| hardware::CANdi & | candi, | ||
| DifferentialCANdiSource | candiSource ) |
Creates a new simple differential mechanism using two hardware::traits::CommonTalon devices and a hardware::CANdi.
The mechanism will use the average of the two Talon FX sensors on the primary axis, and the selected CTR Electronics' CANdi™ branded 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.
| constants | Constants used to construct the mechanism |
| candi | The CTR Electronics' CANdi™ branded device to use for the differential axis |
| candiSource | The sensor source to use for the CTR Electronics' CANdi™ branded device |
| void ctre::phoenix6::mechanisms::SimpleDifferentialMechanism< MotorT >::ClearUserRequirement | ( | ) |
Indicate to the mechanism that the user has performed the required action to resume mechanism control.
| ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::SimpleDifferentialMechanism< MotorT >::ConfigNeutralMode | ( | signals::NeutralModeValue | neutralMode, |
| units::second_t | timeoutSeconds = 100_ms ) |
Configures the neutral mode to use for both motors in the mechanism.
| neutralMode | The state of the motor controller bridge when output is neutral or disabled |
| timeoutSeconds | Maximum amount of time to wait when performing each configuration |
|
inline |
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.
| refresh | Whether to refresh the StatusSignal before returning it; defaults to true |
|
inline |
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.
| refresh | Whether to refresh the StatusSignal before returning it; defaults to true |
|
inline |
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.
| refresh | Whether to refresh the StatusSignal before returning it; defaults to true |
|
inline |
Average component of the mechanism position.
This refreshes and returns a cached StatusSignal object.
| refresh | Whether to refresh the StatusSignal before returning it; defaults to true |
|
inline |
Average component of the mechanism velocity.
This refreshes and returns a cached StatusSignal object.
| refresh | Whether to refresh the StatusSignal before returning it; defaults to true |
|
inline |
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.
| refresh | Whether to refresh the StatusSignal before returning it; defaults to true |
|
inline |
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.
| refresh | Whether to refresh the StatusSignal before returning it; defaults to true |
|
inline |
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.
| refresh | Whether to refresh the StatusSignal before returning it; defaults to true |
|
inline |
Differential component of the mechanism position.
This refreshes and returns a cached StatusSignal object.
| refresh | Whether to refresh the StatusSignal before returning it; defaults to true |
|
inline |
Differential component of the mechanism velocity.
This refreshes and returns a cached StatusSignal object.
| refresh | Whether to refresh the StatusSignal before returning it; defaults to true |
|
inline |
|
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 |
Gets the state of the mechanism.
|
inline |
|
inline |
Get whether the mechanism is currently disabled due to an issue.
| void ctre::phoenix6::mechanisms::SimpleDifferentialMechanism< MotorT >::Periodic | ( | ) |
Call this method periodically to automatically protect against dangerous fault conditions and keep GetMechanismState() 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< MotorT >::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< MotorT >::SetControl | ( | controls::DifferentialDutyCycle const & | diffLeaderFXRequest | ) |
Sets the control request for this mechanism.
| diffLeaderFXRequest | Request a specified motor duty cycle with a differential position closed-loop. |
| ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::SimpleDifferentialMechanism< MotorT >::SetControl | ( | controls::DifferentialMotionMagicDutyCycle const & | diffLeaderFXRequest | ) |
Sets the control request for this mechanism.
| diffLeaderFXRequest | 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< MotorT >::SetControl | ( | controls::DifferentialMotionMagicExpoDutyCycle const & | diffLeaderFXRequest | ) |
Sets the control request for this mechanism.
| diffLeaderFXRequest | Requests Motion Magic® to target a final position using an exponential motion profile, and PID to a differential position setpoint. |
| ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::SimpleDifferentialMechanism< MotorT >::SetControl | ( | controls::DifferentialMotionMagicExpoVoltage const & | diffLeaderFXRequest | ) |
Sets the control request for this mechanism.
| diffLeaderFXRequest | Requests Motion Magic® to target a final position using an exponential motion profile, and PID to a differential position setpoint. |
| ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::SimpleDifferentialMechanism< MotorT >::SetControl | ( | controls::DifferentialMotionMagicVelocityDutyCycle const & | diffLeaderFXRequest | ) |
Sets the control request for this mechanism.
| diffLeaderFXRequest | Requests Motion Magic® to target a final velocity using a motion profile, and PID to a differential position setpoint. This allows smooth transitions between velocity set points. |
| ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::SimpleDifferentialMechanism< MotorT >::SetControl | ( | controls::DifferentialMotionMagicVelocityVoltage const & | diffLeaderFXRequest | ) |
Sets the control request for this mechanism.
| diffLeaderFXRequest | Requests Motion Magic® to target a final velocity using a motion profile, and PID to a differential position setpoint. This allows smooth transitions between velocity set points. |
| ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::SimpleDifferentialMechanism< MotorT >::SetControl | ( | controls::DifferentialMotionMagicVoltage const & | diffLeaderFXRequest | ) |
Sets the control request for this mechanism.
| diffLeaderFXRequest | 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< MotorT >::SetControl | ( | controls::DifferentialPositionDutyCycle const & | diffLeaderFXRequest | ) |
Sets the control request for this mechanism.
| diffLeaderFXRequest | Request PID to target position with a differential position setpoint. |
| ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::SimpleDifferentialMechanism< MotorT >::SetControl | ( | controls::DifferentialPositionVoltage const & | diffLeaderFXRequest | ) |
Sets the control request for this mechanism.
| diffLeaderFXRequest | Request PID to target position with a differential position setpoint |
| ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::SimpleDifferentialMechanism< MotorT >::SetControl | ( | controls::DifferentialVelocityDutyCycle const & | diffLeaderFXRequest | ) |
Sets the control request for this mechanism.
| diffLeaderFXRequest | Request PID to target velocity with a differential position setpoint. |
| ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::SimpleDifferentialMechanism< MotorT >::SetControl | ( | controls::DifferentialVelocityVoltage const & | diffLeaderFXRequest | ) |
Sets the control request for this mechanism.
| diffLeaderFXRequest | Request PID to target velocity with a differential position setpoint. |
| ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::SimpleDifferentialMechanism< MotorT >::SetControl | ( | controls::DifferentialVoltage const & | diffLeaderFXRequest | ) |
Sets the control request for this mechanism.
| diffLeaderFXRequest | Request a specified voltage with a differential position closed-loop. |
| ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::SimpleDifferentialMechanism< MotorT >::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.
|
inline |
Sets the position of the mechanism in rotations.
| avgPosition | The average position of the mechanism, in rotations |
| diffPosition | The differential position of the mechanism, in rotations |
| timeoutSeconds | Maximum time to wait up to in seconds |
| ctre::phoenix::StatusCode ctre::phoenix6::mechanisms::SimpleDifferentialMechanism< MotorT >::SetStaticBrake | ( | ) |
Applies full neutral-brake on the mechanism by shorting motor leads together.