55 MissingDifferentialFX,
63 RemoteSensorPosOverflow,
86 RemoteSensorPosOverflow,
96 std::optional<hardware::Pigeon2 *> _pigeon2;
98 std::optional<hardware::CANcoder *> _cancoder;
104 controls::StaticBrake _brake{};
106 std::function<bool()> _diffAddFXResetChecker;
107 std::function<bool()> _diffSubFXResetChecker;
108 std::optional<std::function<bool()>> _pigeon2ResetChecker;
109 std::optional<std::function<bool()>> _cancoderResetChecker;
111 bool _hasAppliedConfigs{
false};
112 ctre::phoenix::StatusCode BeforeControl();
114 std::atomic<bool> _mechanismDisabled{
false};
115 std::atomic<bool> _requiresUserAction{
false};
140 _diffAddFX{&differentialAddFX},
141 _diffSubFX{&differentialSubFX},
142 _pigeon2{std::nullopt},
144 _cancoder{std::nullopt},
145 _diffFollow{_diffAddFX->GetDeviceID(), !motorDirectionsAlign},
146 _diffAddFXResetChecker{_diffAddFX->GetResetOccurredChecker()},
147 _diffSubFXResetChecker{_diffSubFX->GetResetOccurredChecker()},
148 _pigeon2ResetChecker{std::nullopt},
149 _cancoderResetChecker{std::nullopt}
168 _diffAddFX{&differentialAddFX},
169 _diffSubFX{&differentialSubFX},
171 _pigeonSource{pigeonSource},
172 _cancoder{std::nullopt},
173 _diffFollow{_diffAddFX->GetDeviceID(), !motorDirectionsAlign},
174 _diffAddFXResetChecker{_diffAddFX->GetResetOccurredChecker()},
175 _diffSubFXResetChecker{_diffSubFX->GetResetOccurredChecker()},
176 _pigeon2ResetChecker{(*_pigeon2)->GetResetOccurredChecker()},
177 _cancoderResetChecker{std::nullopt}
195 _diffAddFX{&differentialAddFX},
196 _diffSubFX{&differentialSubFX},
197 _pigeon2{std::nullopt},
199 _cancoder{&cancoder},
200 _diffFollow{_diffAddFX->GetDeviceID(), !motorDirectionsAlign},
201 _diffAddFXResetChecker{_diffAddFX->GetResetOccurredChecker()},
202 _diffSubFXResetChecker{_diffSubFX->GetResetOccurredChecker()},
203 _pigeon2ResetChecker{std::nullopt},
204 _cancoderResetChecker{(*_cancoder)->GetResetOccurredChecker()}
279 return _mechanismDisabled.load(std::memory_order_acquire);
291 return _requiresUserAction.load(std::memory_order_acquire);
321 return _disabledReason;
329 return _requiresUserReason;
361 std::unique_ptr<controls::ControlRequest> _diffAddFX_req{};
Request coast neutral output of actuator.
Definition: CoastOut.hpp:27
Follow the differential motor output of another Talon.
Definition: DifferentialFollower.hpp:30
Request a specified motor duty cycle.
Definition: DutyCycleOut.hpp:28
Requests Motion Magic® to target a final position using a motion profile.
Definition: MotionMagicDutyCycle.hpp:34
Requires Phoenix Pro; Requests Motion Magic® to target a final position using a motion profile.
Definition: MotionMagicTorqueCurrentFOC.hpp:35
Requests Motion Magic® to target a final position using a motion profile.
Definition: MotionMagicVoltage.hpp:34
Request neutral output of actuator.
Definition: NeutralOut.hpp:27
Request PID to target position with duty cycle feedforward.
Definition: PositionDutyCycle.hpp:31
Requires Phoenix Pro; Request PID to target position with torque current feedforward.
Definition: PositionTorqueCurrentFOC.hpp:32
Request PID to target position with voltage feedforward.
Definition: PositionVoltage.hpp:31
Requires Phoenix Pro; Request a specified motor current (field oriented control).
Definition: TorqueCurrentFOC.hpp:32
Request PID to target velocity with duty cycle feedforward.
Definition: VelocityDutyCycle.hpp:31
Requires Phoenix Pro; Request PID to target velocity with torque current feedforward.
Definition: VelocityTorqueCurrentFOC.hpp:32
Request PID to target velocity with voltage feedforward.
Definition: VelocityVoltage.hpp:31
Request a specified voltage.
Definition: VoltageOut.hpp:29
Class for CANcoder, a CAN based magnetic encoder that provides absolute and relative position along w...
Definition: CANcoder.hpp:27
Class description for the Pigeon 2 IMU sensor that measures orientation.
Definition: Pigeon2.hpp:29
Class description for the Talon FX integrated motor controller.
Definition: TalonFX.hpp:32
Manages control of a two-axis differential mechanism.
Definition: DifferentialMechanism.hpp:28
ctre::phoenix::StatusCode SetControl(controls::PositionVoltage AverageRequest, controls::VelocityVoltage DifferentialRequest)
Sets the control request for this mechanism.
RequiresUserReason
Possible reasons for the mechanism to require user action to resume control.
Definition: DifferentialMechanism.hpp:74
ctre::phoenix::StatusCode SetControl(controls::TorqueCurrentFOC AverageRequest, controls::VelocityTorqueCurrentFOC DifferentialRequest)
Sets the control request for this mechanism.
hardware::TalonFX & GetDifferentialFollower()
Get the Talon FX that is differential follower.
Definition: DifferentialMechanism.hpp:239
ctre::phoenix::StatusCode SetControl(controls::VelocityTorqueCurrentFOC AverageRequest, controls::VelocityTorqueCurrentFOC 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.
bool IsDisabled() const
Get whether the mechanism is currently disabled due to an issue.
Definition: DifferentialMechanism.hpp:277
ctre::phoenix::StatusCode SetControl(controls::MotionMagicTorqueCurrentFOC AverageRequest, controls::VelocityTorqueCurrentFOC DifferentialRequest)
Sets the control request for this mechanism.
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::CA...
Definition: DifferentialMechanism.hpp:194
ctre::phoenix::StatusCode SetControl(controls::DutyCycleOut AverageRequest, controls::VelocityDutyCycle 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::DutyCycleOut AverageRequest, controls::PositionDutyCycle DifferentialRequest)
Sets the control request for this mechanism.
ctre::phoenix::StatusCode SetCoastOut()
Request coast neutral output of mechanism.
ctre::phoenix::StatusCode SetControl(controls::VelocityDutyCycle AverageRequest, controls::VelocityDutyCycle DifferentialRequest)
Sets the control request for this mechanism.
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::Pi...
Definition: DifferentialMechanism.hpp:167
RequiresUserReason GetRequiresUserReason() const
Definition: DifferentialMechanism.hpp:327
DisabledReason
Possible reasons for the mechanism to disable.
Definition: DifferentialMechanism.hpp:42
ctre::phoenix::StatusCode SetControl(controls::VelocityVoltage AverageRequest, controls::PositionVoltage DifferentialRequest)
Sets the control request for this mechanism.
DisabledReason GetDisabledReason() const
Definition: DifferentialMechanism.hpp:319
ctre::phoenix::StatusCode SetControl(controls::PositionVoltage AverageRequest, controls::PositionVoltage 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.
DifferentialPigeon2Source
Sensor sources for a differential Pigeon 2.
Definition: DifferentialMechanism.hpp:33
ctre::phoenix::StatusCode SetControl(controls::VoltageOut AverageRequest, controls::VelocityVoltage DifferentialRequest)
Sets the control request for this mechanism.
ctre::phoenix::StatusCode SetStaticBrake()
Applies full neutral-brake on the mechanism by shorting motor leads together.
ctre::phoenix::StatusCode SetControl(controls::MotionMagicDutyCycle AverageRequest, controls::VelocityDutyCycle DifferentialRequest)
Sets the control request for this mechanism.
ctre::phoenix::StatusCode SetNeutralOut()
Request neutral output of mechanism.
ctre::phoenix::StatusCode SetControl(controls::VelocityDutyCycle 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::MotionMagicVoltage AverageRequest, controls::PositionVoltage DifferentialRequest)
Sets the control request for this mechanism.
void Periodic()
Call this method periodically to keep the mechanism state updated.
void ClearUserRequirement()
Indicate to the mechanism that the user has performed the required action to resume mechanism control...
ctre::phoenix::StatusCode SetControl(controls::VelocityVoltage AverageRequest, controls::VelocityVoltage DifferentialRequest)
Sets the control request for this mechanism.
hardware::TalonFX const & GetDifferentialFollower() const
Get the Talon FX that is differential follower.
Definition: DifferentialMechanism.hpp:250
ctre::phoenix::StatusCode SetControl(controls::PositionTorqueCurrentFOC AverageRequest, controls::PositionTorqueCurrentFOC DifferentialRequest)
Sets the control request for this mechanism.
MechanismState GetMechanismState() const
Gets the state of the mechanism.
Definition: DifferentialMechanism.hpp:299
DifferentialMechanism(hardware::TalonFX &differentialAddFX, hardware::TalonFX &differentialSubFX, bool motorDirectionsAlign)
Creates a new differential mechanism using the given two hardware::TalonFX devices.
Definition: DifferentialMechanism.hpp:139
hardware::TalonFX const & GetDifferentialLeader() const
Get the Talon FX that is differential leader.
Definition: DifferentialMechanism.hpp:227
ctre::phoenix::StatusCode SetControl(controls::MotionMagicTorqueCurrentFOC AverageRequest, controls::PositionTorqueCurrentFOC 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.
static constexpr int kDefaultConfigRetries
The default number of retries for config applies.
Definition: DifferentialMechanism.hpp:124
ctre::phoenix::StatusCode ApplyConfigs(int numRetries=kDefaultConfigRetries)
Apply the mechanism configs to the devices.
ctre::phoenix::StatusCode SetControl(controls::TorqueCurrentFOC AverageRequest, controls::PositionTorqueCurrentFOC 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::MotionMagicVoltage AverageRequest, controls::VelocityVoltage DifferentialRequest)
Sets the control request for this mechanism.
hardware::TalonFX & GetDifferentialLeader()
Get the Talon FX that is differential leader.
Definition: DifferentialMechanism.hpp:215
bool RequiresUserAction() const
Get whether the mechanism is currently disabled and requires user action to re-enable mechanism contr...
Definition: DifferentialMechanism.hpp:289
MechanismState
Possible states of a mechanism.
Definition: MechanismState.hpp:15
@ RequiresUserAction
The mechanism is disabled and requires user action.
@ Disabled
The mechanism is temporarily disabled due to an issue.
@ OK
The mechanism is running normally.
Definition: string_util.hpp:15