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