CTRE Phoenix 6 C++ 26.0.0-beta-1
Loading...
Searching...
No Matches
DifferentialMechanism.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 two-axis differential mechanism.
28 *
29 * This mechanism requires the devices to be Pro licensed and
30 * connected to a CAN FD bus. Unlicensed users and users on a
31 * CAN 2.0 bus can use the \c SimpleDifferentialMechanism instead
32 * with limited functionality.
33 *
34 * \details A differential mechanism has two axes of motion, where
35 * the position along each axis is determined by two motors in
36 * separate gearboxes:
37 *
38 * - Driving both motors in a common direction causes the mechanism
39 * to move forward/reverse, up/down, etc.
40 *
41 * - This is the Average axis: position is determined by the
42 * average of the two motors' positions.
43 *
44 * - Driving the motors in opposing directions causes the mechanism
45 * to twist or rotate left/right.
46 *
47 * - This is the Difference axis: rotation is determined by half
48 * the difference of the two motors' positions.
49 */
50template <std::derived_from<hardware::traits::CommonTalon> MotorT>
52public:
53 /**
54 * \brief Possible reasons for the mechanism to disable.
55 */
57 /**
58 * \brief No reason given.
59 */
60 None,
61 /**
62 * \brief A remote sensor is not present on CAN Bus.
63 */
65 /**
66 * \brief The remote Talon FX used for differential
67 * control is not present on CAN Bus.
68 */
70 /**
71 * \brief A remote sensor position has overflowed. Because of the
72 * nature of remote sensors, it is possible for a remote sensor
73 * position to overflow beyond what is supported by the status signal
74 * frame. However, this is rare and cannot occur over the course of an
75 * FRC match under normal use.
76 */
78 /**
79 * \brief A device or remote sensor has reset.
80 */
82 };
83
84 /**
85 * \brief Possible reasons for the mechanism to require
86 * user action to resume control.
87 */
89 /**
90 * \brief No reason given.
91 */
92 None,
93 /**
94 * \brief A remote sensor position has overflowed. Because of the
95 * nature of remote sensors, it is possible for a remote sensor
96 * position to overflow beyond what is supported by the status signal
97 * frame. However, this is rare and cannot occur over the course of an
98 * FRC match under normal use.
99 */
101 /**
102 * \brief A device or remote sensor has reset.
103 */
105 };
106
107private:
108 /** \brief Number of times to attempt config applies. */
109 static constexpr int kNumConfigAttempts = 2;
110
111 std::unique_ptr<MotorT> _diffLeaderFX;
112 std::unique_ptr<MotorT> _diffFollowerFX;
113
114 units::scalar_t _sensorToDiffRatio;
115
116 std::function<bool()> _diffLeaderFXResetChecker;
117 std::function<bool()> _diffFollowerFXResetChecker;
118 std::optional<std::function<bool()>> _diffSensorResetChecker{};
119
121
122 controls::NeutralOut _neutral{};
123 controls::CoastOut _coast{};
124 controls::StaticBrake _brake{};
125
126 std::atomic<bool> _mechanismDisabled{false};
127 std::atomic<bool> _requiresUserAction{false};
128
131
132 void ApplyConfigs(
133 DifferentialMotorConstants<typename MotorT::Configuration> const &constants,
134 signals::DifferentialSensorSourceValue diffSensorSource,
135 std::optional<int> diffSensorID
136 );
137 ctre::phoenix::StatusCode BeforeControl();
138
139public:
140 /**
141 * \brief Creates a new differential mechanism using two hardware#traits#CommonTalon devices.
142 * The mechanism will use the average of the two Talon FX sensors on the primary axis,
143 * and half of the difference between the two Talon FX sensors on the differential axis.
144 *
145 * This mechanism requires the devices to be Pro licensed and connected to a CAN FD bus.
146 * Unlicensed users and users on a CAN 2.0 bus can use the \c SimpleDifferentialMechanism
147 * instead with limited functionality.
148 *
149 * \param constants Constants used to construct the mechanism
150 */
152
153 /**
154 * \brief Creates a new 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 requires the devices to be Pro licensed and connected to a CAN FD bus.
159 * Unlicensed users and users on a CAN 2.0 bus can use the \c SimpleDifferentialMechanism
160 * instead with limited functionality.
161 *
162 * \param constants Constants used to construct the mechanism
163 * \param pigeon2 The Pigeon 2 to use for the differential axis
164 * \param pigeonSource The sensor source to use for the Pigeon 2 (Yaw, Pitch, or Roll)
165 */
167
168 /**
169 * \brief Creates a new differential mechanism using two hardware#traits#CommonTalon devices and
170 * a hardware#CANcoder. The mechanism will use the average of the two Talon FX sensors on the primary
171 * axis, and the CANcoder position/velocity on the differential axis.
172 *
173 * This mechanism requires the devices to be Pro licensed and connected to a CAN FD bus.
174 * Unlicensed users and users on a CAN 2.0 bus can use the \c SimpleDifferentialMechanism
175 * instead with limited functionality.
176 *
177 * \param constants Constants used to construct the mechanism
178 * \param cancoder The CANcoder to use for the differential axis
179 */
181
182 /**
183 * \brief Creates a new differential mechanism using two hardware#traits#CommonTalon devices and
184 * a hardware#CANdi. The mechanism will use the average of the two Talon FX sensors on the primary
185 * axis, and the selected CTR Electronics' CANdi™ branded sensor source on the differential axis.
186 *
187 * This mechanism requires the devices to be Pro licensed and connected to a CAN FD bus.
188 * Unlicensed users and users on a CAN 2.0 bus can use the \c SimpleDifferentialMechanism
189 * instead with limited functionality.
190 *
191 * \param constants Constants used to construct the mechanism
192 * \param candi The CTR Electronics' CANdi™ branded device to use for the differential axis
193 * \param candiSource The sensor source to use for the CTR Electronics' CANdi™ branded device
194 */
196
197 /**
198 * \brief Configures the neutral mode to use for both motors in the mechanism.
199 *
200 * \param neutralMode The state of the motor controller bridge when output is neutral or disabled
201 * \param timeoutSeconds Maximum amount of time to wait when performing each configuration
202 * \returns Status code of the first failed config call, or OK if all succeeded
203 */
204 ctre::phoenix::StatusCode ConfigNeutralMode(signals::NeutralModeValue neutralMode, units::second_t timeoutSeconds = 100_ms);
205
206 /**
207 * \brief Call this method periodically to automatically protect against
208 * dangerous fault conditions and keep #GetMechanismState() updated.
209 */
210 void Periodic();
211
212 /**
213 * \brief Get whether the mechanism is currently disabled due to an issue.
214 *
215 * \returns true if the mechanism is temporarily disabled
216 */
217 bool IsDisabled() const
218 {
219 return _mechanismDisabled.load(std::memory_order_acquire);
220 }
221
222 /**
223 * \brief Get whether the mechanism is currently disabled and requires
224 * user action to re-enable mechanism control.
225 *
226 * \returns true if the mechanism is disabled and the user must manually
227 * perform an action
228 */
230 {
231 return _requiresUserAction.load(std::memory_order_acquire);
232 }
233
234 /**
235 * \brief Gets the state of the mechanism.
236 *
237 * \returns MechanismState representing the state of the mechanism
238 */
240 {
241 if (RequiresUserAction()) {
243 } else if (IsDisabled()) {
245 } else {
246 return MechanismState::OK;
247 }
248 }
249
250 /**
251 * \brief Indicate to the mechanism that the user has performed the required
252 * action to resume mechanism control.
253 */
255
256 /**
257 * \returns The reason for the mechanism being disabled
258 */
260 {
261 return _disabledReason;
262 }
263 /**
264 * \returns The reason for the mechanism requiring user
265 * action to resume control
266 */
268 {
269 return _requiresUserReason;
270 }
271
272 /**
273 * \brief Average component of the mechanism position.
274 *
275 * - Minimum Value: -16384.0
276 * - Maximum Value: 16383.999755859375
277 * - Default Value: 0
278 * - Units: rotations
279 *
280 * This refreshes and returns a cached StatusSignal object.
281 *
282 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
283 * \returns DifferentialAveragePosition Status Signal Object
284 */
286 {
287 return _diffLeaderFX->GetDifferentialAveragePosition(refresh);
288 }
289
290 /**
291 * \brief Average component of the mechanism velocity.
292 *
293 * - Minimum Value: -512.0
294 * - Maximum Value: 511.998046875
295 * - Default Value: 0
296 * - Units: rotations per second
297 *
298 * This refreshes and returns a cached StatusSignal object.
299 *
300 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
301 * \returns DifferentialAverageVelocity Status Signal Object
302 */
304 {
305 return _diffLeaderFX->GetDifferentialAverageVelocity(refresh);
306 }
307
308 /**
309 * \brief Differential component of the mechanism position.
310 *
311 * - Minimum Value: -16384.0
312 * - Maximum Value: 16383.999755859375
313 * - Default Value: 0
314 * - Units: rotations
315 *
316 * This refreshes and returns a cached StatusSignal object.
317 *
318 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
319 * \returns DifferentialDifferencePosition Status Signal Object
320 */
322 {
323 return _diffLeaderFX->GetDifferentialDifferencePosition(refresh);
324 }
325
326 /**
327 * \brief Differential component of the mechanism velocity.
328 *
329 * - Minimum Value: -512.0
330 * - Maximum Value: 511.998046875
331 * - Default Value: 0
332 * - Units: rotations per second
333 *
334 * This refreshes and returns a cached StatusSignal object.
335 *
336 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
337 * \returns DifferentialDifferenceVelocity Status Signal Object
338 */
340 {
341 return _diffLeaderFX->GetDifferentialDifferenceVelocity(refresh);
342 }
343
344 /**
345 * \brief Value that the average closed loop is targeting.
346 *
347 * \details This is the value that the closed loop PID controller
348 * targets.
349 *
350 * This refreshes and returns a cached StatusSignal object.
351 *
352 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
353 * \returns ClosedLoopReference Status Signal object
354 */
356 {
357 return _diffLeaderFX->GetClosedLoopReference(refresh);
358 }
359
360 /**
361 * \brief Derivative of the target that the average closed loop is targeting.
362 *
363 * \details This is the change in the closed loop reference. This may
364 * be used in the feed-forward calculation, the derivative-error, or
365 * in application of the signage for kS. Typically, this represents
366 * the target velocity during Motion Magic®.
367 *
368 * This refreshes and returns a cached StatusSignal object.
369 *
370 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
371 * \returns ClosedLoopReferenceSlope Status Signal object
372 */
374 {
375 return _diffLeaderFX->GetClosedLoopReferenceSlope(refresh);
376 }
377
378 /**
379 * \brief The difference between target average reference and current
380 * measurement.
381 *
382 * \details This is the value that is treated as the error in the PID
383 * loop.
384 *
385 * This refreshes and returns a cached StatusSignal object.
386 *
387 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
388 * \returns ClosedLoopError Status Signal object
389 */
391 {
392 return _diffLeaderFX->GetClosedLoopError(refresh);
393 }
394
395 /**
396 * \brief Value that the differential closed loop is targeting.
397 *
398 * \details This is the value that the differential closed loop PID
399 * controller targets (on the difference axis).
400 *
401 * This refreshes and returns a cached StatusSignal object.
402 *
403 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
404 * \returns DifferentialClosedLoopReference Status Signal object
405 */
407 {
408 return _diffLeaderFX->GetDifferentialClosedLoopReference(refresh);
409 }
410
411 /**
412 * \brief Derivative of the target that the differential closed loop
413 * is targeting.
414 *
415 * \details This is the change in the closed loop reference (on the
416 * difference axis). This may be used in the feed-forward calculation,
417 * the derivative-error, or in application of the signage for kS.
418 * Typically, this represents the target velocity during Motion
419 * Magic®.
420 *
421 * This refreshes and returns a cached StatusSignal object.
422 *
423 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
424 * \returns DifferentialClosedLoopReferenceSlope Status Signal object
425 */
427 {
428 return _diffLeaderFX->GetDifferentialClosedLoopReferenceSlope(refresh);
429 }
430
431 /**
432 * \brief The difference between target differential reference and
433 * current measurement.
434 *
435 * \details This is the value that is treated as the error in the
436 * differential PID loop (on the difference axis).
437 *
438 * This refreshes and returns a cached StatusSignal object.
439 *
440 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
441 * \returns DifferentialClosedLoopError Status Signal object
442 */
444 {
445 return _diffLeaderFX->GetDifferentialClosedLoopError(refresh);
446 }
447
448 /**
449 * \brief Sets the position of the mechanism in rotations.
450 *
451 * \param avgPosition The average position of the mechanism, in rotations
452 * \param diffPosition The differential position of the mechanism, in rotations
453 * \param timeoutSeconds Maximum time to wait up to in seconds
454 * \returns StatusCode of the set command
455 */
456 ctre::phoenix::StatusCode SetPosition(units::turn_t avgPosition, units::turn_t diffPosition = 0_tr, units::time::second_t timeoutSeconds = 0.100_s)
457 {
459
460 auto response = _diffLeaderFX->SetPosition(avgPosition + diffPosition * _sensorToDiffRatio, timeoutSeconds);
461 if (retval.IsOK()) retval = response;
462 response = _diffFollowerFX->SetPosition(avgPosition - diffPosition * _sensorToDiffRatio, timeoutSeconds);
463 if (retval.IsOK()) retval = response;
464
465 return retval;
466 }
467
468 /**
469 * \brief Get the Talon FX that is differential leader. The differential
470 * leader calculates the output for the differential follower. The differential
471 * leader is also used for fault detection, and it reports status signals for
472 * the differential controller.
473 *
474 * \returns Differential leader Talon FX
475 */
476 MotorT &GetLeader()
477 {
478 return *_diffLeaderFX;
479 }
480 /**
481 * \brief Get the Talon FX that is differential leader. The differential
482 * leader calculates the output for the differential follower. The differential
483 * leader is also useful for fault detection, and it reports status signals for
484 * the differential controller.
485 *
486 * \returns Differential leader Talon FX
487 */
488 MotorT const &GetLeader() const
489 {
490 return *_diffLeaderFX;
491 }
492
493 /**
494 * \brief Get the Talon FX that is differential follower. The differential
495 * follower's position and velocity are used by the differential leader
496 * for the differential controller.
497 *
498 * \returns Differential follower Talon FX
499 */
500 MotorT &GetFollower()
501 {
502 return *_diffFollowerFX;
503 }
504 /**
505 * \brief Get the Talon FX that is differential follower. The differential
506 * follower's position and velocity are used by the differential leader
507 * for the differential controller.
508 *
509 * \returns Differential follower Talon FX
510 */
511 MotorT const &GetFollower() const
512 {
513 return *_diffFollowerFX;
514 }
515
516 /**
517 * \brief Request neutral output of mechanism. The applied brake type
518 * is determined by the NeutralMode configuration of each device.
519 *
520 * \details Since the NeutralMode configuration of devices may not align, users
521 * may prefer to use the \c SetCoastOut() or \c SetStaticBrake() method.
522 *
523 * \returns Status Code of the request.
524 */
526
527 /**
528 * \brief Request coast neutral output of mechanism. The bridge is
529 * disabled and the rotor is allowed to coast.
530 *
531 * \returns Status Code of the request.
532 */
534
535 /**
536 * \brief Applies full neutral-brake on the mechanism by shorting
537 * motor leads together.
538 *
539 * \returns Status Code of the request.
540 */
542
543 /**
544 * \brief Sets the control request for this mechanism.
545 *
546 * \param AverageRequest Average DutyCycleOut request of the mechanism.
547 * \param DifferentialRequest Differential PositionDutyCycle request of the
548 * mechanism. Note: The UpdateFreqHz parameter for
549 * this control request will be ignored by the
550 * control frame.
551 * \returns Status Code of the request.
552 */
554 /**
555 * \brief Sets the control request for this mechanism.
556 *
557 * \param AverageRequest Average PositionDutyCycle request of the mechanism.
558 * \param DifferentialRequest Differential PositionDutyCycle request of the
559 * mechanism. Note: The UpdateFreqHz parameter for
560 * this control request will be ignored by the
561 * control frame.
562 * \returns Status Code of the request.
563 */
565 /**
566 * \brief Sets the control request for this mechanism.
567 *
568 * \param AverageRequest Average VelocityDutyCYcle request of the mechanism.
569 * \param DifferentialRequest Differential PositionDutyCycle request of the
570 * mechanism. Note: The UpdateFreqHz parameter for
571 * this control request will be ignored by the
572 * control frame.
573 * \returns Status Code of the request.
574 */
576 /**
577 * \brief Sets the control request for this mechanism.
578 *
579 * \param AverageRequest Average MotionMagicDutyCycle request of the mechanism.
580 * \param DifferentialRequest Differential PositionDutyCycle request of the
581 * mechanism. Note: The UpdateFreqHz parameter for
582 * this control request will be ignored by the
583 * control frame.
584 * \returns Status Code of the request.
585 */
587 /**
588 * \brief Sets the control request for this mechanism.
589 *
590 * \param AverageRequest Average MotionMagicExpoDutyCycle request of the
591 * mechanism.
592 * \param DifferentialRequest Differential PositionDutyCycle request of the
593 * mechanism. Note: The UpdateFreqHz parameter for
594 * this control request will be ignored by the
595 * control frame.
596 * \returns Status Code of the request.
597 */
599 /**
600 * \brief Sets the control request for this mechanism.
601 *
602 * \param AverageRequest Average MotionMagicVelocityDutyCycle request of the
603 * mechanism.
604 * \param DifferentialRequest Differential PositionDutyCycle request of the
605 * mechanism. Note: The UpdateFreqHz parameter for
606 * this control request will be ignored by the
607 * control frame.
608 * \returns Status Code of the request.
609 */
611 /**
612 * \brief Sets the control request for this mechanism.
613 *
614 * \param AverageRequest Average DutyCycleOut request of the mechanism.
615 * \param DifferentialRequest Differential VelocityDutyCycle request of the
616 * mechanism. Note: The UpdateFreqHz parameter for
617 * this control request will be ignored by the
618 * control frame.
619 * \returns Status Code of the request.
620 */
622 /**
623 * \brief Sets the control request for this mechanism.
624 *
625 * \param AverageRequest Average PositionDutyCycle request of the mechanism.
626 * \param DifferentialRequest Differential VelocityDutyCycle request of the
627 * mechanism. Note: The UpdateFreqHz parameter for
628 * this control request will be ignored by the
629 * control frame.
630 * \returns Status Code of the request.
631 */
633 /**
634 * \brief Sets the control request for this mechanism.
635 *
636 * \param AverageRequest Average VelocityDutyCycle request of the mechanism.
637 * \param DifferentialRequest Differential VelocityDutyCycle request of the
638 * mechanism. Note: The UpdateFreqHz parameter for
639 * this control request will be ignored by the
640 * control frame.
641 * \returns Status Code of the request.
642 */
644 /**
645 * \brief Sets the control request for this mechanism.
646 *
647 * \param AverageRequest Average MotionMagicDutyCycle request of the mechanism.
648 * \param DifferentialRequest Differential VelocityDutyCycle request of the
649 * mechanism. Note: The UpdateFreqHz parameter for
650 * this control request will be ignored by the
651 * control frame.
652 * \returns Status Code of the request.
653 */
655 /**
656 * \brief Sets the control request for this mechanism.
657 *
658 * \param AverageRequest Average MotionMagicExpoDutyCycle request of the
659 * mechanism.
660 * \param DifferentialRequest Differential VelocityDutyCycle request of the
661 * mechanism. Note: The UpdateFreqHz parameter for
662 * this control request will be ignored by the
663 * control frame.
664 * \returns Status Code of the request.
665 */
667 /**
668 * \brief Sets the control request for this mechanism.
669 *
670 * \param AverageRequest Average MotionMagicVelocityDutyCycle request of the
671 * mechanism.
672 * \param DifferentialRequest Differential VelocityDutyCycle request of the
673 * mechanism. Note: The UpdateFreqHz parameter for
674 * this control request will be ignored by the
675 * control frame.
676 * \returns Status Code of the request.
677 */
679 /**
680 * \brief Sets the control request for this mechanism.
681 *
682 * \param AverageRequest Average DutyCycleOut request of the mechanism.
683 * \param DifferentialRequest Differential DutyCycleOut request of the
684 * mechanism. Note: The UpdateFreqHz parameter for
685 * this control request will be ignored by the
686 * control frame.
687 * \returns Status Code of the request.
688 */
690 /**
691 * \brief Sets the control request for this mechanism.
692 *
693 * \param AverageRequest Average PositionDutyCycle request of the mechanism.
694 * \param DifferentialRequest Differential DutyCycleOut request of the
695 * mechanism. Note: The UpdateFreqHz parameter for
696 * this control request will be ignored by the
697 * control frame.
698 * \returns Status Code of the request.
699 */
701 /**
702 * \brief Sets the control request for this mechanism.
703 *
704 * \param AverageRequest Average VelocityDutyCYcle request of the mechanism.
705 * \param DifferentialRequest Differential DutyCycleOut request of the
706 * mechanism. Note: The UpdateFreqHz parameter for
707 * this control request will be ignored by the
708 * control frame.
709 * \returns Status Code of the request.
710 */
712 /**
713 * \brief Sets the control request for this mechanism.
714 *
715 * \param AverageRequest Average MotionMagicDutyCycle request of the mechanism.
716 * \param DifferentialRequest Differential DutyCycleOut request of the
717 * mechanism. Note: The UpdateFreqHz parameter for
718 * this control request will be ignored by the
719 * control frame.
720 * \returns Status Code of the request.
721 */
723 /**
724 * \brief Sets the control request for this mechanism.
725 *
726 * \param AverageRequest Average MotionMagicExpoDutyCycle request of the
727 * mechanism.
728 * \param DifferentialRequest Differential DutyCycleOut request of the
729 * mechanism. Note: The UpdateFreqHz parameter for
730 * this control request will be ignored by the
731 * control frame.
732 * \returns Status Code of the request.
733 */
735 /**
736 * \brief Sets the control request for this mechanism.
737 *
738 * \param AverageRequest Average MotionMagicVelocityDutyCycle request of the
739 * mechanism.
740 * \param DifferentialRequest Differential DutyCycleOut request of the
741 * mechanism. Note: The UpdateFreqHz parameter for
742 * this control request will be ignored by the
743 * control frame.
744 * \returns Status Code of the request.
745 */
747 /**
748 * \brief Sets the control request for this mechanism.
749 *
750 * \param AverageRequest Average VoltageOut request of the mechanism.
751 * \param DifferentialRequest Differential PositionVoltage request of the
752 * mechanism. Note: The UpdateFreqHz parameter for
753 * this control request will be ignored by the
754 * control frame.
755 * \returns Status Code of the request.
756 */
758 /**
759 * \brief Sets the control request for this mechanism.
760 *
761 * \param AverageRequest Average PositionVoltage request of the mechanism.
762 * \param DifferentialRequest Differential PositionVoltage request of the
763 * mechanism. Note: The UpdateFreqHz parameter for
764 * this control request will be ignored by the
765 * control frame.
766 * \returns Status Code of the request.
767 */
769 /**
770 * \brief Sets the control request for this mechanism.
771 *
772 * \param AverageRequest Average VelocityVoltage request of the mechanism.
773 * \param DifferentialRequest Differential PositionVoltage request of the
774 * mechanism. Note: The UpdateFreqHz parameter for
775 * this control request will be ignored by the
776 * control frame.
777 * \returns Status Code of the request.
778 */
780 /**
781 * \brief Sets the control request for this mechanism.
782 *
783 * \param AverageRequest Average MotionMagicVoltage request of the mechanism.
784 * \param DifferentialRequest Differential PositionVoltage request of the
785 * mechanism. Note: The UpdateFreqHz parameter for
786 * this control request will be ignored by the
787 * control frame.
788 * \returns Status Code of the request.
789 */
791 /**
792 * \brief Sets the control request for this mechanism.
793 *
794 * \param AverageRequest Average MotionMagicExpoVoltage request of the
795 * mechanism.
796 * \param DifferentialRequest Differential PositionVoltage request of the
797 * mechanism. Note: The UpdateFreqHz parameter for
798 * this control request will be ignored by the
799 * control frame.
800 * \returns Status Code of the request.
801 */
803 /**
804 * \brief Sets the control request for this mechanism.
805 *
806 * \param AverageRequest Average MotionMagicVelocityVoltage request of the
807 * mechanism.
808 * \param DifferentialRequest Differential PositionVoltage request of the
809 * mechanism. Note: The UpdateFreqHz parameter for
810 * this control request will be ignored by the
811 * control frame.
812 * \returns Status Code of the request.
813 */
815 /**
816 * \brief Sets the control request for this mechanism.
817 *
818 * \param AverageRequest Average VoltageOut request of the mechanism.
819 * \param DifferentialRequest Differential VelocityVoltage request of the
820 * mechanism. Note: The UpdateFreqHz parameter for
821 * this control request will be ignored by the
822 * control frame.
823 * \returns Status Code of the request.
824 */
826 /**
827 * \brief Sets the control request for this mechanism.
828 *
829 * \param AverageRequest Average PositionVoltage request of the mechanism.
830 * \param DifferentialRequest Differential VelocityVoltage request of the
831 * mechanism. Note: The UpdateFreqHz parameter for
832 * this control request will be ignored by the
833 * control frame.
834 * \returns Status Code of the request.
835 */
837 /**
838 * \brief Sets the control request for this mechanism.
839 *
840 * \param AverageRequest Average VelocityVoltage request of the mechanism.
841 * \param DifferentialRequest Differential VelocityVoltage request of the
842 * mechanism. Note: The UpdateFreqHz parameter for
843 * this control request will be ignored by the
844 * control frame.
845 * \returns Status Code of the request.
846 */
848 /**
849 * \brief Sets the control request for this mechanism.
850 *
851 * \param AverageRequest Average MotionMagicVoltage request of the mechanism.
852 * \param DifferentialRequest Differential VelocityVoltage request of the
853 * mechanism. Note: The UpdateFreqHz parameter for
854 * this control request will be ignored by the
855 * control frame.
856 * \returns Status Code of the request.
857 */
859 /**
860 * \brief Sets the control request for this mechanism.
861 *
862 * \param AverageRequest Average MotionMagicExpoVoltage request of the
863 * mechanism.
864 * \param DifferentialRequest Differential VelocityVoltage request of the
865 * mechanism. Note: The UpdateFreqHz parameter for
866 * this control request will be ignored by the
867 * control frame.
868 * \returns Status Code of the request.
869 */
871 /**
872 * \brief Sets the control request for this mechanism.
873 *
874 * \param AverageRequest Average MotionMagicVelocityVoltage request of the
875 * mechanism.
876 * \param DifferentialRequest Differential VelocityVoltage request of the
877 * mechanism. Note: The UpdateFreqHz parameter for
878 * this control request will be ignored by the
879 * control frame.
880 * \returns Status Code of the request.
881 */
883 /**
884 * \brief Sets the control request for this mechanism.
885 *
886 * \param AverageRequest Average VoltageOut request of the mechanism.
887 * \param DifferentialRequest Differential VoltageOut request of the mechanism.
888 * Note: The UpdateFreqHz parameter for this control
889 * request will be ignored by the control frame.
890 * \returns Status Code of the request.
891 */
893 /**
894 * \brief Sets the control request for this mechanism.
895 *
896 * \param AverageRequest Average PositionVoltage request of the mechanism.
897 * \param DifferentialRequest Differential VoltageOut request of the mechanism.
898 * Note: The UpdateFreqHz parameter for this control
899 * request will be ignored by the control frame.
900 * \returns Status Code of the request.
901 */
903 /**
904 * \brief Sets the control request for this mechanism.
905 *
906 * \param AverageRequest Average VelocityVoltage request of the mechanism.
907 * \param DifferentialRequest Differential VoltageOut request of the mechanism.
908 * Note: The UpdateFreqHz parameter for this control
909 * request will be ignored by the control frame.
910 * \returns Status Code of the request.
911 */
913 /**
914 * \brief Sets the control request for this mechanism.
915 *
916 * \param AverageRequest Average MotionMagicVoltage request of the mechanism.
917 * \param DifferentialRequest Differential VoltageOut request of the mechanism.
918 * Note: The UpdateFreqHz parameter for this control
919 * request will be ignored by the control frame.
920 * \returns Status Code of the request.
921 */
923 /**
924 * \brief Sets the control request for this mechanism.
925 *
926 * \param AverageRequest Average MotionMagicExpoVoltage request of the
927 * mechanism.
928 * \param DifferentialRequest Differential VoltageOut request of the mechanism.
929 * Note: The UpdateFreqHz parameter for this control
930 * request will be ignored by the control frame.
931 * \returns Status Code of the request.
932 */
934 /**
935 * \brief Sets the control request for this mechanism.
936 *
937 * \param AverageRequest Average MotionMagicVelocityVoltage request of the
938 * mechanism.
939 * \param DifferentialRequest Differential VoltageOut request of the mechanism.
940 * Note: The UpdateFreqHz parameter for this control
941 * request will be ignored by the control frame.
942 * \returns Status Code of the request.
943 */
945 /**
946 * \brief Sets the control request for this mechanism.
947 *
948 * \param AverageRequest Average TorqueCurrentFOC request of the mechanism.
949 * \param DifferentialRequest Differential PositionTorqueCurrentFOC request of
950 * the mechanism. Note: The UpdateFreqHz parameter
951 * for this control request will be ignored by the
952 * control frame.
953 * \returns Status Code of the request.
954 */
956 /**
957 * \brief Sets the control request for this mechanism.
958 *
959 * \param AverageRequest Average PositionTorqueCurrentFOC request of the
960 * mechanism.
961 * \param DifferentialRequest Differential PositionTorqueCurrentFOC request of
962 * the mechanism. Note: The UpdateFreqHz parameter
963 * for this control request will be ignored by the
964 * control frame.
965 * \returns Status Code of the request.
966 */
968 /**
969 * \brief Sets the control request for this mechanism.
970 *
971 * \param AverageRequest Average VelocityTorqueCurrentFOC request of the
972 * mechanism.
973 * \param DifferentialRequest Differential PositionTorqueCurrentFOC request of
974 * the mechanism. Note: The UpdateFreqHz parameter
975 * for this control request will be ignored by the
976 * control frame.
977 * \returns Status Code of the request.
978 */
980 /**
981 * \brief Sets the control request for this mechanism.
982 *
983 * \param AverageRequest Average MotionMagicTorqueCurrentFOC request of the
984 * mechanism.
985 * \param DifferentialRequest Differential PositionTorqueCurrentFOC request of
986 * the mechanism. Note: The UpdateFreqHz parameter
987 * for this control request will be ignored by the
988 * control frame.
989 * \returns Status Code of the request.
990 */
992 /**
993 * \brief Sets the control request for this mechanism.
994 *
995 * \param AverageRequest Average MotionMagicExpoTorqueCurrentFOC request of the
996 * mechanism.
997 * \param DifferentialRequest Differential PositionTorqueCurrentFOC request of
998 * the mechanism. Note: The UpdateFreqHz parameter
999 * for this control request will be ignored by the
1000 * control frame.
1001 * \returns Status Code of the request.
1002 */
1004 /**
1005 * \brief Sets the control request for this mechanism.
1006 *
1007 * \param AverageRequest Average MotionMagicVelocityTorqueCurrentFOC request of
1008 * the mechanism.
1009 * \param DifferentialRequest Differential PositionTorqueCurrentFOC request of
1010 * the mechanism. Note: The UpdateFreqHz parameter
1011 * for this control request will be ignored by the
1012 * control frame.
1013 * \returns Status Code of the request.
1014 */
1016 /**
1017 * \brief Sets the control request for this mechanism.
1018 *
1019 * \param AverageRequest Average TorqueCurrentFOC request of the mechanism.
1020 * \param DifferentialRequest Differential VelocityTorqueCurrentFOC request of
1021 * the mechanism. Note: The UpdateFreqHz parameter
1022 * for this control request will be ignored by the
1023 * control frame.
1024 * \returns Status Code of the request.
1025 */
1027 /**
1028 * \brief Sets the control request for this mechanism.
1029 *
1030 * \param AverageRequest Average PositionTorqueCurrentFOC request of the
1031 * mechanism.
1032 * \param DifferentialRequest Differential VelocityTorqueCurrentFOC request of
1033 * the mechanism. Note: The UpdateFreqHz parameter
1034 * for this control request will be ignored by the
1035 * control frame.
1036 * \returns Status Code of the request.
1037 */
1039 /**
1040 * \brief Sets the control request for this mechanism.
1041 *
1042 * \param AverageRequest Average VelocityTorqueCurrentFOC request of the
1043 * mechanism.
1044 * \param DifferentialRequest Differential VelocityTorqueCurrentFOC request of
1045 * the mechanism. Note: The UpdateFreqHz parameter
1046 * for this control request will be ignored by the
1047 * control frame.
1048 * \returns Status Code of the request.
1049 */
1051 /**
1052 * \brief Sets the control request for this mechanism.
1053 *
1054 * \param AverageRequest Average MotionMagicTorqueCurrentFOC request of the
1055 * mechanism.
1056 * \param DifferentialRequest Differential VelocityTorqueCurrentFOC request of
1057 * the mechanism. Note: The UpdateFreqHz parameter
1058 * for this control request will be ignored by the
1059 * control frame.
1060 * \returns Status Code of the request.
1061 */
1063 /**
1064 * \brief Sets the control request for this mechanism.
1065 *
1066 * \param AverageRequest Average MotionMagicExpoTorqueCurrentFOC request of the
1067 * mechanism.
1068 * \param DifferentialRequest Differential VelocityTorqueCurrentFOC request of
1069 * the mechanism. Note: The UpdateFreqHz parameter
1070 * for this control request will be ignored by the
1071 * control frame.
1072 * \returns Status Code of the request.
1073 */
1075 /**
1076 * \brief Sets the control request for this mechanism.
1077 *
1078 * \param AverageRequest Average MotionMagicVelocityTorqueCurrentFOC request of
1079 * the mechanism.
1080 * \param DifferentialRequest Differential VelocityTorqueCurrentFOC request of
1081 * the mechanism. Note: The UpdateFreqHz parameter
1082 * for this control request will be ignored by the
1083 * control frame.
1084 * \returns Status Code of the request.
1085 */
1087 /**
1088 * \brief Sets the control request for this mechanism.
1089 *
1090 * \param AverageRequest Average TorqueCurrentFOC request of the mechanism.
1091 * \param DifferentialRequest Differential TorqueCurrentFOC request of the
1092 * mechanism. Note: The UpdateFreqHz parameter for
1093 * this control request will be ignored by the
1094 * control frame.
1095 * \returns Status Code of the request.
1096 */
1098 /**
1099 * \brief Sets the control request for this mechanism.
1100 *
1101 * \param AverageRequest Average PositionTorqueCurrentFOC request of the
1102 * mechanism.
1103 * \param DifferentialRequest Differential TorqueCurrentFOC request of the
1104 * mechanism. Note: The UpdateFreqHz parameter for
1105 * this control request will be ignored by the
1106 * control frame.
1107 * \returns Status Code of the request.
1108 */
1110 /**
1111 * \brief Sets the control request for this mechanism.
1112 *
1113 * \param AverageRequest Average VelocityTorqueCurrentFOC request of the
1114 * mechanism.
1115 * \param DifferentialRequest Differential TorqueCurrentFOC request of the
1116 * mechanism. Note: The UpdateFreqHz parameter for
1117 * this control request will be ignored by the
1118 * control frame.
1119 * \returns Status Code of the request.
1120 */
1122 /**
1123 * \brief Sets the control request for this mechanism.
1124 *
1125 * \param AverageRequest Average MotionMagicTorqueCurrentFOC request of the
1126 * mechanism.
1127 * \param DifferentialRequest Differential TorqueCurrentFOC request of the
1128 * mechanism. Note: The UpdateFreqHz parameter for
1129 * this control request will be ignored by the
1130 * control frame.
1131 * \returns Status Code of the request.
1132 */
1134 /**
1135 * \brief Sets the control request for this mechanism.
1136 *
1137 * \param AverageRequest Average MotionMagicExpoTorqueCurrentFOC request of the
1138 * mechanism.
1139 * \param DifferentialRequest Differential TorqueCurrentFOC request of the
1140 * mechanism. Note: The UpdateFreqHz parameter for
1141 * this control request will be ignored by the
1142 * control frame.
1143 * \returns Status Code of the request.
1144 */
1146 /**
1147 * \brief Sets the control request for this mechanism.
1148 *
1149 * \param AverageRequest Average MotionMagicVelocityTorqueCurrentFOC request of
1150 * the mechanism.
1151 * \param DifferentialRequest Differential TorqueCurrentFOC request of the
1152 * mechanism. Note: The UpdateFreqHz parameter for
1153 * this control request will be ignored by the
1154 * control frame.
1155 * \returns Status Code of the request.
1156 */
1158};
1159
1160}
1161}
1162}
Represents a status signal with data of type T, and operations available to retrieve information abou...
Definition StatusSignal.hpp:474
Follow the differential motor output of another Talon.
Definition DifferentialFollower.hpp:29
Request a specified motor duty cycle.
Definition DutyCycleOut.hpp:23
Requests Motion Magic® to target a final position using a motion profile.
Definition MotionMagicDutyCycle.hpp:31
Requests Motion Magic® to target a final position using an exponential motion profile.
Definition MotionMagicExpoDutyCycle.hpp:34
Requires Phoenix Pro; Requests Motion Magic® to target a final position using an exponential motion p...
Definition MotionMagicExpoTorqueCurrentFOC.hpp:34
Requests Motion Magic® to target a final position using an exponential motion profile.
Definition MotionMagicExpoVoltage.hpp:33
Requires Phoenix Pro; Requests Motion Magic® to target a final position using a motion profile.
Definition MotionMagicTorqueCurrentFOC.hpp:31
Requests Motion Magic® to target a final velocity using a motion profile.
Definition MotionMagicVelocityDutyCycle.hpp:38
Requests Motion Magic® to target a final velocity using a motion profile.
Definition MotionMagicVelocityTorqueCurrentFOC.hpp:38
Requests Motion Magic® to target a final velocity using a motion profile.
Definition MotionMagicVelocityVoltage.hpp:37
Requests Motion Magic® to target a final position using a motion profile.
Definition MotionMagicVoltage.hpp:30
Request neutral output of actuator.
Definition NeutralOut.hpp:21
Request PID to target position with duty cycle feedforward.
Definition PositionDutyCycle.hpp:26
Requires Phoenix Pro; Request PID to target position with torque current feedforward.
Definition PositionTorqueCurrentFOC.hpp:27
Request PID to target position with voltage feedforward.
Definition PositionVoltage.hpp:26
Requires Phoenix Pro; Request a specified motor current (field oriented control).
Definition TorqueCurrentFOC.hpp:27
Request PID to target velocity with duty cycle feedforward.
Definition VelocityDutyCycle.hpp:26
Requires Phoenix Pro; Request PID to target velocity with torque current feedforward.
Definition VelocityTorqueCurrentFOC.hpp:27
Request PID to target velocity with voltage feedforward.
Definition VelocityVoltage.hpp:26
Request a specified voltage.
Definition VoltageOut.hpp:24
Class for CANcoder, a CAN based magnetic encoder that provides absolute and relative position along w...
Definition CANcoder.hpp:32
Class for CTR Electronics' CANdi™ branded device, a device that integrates digital signals into the e...
Definition CANdi.hpp:32
Class description for the Pigeon 2 IMU sensor that measures orientation.
Definition Pigeon2.hpp:34
Manages control of a two-axis differential mechanism.
Definition DifferentialMechanism.hpp:51
ctre::phoenix::StatusCode SetControl(controls::PositionVoltage AverageRequest, controls::PositionVoltage 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::VelocityVoltage AverageRequest, controls::VoltageOut DifferentialRequest)
Sets the control request for this mechanism.
ctre::phoenix::StatusCode SetControl(controls::PositionVoltage AverageRequest, controls::VoltageOut DifferentialRequest)
Sets the control request for this mechanism.
ctre::phoenix::StatusCode SetControl(controls::DutyCycleOut AverageRequest, controls::DutyCycleOut DifferentialRequest)
Sets the control request for this mechanism.
ctre::phoenix::StatusCode SetControl(controls::MotionMagicVelocityVoltage AverageRequest, controls::VoltageOut 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.
StatusSignal< double > & GetDifferentialClosedLoopReference(bool refresh=true)
Value that the differential closed loop is targeting.
Definition DifferentialMechanism.hpp:406
DisabledReasonValue
Possible reasons for the mechanism to disable.
Definition DifferentialMechanism.hpp:56
@ RemoteSensorPosOverflow
A remote sensor position has overflowed.
@ MissingDifferentialFX
The remote Talon FX used for differential control is not present on CAN Bus.
@ MissingRemoteSensor
A remote sensor is not present on CAN Bus.
DifferentialMechanism(DifferentialMotorConstants< typename MotorT::Configuration > const &constants)
Creates a new differential mechanism using two hardware::traits::CommonTalon devices.
ctre::phoenix::StatusCode SetControl(controls::DutyCycleOut AverageRequest, controls::VelocityDutyCycle DifferentialRequest)
Sets the control request for this mechanism.
RequiresUserReasonValue GetRequiresUserReason() const
Definition DifferentialMechanism.hpp:267
ctre::phoenix::StatusCode SetControl(controls::VoltageOut AverageRequest, controls::PositionVoltage DifferentialRequest)
Sets the control request for this mechanism.
ctre::phoenix::StatusCode SetControl(controls::MotionMagicExpoVoltage AverageRequest, controls::PositionVoltage DifferentialRequest)
Sets the control request for this mechanism.
void ClearUserRequirement()
Indicate to the mechanism that the user has performed the required action to resume mechanism control...
ctre::phoenix::StatusCode SetControl(controls::VoltageOut AverageRequest, controls::VelocityVoltage 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 ConfigNeutralMode(signals::NeutralModeValue neutralMode, units::second_t timeoutSeconds=100_ms)
Configures the neutral mode to use for both motors in the mechanism.
ctre::phoenix::StatusCode SetControl(controls::MotionMagicExpoVoltage AverageRequest, controls::VoltageOut DifferentialRequest)
Sets the control request for this mechanism.
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.
Definition DifferentialMechanism.hpp:456
ctre::phoenix::StatusCode SetControl(controls::MotionMagicExpoTorqueCurrentFOC AverageRequest, controls::PositionTorqueCurrentFOC 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::MotionMagicVelocityDutyCycle AverageRequest, controls::VelocityDutyCycle 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:217
ctre::phoenix::StatusCode SetControl(controls::TorqueCurrentFOC AverageRequest, controls::TorqueCurrentFOC DifferentialRequest)
Sets the control request for this mechanism.
ctre::phoenix::StatusCode SetControl(controls::PositionTorqueCurrentFOC AverageRequest, controls::TorqueCurrentFOC 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::MotionMagicTorqueCurrentFOC AverageRequest, controls::VelocityTorqueCurrentFOC DifferentialRequest)
Sets the control request for this mechanism.
DisabledReasonValue GetDisabledReason() const
Definition DifferentialMechanism.hpp:259
MotorT const & GetFollower() const
Get the Talon FX that is differential follower.
Definition DifferentialMechanism.hpp:511
ctre::phoenix::StatusCode SetControl(controls::MotionMagicVelocityDutyCycle AverageRequest, controls::DutyCycleOut DifferentialRequest)
Sets the control request for this mechanism.
ctre::phoenix::StatusCode SetControl(controls::MotionMagicExpoTorqueCurrentFOC AverageRequest, controls::TorqueCurrentFOC DifferentialRequest)
Sets the control request for this mechanism.
ctre::phoenix::StatusCode SetNeutralOut()
Request neutral output of mechanism.
ctre::phoenix::StatusCode SetControl(controls::PositionTorqueCurrentFOC AverageRequest, controls::VelocityTorqueCurrentFOC DifferentialRequest)
Sets the control request for this mechanism.
ctre::phoenix::StatusCode SetControl(controls::MotionMagicVelocityDutyCycle AverageRequest, controls::PositionDutyCycle 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.
StatusSignal< double > & GetDifferentialClosedLoopReferenceSlope(bool refresh=true)
Derivative of the target that the differential closed loop is targeting.
Definition DifferentialMechanism.hpp:426
ctre::phoenix::StatusCode SetControl(controls::VelocityTorqueCurrentFOC AverageRequest, controls::TorqueCurrentFOC 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::MotionMagicVelocityTorqueCurrentFOC AverageRequest, controls::PositionTorqueCurrentFOC 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.
MechanismState GetMechanismState() const
Gets the state of the mechanism.
Definition DifferentialMechanism.hpp:239
ctre::phoenix::StatusCode SetControl(controls::PositionDutyCycle AverageRequest, controls::PositionDutyCycle DifferentialRequest)
Sets the control request for this mechanism.
ctre::phoenix::StatusCode SetControl(controls::MotionMagicVelocityVoltage AverageRequest, controls::VelocityVoltage DifferentialRequest)
Sets the control request for this mechanism.
ctre::phoenix::StatusCode SetControl(controls::MotionMagicVelocityVoltage AverageRequest, controls::PositionVoltage DifferentialRequest)
Sets the control request for this mechanism.
ctre::phoenix::StatusCode SetControl(controls::MotionMagicVelocityTorqueCurrentFOC AverageRequest, controls::VelocityTorqueCurrentFOC DifferentialRequest)
Sets the control request for this mechanism.
ctre::phoenix::StatusCode SetControl(controls::MotionMagicVoltage AverageRequest, controls::VoltageOut DifferentialRequest)
Sets the control request for this mechanism.
void Periodic()
Call this method periodically to automatically protect against dangerous fault conditions and keep Ge...
StatusSignal< units::turns_per_second_t > & GetDifferentialVelocity(bool refresh=true)
Differential component of the mechanism velocity.
Definition DifferentialMechanism.hpp:339
ctre::phoenix::StatusCode SetControl(controls::PositionDutyCycle AverageRequest, controls::VelocityDutyCycle 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::VelocityDutyCycle AverageRequest, controls::DutyCycleOut DifferentialRequest)
Sets the control request for this mechanism.
StatusSignal< double > & GetAverageClosedLoopReference(bool refresh=true)
Value that the average closed loop is targeting.
Definition DifferentialMechanism.hpp:355
RequiresUserReasonValue
Possible reasons for the mechanism to require user action to resume control.
Definition DifferentialMechanism.hpp:88
ctre::phoenix::StatusCode SetControl(controls::MotionMagicExpoDutyCycle AverageRequest, controls::VelocityDutyCycle 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.
StatusSignal< units::turn_t > & GetDifferentialPosition(bool refresh=true)
Differential component of the mechanism position.
Definition DifferentialMechanism.hpp:321
ctre::phoenix::StatusCode SetControl(controls::MotionMagicTorqueCurrentFOC AverageRequest, controls::TorqueCurrentFOC DifferentialRequest)
Sets the control request for this mechanism.
MotorT & GetFollower()
Get the Talon FX that is differential follower.
Definition DifferentialMechanism.hpp:500
ctre::phoenix::StatusCode SetCoastOut()
Request coast neutral output of mechanism.
ctre::phoenix::StatusCode SetControl(controls::VelocityVoltage AverageRequest, controls::VelocityVoltage DifferentialRequest)
Sets the control request for this mechanism.
ctre::phoenix::StatusCode SetControl(controls::PositionDutyCycle AverageRequest, controls::DutyCycleOut 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::MotionMagicExpoDutyCycle AverageRequest, controls::PositionDutyCycle DifferentialRequest)
Sets the control request for this mechanism.
StatusSignal< units::turns_per_second_t > & GetAverageVelocity(bool refresh=true)
Average component of the mechanism velocity.
Definition DifferentialMechanism.hpp:303
DifferentialMechanism(DifferentialMotorConstants< typename MotorT::Configuration > const &constants, hardware::CANcoder &cancoder)
Creates a new differential mechanism using two hardware::traits::CommonTalon devices and a hardware::...
bool RequiresUserAction() const
Get whether the mechanism is currently disabled and requires user action to re-enable mechanism contr...
Definition DifferentialMechanism.hpp:229
ctre::phoenix::StatusCode SetControl(controls::VelocityTorqueCurrentFOC AverageRequest, controls::VelocityTorqueCurrentFOC 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.
DifferentialMechanism(DifferentialMotorConstants< typename MotorT::Configuration > const &constants, hardware::Pigeon2 &pigeon2, DifferentialPigeon2Source pigeonSource)
Creates a new differential mechanism using two hardware::traits::CommonTalon devices and a hardware::...
ctre::phoenix::StatusCode SetControl(controls::MotionMagicVelocityTorqueCurrentFOC AverageRequest, controls::TorqueCurrentFOC 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.
DifferentialMechanism(DifferentialMotorConstants< typename MotorT::Configuration > const &constants, hardware::CANdi &candi, DifferentialCANdiSource candiSource)
Creates a new differential mechanism using two hardware::traits::CommonTalon devices and a hardware::...
MotorT & GetLeader()
Get the Talon FX that is differential leader.
Definition DifferentialMechanism.hpp:476
MotorT const & GetLeader() const
Get the Talon FX that is differential leader.
Definition DifferentialMechanism.hpp:488
StatusSignal< units::turn_t > & GetAveragePosition(bool refresh=true)
Average component of the mechanism position.
Definition DifferentialMechanism.hpp:285
ctre::phoenix::StatusCode SetControl(controls::MotionMagicDutyCycle AverageRequest, controls::VelocityDutyCycle DifferentialRequest)
Sets the control request for this mechanism.
ctre::phoenix::StatusCode SetControl(controls::MotionMagicExpoTorqueCurrentFOC AverageRequest, controls::VelocityTorqueCurrentFOC DifferentialRequest)
Sets the control request for this mechanism.
StatusSignal< double > & GetAverageClosedLoopReferenceSlope(bool refresh=true)
Derivative of the target that the average closed loop is targeting.
Definition DifferentialMechanism.hpp:373
ctre::phoenix::StatusCode SetControl(controls::VelocityDutyCycle AverageRequest, controls::VelocityDutyCycle DifferentialRequest)
Sets the control request for this mechanism.
ctre::phoenix::StatusCode SetControl(controls::MotionMagicExpoDutyCycle AverageRequest, controls::DutyCycleOut DifferentialRequest)
Sets the control request for this mechanism.
ctre::phoenix::StatusCode SetControl(controls::MotionMagicExpoVoltage AverageRequest, controls::VelocityVoltage DifferentialRequest)
Sets the control request for this mechanism.
StatusSignal< double > & GetDifferentialClosedLoopError(bool refresh=true)
The difference between target differential reference and current measurement.
Definition DifferentialMechanism.hpp:443
StatusSignal< double > & GetAverageClosedLoopError(bool refresh=true)
The difference between target average reference and current measurement.
Definition DifferentialMechanism.hpp:390
ctre::phoenix::StatusCode SetControl(controls::MotionMagicDutyCycle AverageRequest, controls::DutyCycleOut DifferentialRequest)
Sets the control request for this mechanism.
ctre::phoenix::StatusCode SetControl(controls::VoltageOut AverageRequest, controls::VoltageOut DifferentialRequest)
Sets the control request for this mechanism.
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:858
DifferentialPigeon2Source
Sensor sources for a differential Pigeon 2.
Definition DifferentialConstants.hpp:19
DifferentialCANdiSource
Sensor sources for a differential CTR Electronics' CANdi™ branded device.
Definition DifferentialConstants.hpp:38
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.
@ CANcoder
Definition FrcUsageReport.hpp:23
@ Pigeon2
Definition FrcUsageReport.hpp:27
@ CANdi
Definition FrcUsageReport.hpp:29
Definition motor_constants.h:14
All constants for setting up the motors of a differential mechanism.
Definition DifferentialConstants.hpp:57
The state of the motor controller bridge when output is neutral or disabled.
Definition SpnEnums.hpp:1603