CTRE Phoenix 6 C++ 26.70.0-alpha-2
Loading...
Searching...
No Matches
SimpleDifferentialMechanism.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) Cross The Road Electronics.  All rights reserved.
3 * License information can be found in CTRE_LICENSE.txt
4 * For support and suggestions contact support@ctr-electronics.com or file
5 * an issue tracker at https://github.com/CrossTheRoadElec/Phoenix-Releases
6 */
7#pragma once
8
12#include <atomic>
13#include <optional>
14
15namespace ctre {
16namespace phoenix6 {
17
18namespace hardware {
19 class CANcoder;
20 class CANdi;
21 class Pigeon2;
22}
23
24namespace mechanisms {
25
26/**
27 * \brief Manages control of a simple two-axis differential mechanism.
28 *
29 * This mechanism provides limited differential functionality. Pro users
30 * on a CAN FD bus can use the \c DifferentialMechanism instead
31 * for full functionality.
32 *
33 * \details A differential mechanism has two axes of motion, where
34 * the position along each axis is determined by two motors in
35 * separate gearboxes:
36 *
37 * - Driving both motors in a common direction causes the mechanism
38 * to move forward/reverse, up/down, etc.
39 *
40 * - This is the Average axis: position is determined by the
41 * average of the two motors' positions.
42 *
43 * - Driving the motors in opposing directions causes the mechanism
44 * to twist or rotate left/right.
45 *
46 * - This is the Difference axis: rotation is determined by half
47 * the difference of the two motors' positions.
48 *
49 * \tparam MotorT Type of the motor controllers
50 */
51template <std::derived_from<hardware::traits::CommonTalon> MotorT>
53public:
54 /**
55 * \brief Possible reasons for the mechanism to disable.
56 */
58 /**
59 * \brief No reason given.
60 */
62 /**
63 * \brief A remote sensor is not present on CAN Bus.
64 */
66 /**
67 * \brief The remote Talon FX used for differential
68 * control is not present on CAN Bus.
69 */
71 /**
72 * \brief A remote sensor position has overflowed. Because of the
73 * nature of remote sensors, it is possible for a remote sensor
74 * position to overflow beyond what is supported by the status signal
75 * frame. However, this is rare and cannot occur over the course of an
76 * FRC match under normal use.
77 */
79 /**
80 * \brief A device or remote sensor has reset.
81 */
83 };
84
85 /**
86 * \brief Possible reasons for the mechanism to require
87 * user action to resume control.
88 */
90 /**
91 * \brief No reason given.
92 */
94 /**
95 * \brief A remote sensor position has overflowed. Because of the
96 * nature of remote sensors, it is possible for a remote sensor
97 * position to overflow beyond what is supported by the status signal
98 * frame. However, this is rare and cannot occur over the course of an
99 * FRC match under normal use.
100 */
102 /**
103 * \brief A device or remote sensor has reset.
104 */
106 };
107
108private:
109 /** \brief Number of times to attempt config applies. */
110 static constexpr int kNumConfigAttempts = 2;
111
112 std::unique_ptr<MotorT> _diffLeaderFX;
113 std::unique_ptr<MotorT> _diffFollowerFX;
114
115 wpi::units::scalar_t _sensorToDiffRatio;
116
117 std::function<bool()> _diffLeaderFXResetChecker;
118 std::function<bool()> _diffFollowerFXResetChecker;
119 std::optional<std::function<bool()>> _diffSensorResetChecker{};
120
122
123 controls::NeutralOut _neutral{};
124 controls::CoastOut _coast{};
125 controls::StaticBrake _brake{};
126
127 std::atomic<bool> _mechanismDisabled{false};
128 std::atomic<bool> _requiresUserAction{false};
129
132
133 void ApplyConfigs(
134 DifferentialMotorConstants<typename MotorT::Configuration> const &constants,
135 signals::DifferentialSensorSourceValue diffSensorSource,
136 std::optional<int> diffSensorID
137 );
138 ctre::phoenix::StatusCode BeforeControl();
139
140public:
141 /**
142 * \brief Creates a new simple differential mechanism using two hardware#traits#CommonTalon devices.
143 * The mechanism will use the average of the two Talon FX sensors on the primary axis,
144 * and half of the difference between the two Talon FX sensors on the differential axis.
145 *
146 * This mechanism provides limited differential functionality. Pro users on a CAN FD
147 * bus can use the \c DifferentialMechanism class instead for full functionality.
148 *
149 * \param constants Constants used to construct the mechanism
150 */
152
153 /**
154 * \brief Creates a new simple differential mechanism using two hardware#traits#CommonTalon devices and
155 * a hardware#Pigeon2. The mechanism will use the average of the two Talon FX sensors on the primary
156 * axis, and the selected Pigeon 2 sensor source on the differential axis.
157 *
158 * This mechanism provides limited differential functionality. Pro users on a CAN FD
159 * bus can use the \c DifferentialMechanism class instead for full functionality.
160 *
161 * \param constants Constants used to construct the mechanism
162 * \param pigeon2 The Pigeon 2 to use for the differential axis
163 * \param pigeonSource The sensor source to use for the Pigeon 2 (Yaw, Pitch, or Roll)
164 */
166
167 /**
168 * \brief Creates a new simple differential mechanism using two hardware#traits#CommonTalon devices and
169 * a hardware#CANcoder. The mechanism will use the average of the two Talon FX sensors on the primary
170 * axis, and the CANcoder position/velocity on the differential axis.
171 *
172 * This mechanism provides limited differential functionality. Pro users on a CAN FD
173 * bus can use the \c DifferentialMechanism class instead for full functionality.
174 *
175 * \param constants Constants used to construct the mechanism
176 * \param cancoder The CANcoder to use for the differential axis
177 */
179
180 /**
181 * \brief Creates a new simple differential mechanism using two hardware#traits#CommonTalon devices and
182 * a hardware#CANdi. The mechanism will use the average of the two Talon FX sensors on the primary
183 * axis, and the selected CTR Electronics' CANdi™ branded sensor source on the differential axis.
184 *
185 * This mechanism provides limited differential functionality. Pro users on a CAN FD
186 * bus can use the \c DifferentialMechanism class instead for full functionality.
187 *
188 * \param constants Constants used to construct the mechanism
189 * \param candi The CTR Electronics' CANdi™ branded device to use for the differential axis
190 * \param candiSource The sensor source to use for the CTR Electronics' CANdi™ branded device
191 */
193
194 /**
195 * \brief Configures the neutral mode to use for both motors in the mechanism.
196 *
197 * \param neutralMode The state of the motor controller bridge when output is neutral or disabled
198 * \param timeoutSeconds Maximum amount of time to wait when performing each configuration
199 * \returns Status code of the first failed config call, or OK if all succeeded
200 */
201 ctre::phoenix::StatusCode ConfigNeutralMode(signals::NeutralModeValue neutralMode, wpi::units::second_t timeoutSeconds = 100_ms);
202
203 /**
204 * \brief Call this method periodically to automatically protect against
205 * dangerous fault conditions and keep #GetMechanismState() updated.
206 */
207 void Periodic();
208
209 /**
210 * \brief Get whether the mechanism is currently disabled due to an issue.
211 *
212 * \returns true if the mechanism is temporarily disabled
213 */
214 bool IsDisabled() const
215 {
216 return _mechanismDisabled.load(std::memory_order_acquire);
217 }
218
219 /**
220 * \brief Get whether the mechanism is currently disabled and requires
221 * user action to re-enable mechanism control.
222 *
223 * \returns true if the mechanism is disabled and the user must manually
224 * perform an action
225 */
227 {
228 return _requiresUserAction.load(std::memory_order_acquire);
229 }
230
231 /**
232 * \brief Gets the state of the mechanism.
233 *
234 * \returns MechanismState representing the state of the mechanism
235 */
237 {
238 if (RequiresUserAction()) {
240 } else if (IsDisabled()) {
242 } else {
243 return MechanismState::OK;
244 }
245 }
246
247 /**
248 * \brief Indicate to the mechanism that the user has performed the required
249 * action to resume mechanism control.
250 */
252
253 /**
254 * \returns The reason for the mechanism being disabled
255 */
257 {
258 return _disabledReason;
259 }
260 /**
261 * \returns The reason for the mechanism requiring user
262 * action to resume control
263 */
265 {
266 return _requiresUserReason;
267 }
268
269 /**
270 * \brief Average component of the mechanism position.
271 *
272 * - Minimum Value: -16384.0
273 * - Maximum Value: 16383.999755859375
274 * - Default Value: 0
275 * - Units: rotations
276 *
277 * This refreshes and returns a cached StatusSignal object.
278 *
279 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
280 * \returns DifferentialAveragePosition Status Signal Object
281 */
283 {
284 return _diffLeaderFX->GetDifferentialAveragePosition(refresh);
285 }
286
287 /**
288 * \brief Average component of the mechanism velocity.
289 *
290 * - Minimum Value: -512.0
291 * - Maximum Value: 511.998046875
292 * - Default Value: 0
293 * - Units: rotations per second
294 *
295 * This refreshes and returns a cached StatusSignal object.
296 *
297 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
298 * \returns DifferentialAverageVelocity Status Signal Object
299 */
301 {
302 return _diffLeaderFX->GetDifferentialAverageVelocity(refresh);
303 }
304
305 /**
306 * \brief Differential component of the mechanism position.
307 *
308 * - Minimum Value: -16384.0
309 * - Maximum Value: 16383.999755859375
310 * - Default Value: 0
311 * - Units: rotations
312 *
313 * This refreshes and returns a cached StatusSignal object.
314 *
315 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
316 * \returns DifferentialDifferencePosition Status Signal Object
317 */
319 {
320 return _diffLeaderFX->GetDifferentialDifferencePosition(refresh);
321 }
322
323 /**
324 * \brief Differential component of the mechanism velocity.
325 *
326 * - Minimum Value: -512.0
327 * - Maximum Value: 511.998046875
328 * - Default Value: 0
329 * - Units: rotations per second
330 *
331 * This refreshes and returns a cached StatusSignal object.
332 *
333 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
334 * \returns DifferentialDifferenceVelocity Status Signal Object
335 */
337 {
338 return _diffLeaderFX->GetDifferentialDifferenceVelocity(refresh);
339 }
340
341 /**
342 * \brief Value that the average closed loop is targeting.
343 *
344 * \details This is the value that the closed loop PID controller
345 * targets.
346 *
347 * This refreshes and returns a cached StatusSignal object.
348 *
349 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
350 * \returns ClosedLoopReference Status Signal object
351 */
353 {
354 return _diffLeaderFX->GetClosedLoopReference(refresh);
355 }
356
357 /**
358 * \brief Derivative of the target that the average closed loop is targeting.
359 *
360 * \details This is the change in the closed loop reference. This may
361 * be used in the feed-forward calculation, the derivative-error, or
362 * in application of the signage for kS. Typically, this represents
363 * the target velocity during Motion Magic®.
364 *
365 * This refreshes and returns a cached StatusSignal object.
366 *
367 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
368 * \returns ClosedLoopReferenceSlope Status Signal object
369 */
371 {
372 return _diffLeaderFX->GetClosedLoopReferenceSlope(refresh);
373 }
374
375 /**
376 * \brief The difference between target average reference and current
377 * measurement.
378 *
379 * \details This is the value that is treated as the error in the PID
380 * loop.
381 *
382 * This refreshes and returns a cached StatusSignal object.
383 *
384 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
385 * \returns ClosedLoopError Status Signal object
386 */
388 {
389 return _diffLeaderFX->GetClosedLoopError(refresh);
390 }
391
392 /**
393 * \brief Value that the differential closed loop is targeting.
394 *
395 * \details This is the value that the differential closed loop PID
396 * controller targets (on the difference axis).
397 *
398 * This refreshes and returns a cached StatusSignal object.
399 *
400 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
401 * \returns DifferentialClosedLoopReference Status Signal object
402 */
404 {
405 return _diffLeaderFX->GetDifferentialClosedLoopReference(refresh);
406 }
407
408 /**
409 * \brief Derivative of the target that the differential closed loop
410 * is targeting.
411 *
412 * \details This is the change in the closed loop reference (on the
413 * difference axis). This may be used in the feed-forward calculation,
414 * the derivative-error, or in application of the signage for kS.
415 * Typically, this represents the target velocity during Motion
416 * Magic®.
417 *
418 * This refreshes and returns a cached StatusSignal object.
419 *
420 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
421 * \returns DifferentialClosedLoopReferenceSlope Status Signal object
422 */
424 {
425 return _diffLeaderFX->GetDifferentialClosedLoopReferenceSlope(refresh);
426 }
427
428 /**
429 * \brief The difference between target differential reference and
430 * current measurement.
431 *
432 * \details This is the value that is treated as the error in the
433 * differential PID loop (on the difference axis).
434 *
435 * This refreshes and returns a cached StatusSignal object.
436 *
437 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
438 * \returns DifferentialClosedLoopError Status Signal object
439 */
441 {
442 return _diffLeaderFX->GetDifferentialClosedLoopError(refresh);
443 }
444
445 /**
446 * \brief Sets the position of the mechanism in rotations.
447 *
448 * \param avgPosition The average position of the mechanism, in rotations
449 * \param diffPosition The differential position of the mechanism, in rotations
450 * \param timeoutSeconds Maximum time to wait up to in seconds
451 * \returns StatusCode of the set command
452 */
453 ctre::phoenix::StatusCode SetPosition(wpi::units::turn_t avgPosition, wpi::units::turn_t diffPosition = 0_tr, wpi::units::second_t timeoutSeconds = 0.100_s)
454 {
456
457 auto response = _diffLeaderFX->SetPosition(avgPosition + diffPosition * _sensorToDiffRatio, timeoutSeconds);
458 if (retval.IsOK()) retval = response;
459 response = _diffFollowerFX->SetPosition(avgPosition - diffPosition * _sensorToDiffRatio, timeoutSeconds);
460 if (retval.IsOK()) retval = response;
461
462 return retval;
463 }
464
465 /**
466 * \brief Get the Talon FX that is differential leader. The differential
467 * leader calculates the output for the differential follower. The differential
468 * leader is also used for fault detection, and it reports status signals for
469 * the differential controller.
470 *
471 * \returns Differential leader Talon FX
472 */
473 MotorT &GetLeader()
474 {
475 return *_diffLeaderFX;
476 }
477 /**
478 * \brief Get the Talon FX that is differential leader. The differential
479 * leader calculates the output for the differential follower. The differential
480 * leader is also useful for fault detection, and it reports status signals for
481 * the differential controller.
482 *
483 * \returns Differential leader Talon FX
484 */
485 MotorT const &GetLeader() const
486 {
487 return *_diffLeaderFX;
488 }
489
490 /**
491 * \brief Get the Talon FX that is differential follower. The differential
492 * follower's position and velocity are used by the differential leader
493 * for the differential controller.
494 *
495 * \returns Differential follower Talon FX
496 */
497 MotorT &GetFollower()
498 {
499 return *_diffFollowerFX;
500 }
501 /**
502 * \brief Get the Talon FX that is differential follower. The differential
503 * follower's position and velocity are used by the differential leader
504 * for the differential controller.
505 *
506 * \returns Differential follower Talon FX
507 */
508 MotorT const &GetFollower() const
509 {
510 return *_diffFollowerFX;
511 }
512
513 /**
514 * \brief Request neutral output of mechanism. The applied brake type
515 * is determined by the NeutralMode configuration of each device.
516 *
517 * \details Since the NeutralMode configuration of devices may not align, users
518 * may prefer to use the \c SetCoastOut() or \c SetStaticBrake() method.
519 *
520 * \returns Status Code of the request.
521 */
523
524 /**
525 * \brief Request coast neutral output of mechanism. The bridge is
526 * disabled and the rotor is allowed to coast.
527 *
528 * \returns Status Code of the request.
529 */
531
532 /**
533 * \brief Applies full neutral-brake on the mechanism by shorting
534 * motor leads together.
535 *
536 * \returns Status Code of the request.
537 */
539
540 /**
541 * \brief Sets the control request for this mechanism.
542 *
543 * \param diffLeaderFXRequest Request a specified motor duty cycle with a
544 * differential position closed-loop.
545 * \returns Status code of the request
546 */
548 /**
549 * \brief Sets the control request for this mechanism.
550 *
551 * \param diffLeaderFXRequest Request a specified voltage with a differential
552 * position closed-loop.
553 * \returns Status code of the request
554 */
556 /**
557 * \brief Sets the control request for this mechanism.
558 *
559 * \param diffLeaderFXRequest Request PID to target position with a differential
560 * position setpoint.
561 * \returns Status code of the request
562 */
564 /**
565 * \brief Sets the control request for this mechanism.
566 *
567 * \param diffLeaderFXRequest Request PID to target position with a differential
568 * position setpoint
569 * \returns Status code of the request
570 */
572 /**
573 * \brief Sets the control request for this mechanism.
574 *
575 * \param diffLeaderFXRequest Request PID to target velocity with a differential
576 * position setpoint.
577 * \returns Status code of the request
578 */
580 /**
581 * \brief Sets the control request for this mechanism.
582 *
583 * \param diffLeaderFXRequest Request PID to target velocity with a differential
584 * position setpoint.
585 * \returns Status code of the request
586 */
588 /**
589 * \brief Sets the control request for this mechanism.
590 *
591 * \param diffLeaderFXRequest Requests Motion Magic® to target a final position
592 * using a motion profile, and PID to a differential
593 * position setpoint.
594 * \returns Status code of the request
595 */
597 /**
598 * \brief Sets the control request for this mechanism.
599 *
600 * \param diffLeaderFXRequest Requests Motion Magic® to target a final position
601 * using a motion profile, and PID to a differential
602 * position setpoint.
603 * \returns Status code of the request
604 */
606 /**
607 * \brief Sets the control request for this mechanism.
608 *
609 * \param diffLeaderFXRequest Requests Motion Magic® to target a final position
610 * using an exponential motion profile, and PID to a
611 * differential position setpoint.
612 * \returns Status code of the request
613 */
615 /**
616 * \brief Sets the control request for this mechanism.
617 *
618 * \param diffLeaderFXRequest Requests Motion Magic® to target a final position
619 * using an exponential motion profile, and PID to a
620 * differential position setpoint.
621 * \returns Status code of the request
622 */
624 /**
625 * \brief Sets the control request for this mechanism.
626 *
627 * \param diffLeaderFXRequest Requests Motion Magic® to target a final velocity
628 * using a motion profile, and PID to a differential
629 * position setpoint. This allows smooth transitions
630 * between velocity set points.
631 * \returns Status code of the request
632 */
634 /**
635 * \brief Sets the control request for this mechanism.
636 *
637 * \param diffLeaderFXRequest Requests Motion Magic® to target a final velocity
638 * using a motion profile, and PID to a differential
639 * position setpoint. This allows smooth transitions
640 * between velocity set points.
641 * \returns Status code of the request
642 */
644};
645
646}
647}
648}
Represents a status signal with data of type T, and operations available to retrieve information abou...
Definition StatusSignal.hpp:523
Request a specified motor duty cycle with a differential position closed-loop.
Definition DifferentialDutyCycle.hpp:26
Follow the differential motor output of another Talon.
Definition DifferentialFollower.hpp:29
Requests Motion Magic® to target a final position using a motion profile, and PID to a differential p...
Definition DifferentialMotionMagicDutyCycle.hpp:30
Requests Motion Magic® to target a final position using an exponential motion profile,...
Definition DifferentialMotionMagicExpoDutyCycle.hpp:33
Requests Motion Magic® to target a final position using an exponential motion profile,...
Definition DifferentialMotionMagicExpoVoltage.hpp:32
Requests Motion Magic® to target a final velocity using a motion profile, and PID to a differential p...
Definition DifferentialMotionMagicVelocityDutyCycle.hpp:35
Requests Motion Magic® to target a final velocity using a motion profile, and PID to a differential p...
Definition DifferentialMotionMagicVelocityVoltage.hpp:34
Requests Motion Magic® to target a final position using a motion profile, and PID to a differential p...
Definition DifferentialMotionMagicVoltage.hpp:29
Request PID to target position with a differential position setpoint.
Definition DifferentialPositionDutyCycle.hpp:24
Request PID to target position with a differential position setpoint.
Definition DifferentialPositionVoltage.hpp:24
Request PID to target velocity with a differential position setpoint.
Definition DifferentialVelocityDutyCycle.hpp:25
Request PID to target velocity with a differential position setpoint.
Definition DifferentialVelocityVoltage.hpp:25
Request a specified voltage with a differential position closed-loop.
Definition DifferentialVoltage.hpp:26
Request neutral output of actuator.
Definition NeutralOut.hpp:21
Class for CANcoder, a CAN based magnetic encoder that provides absolute and relative position along w...
Definition CANcoder.hpp:27
Class for CTR Electronics' CANdi™ branded device, a device that integrates digital signals into the e...
Definition CANdi.hpp:26
Class description for the Pigeon 2 IMU sensor that measures orientation.
Definition Pigeon2.hpp:28
StatusSignal< double > & GetAverageClosedLoopReference(bool refresh=true)
Value that the average closed loop is targeting.
Definition SimpleDifferentialMechanism.hpp:352
SimpleDifferentialMechanism(DifferentialMotorConstants< typename MotorT::Configuration > const &constants, hardware::CANcoder &cancoder)
Creates a new simple differential mechanism using two hardware::traits::CommonTalon devices and a har...
DisabledReasonValue GetDisabledReason() const
Definition SimpleDifferentialMechanism.hpp:256
ctre::phoenix::StatusCode SetControl(controls::DifferentialMotionMagicExpoVoltage const &diffLeaderFXRequest)
Sets the control request for this mechanism.
ctre::phoenix::StatusCode SetControl(controls::DifferentialMotionMagicVoltage const &diffLeaderFXRequest)
Sets the control request for this mechanism.
StatusSignal< wpi::units::turn_t > & GetAveragePosition(bool refresh=true)
Average component of the mechanism position.
Definition SimpleDifferentialMechanism.hpp:282
ctre::phoenix::StatusCode SetPosition(wpi::units::turn_t avgPosition, wpi::units::turn_t diffPosition=0_tr, wpi::units::second_t timeoutSeconds=0.100_s)
Sets the position of the mechanism in rotations.
Definition SimpleDifferentialMechanism.hpp:453
StatusSignal< double > & GetDifferentialClosedLoopReference(bool refresh=true)
Value that the differential closed loop is targeting.
Definition SimpleDifferentialMechanism.hpp:403
MechanismState GetMechanismState() const
Gets the state of the mechanism.
Definition SimpleDifferentialMechanism.hpp:236
ctre::phoenix::StatusCode SetControl(controls::DifferentialPositionDutyCycle const &diffLeaderFXRequest)
Sets the control request for this mechanism.
ctre::phoenix::StatusCode SetControl(controls::DifferentialMotionMagicExpoDutyCycle const &diffLeaderFXRequest)
Sets the control request for this mechanism.
SimpleDifferentialMechanism(DifferentialMotorConstants< typename MotorT::Configuration > const &constants)
Creates a new simple differential mechanism using two hardware::traits::CommonTalon devices.
ctre::phoenix::StatusCode SetControl(controls::DifferentialVoltage const &diffLeaderFXRequest)
Sets the control request for this mechanism.
ctre::phoenix::StatusCode SetControl(controls::DifferentialMotionMagicVelocityDutyCycle const &diffLeaderFXRequest)
Sets the control request for this mechanism.
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 har...
ctre::phoenix::StatusCode SetStaticBrake()
Applies full neutral-brake on the mechanism by shorting motor leads together.
RequiresUserReasonValue GetRequiresUserReason() const
Definition SimpleDifferentialMechanism.hpp:264
DisabledReasonValue
Possible reasons for the mechanism to disable.
Definition SimpleDifferentialMechanism.hpp:57
@ RemoteSensorPosOverflow
A remote sensor position has overflowed.
Definition SimpleDifferentialMechanism.hpp:78
@ None
No reason given.
Definition SimpleDifferentialMechanism.hpp:61
@ MissingDifferentialFX
The remote Talon FX used for differential control is not present on CAN Bus.
Definition SimpleDifferentialMechanism.hpp:70
@ DeviceHasReset
A device or remote sensor has reset.
Definition SimpleDifferentialMechanism.hpp:82
@ MissingRemoteSensor
A remote sensor is not present on CAN Bus.
Definition SimpleDifferentialMechanism.hpp:65
ctre::phoenix::StatusCode SetCoastOut()
Request coast neutral output of mechanism.
ctre::phoenix::StatusCode SetControl(controls::DifferentialPositionVoltage const &diffLeaderFXRequest)
Sets the control request for this mechanism.
StatusSignal< wpi::units::turn_t > & GetDifferentialPosition(bool refresh=true)
Differential component of the mechanism position.
Definition SimpleDifferentialMechanism.hpp:318
ctre::phoenix::StatusCode SetControl(controls::DifferentialMotionMagicVelocityVoltage const &diffLeaderFXRequest)
Sets the control request for this mechanism.
bool RequiresUserAction() const
Get whether the mechanism is currently disabled and requires user action to re-enable mechanism contr...
Definition SimpleDifferentialMechanism.hpp:226
ctre::phoenix::StatusCode SetControl(controls::DifferentialDutyCycle 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 SetNeutralOut()
Request neutral output of mechanism.
MotorT & GetLeader()
Get the Talon FX that is differential leader.
Definition SimpleDifferentialMechanism.hpp:473
RequiresUserReasonValue
Possible reasons for the mechanism to require user action to resume control.
Definition SimpleDifferentialMechanism.hpp:89
@ None
No reason given.
Definition SimpleDifferentialMechanism.hpp:93
void ClearUserRequirement()
Indicate to the mechanism that the user has performed the required action to resume mechanism control...
bool IsDisabled() const
Get whether the mechanism is currently disabled due to an issue.
Definition SimpleDifferentialMechanism.hpp:214
MotorT const & GetFollower() const
Get the Talon FX that is differential follower.
Definition SimpleDifferentialMechanism.hpp:508
MotorT const & GetLeader() const
Get the Talon FX that is differential leader.
Definition SimpleDifferentialMechanism.hpp:485
ctre::phoenix::StatusCode SetControl(controls::DifferentialMotionMagicDutyCycle const &diffLeaderFXRequest)
Sets the control request for this mechanism.
StatusSignal< wpi::units::turns_per_second_t > & GetDifferentialVelocity(bool refresh=true)
Differential component of the mechanism velocity.
Definition SimpleDifferentialMechanism.hpp:336
StatusSignal< double > & GetAverageClosedLoopReferenceSlope(bool refresh=true)
Derivative of the target that the average closed loop is targeting.
Definition SimpleDifferentialMechanism.hpp:370
StatusSignal< double > & GetAverageClosedLoopError(bool refresh=true)
The difference between target average reference and current measurement.
Definition SimpleDifferentialMechanism.hpp:387
void Periodic()
Call this method periodically to automatically protect against dangerous fault conditions and keep Ge...
StatusSignal< double > & GetDifferentialClosedLoopError(bool refresh=true)
The difference between target differential reference and current measurement.
Definition SimpleDifferentialMechanism.hpp:440
StatusSignal< wpi::units::turns_per_second_t > & GetAverageVelocity(bool refresh=true)
Average component of the mechanism velocity.
Definition SimpleDifferentialMechanism.hpp:300
ctre::phoenix::StatusCode ConfigNeutralMode(signals::NeutralModeValue neutralMode, wpi::units::second_t timeoutSeconds=100_ms)
Configures the neutral mode to use for both motors in the mechanism.
ctre::phoenix::StatusCode SetControl(controls::DifferentialVelocityVoltage const &diffLeaderFXRequest)
Sets the control request for this mechanism.
StatusSignal< double > & GetDifferentialClosedLoopReferenceSlope(bool refresh=true)
Derivative of the target that the differential closed loop is targeting.
Definition SimpleDifferentialMechanism.hpp:423
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 har...
MotorT & GetFollower()
Get the Talon FX that is differential follower.
Definition SimpleDifferentialMechanism.hpp:497
Status codes reported by APIs, including OK, warnings, and errors.
Definition StatusCodes.h:28
static constexpr int OK
No Error.
Definition StatusCodes.h:35
constexpr bool IsOK() const
Definition StatusCodes.h:860
Definition ExternalFeedbackConfigs.hpp:17
Definition SimpleDifferentialMechanism.hpp:24
DifferentialPigeon2Source
Sensor sources for a differential Pigeon 2.
Definition DifferentialConstants.hpp:20
DifferentialCANdiSource
Sensor sources for a differential CTR Electronics' CANdi™ branded device.
Definition DifferentialConstants.hpp:39
Definition ExternalFeedbackConfigs.hpp:16
MechanismState
Possible states of a mechanism.
Definition MechanismState.hpp:15
@ RequiresUserAction
The mechanism is disabled and requires user action.
Definition MechanismState.hpp:27
@ Disabled
The mechanism is temporarily disabled due to an issue.
Definition MechanismState.hpp:23
@ OK
The mechanism is running normally.
Definition MechanismState.hpp:19
Definition motor_constants.h:14
All constants for setting up the motors of a differential mechanism.
Definition DifferentialConstants.hpp:58
The state of the motor controller bridge when output is neutral or disabled.
Definition SpnEnums.hpp:1499