CTRE Phoenix 6 C++ 26.70.0-alpha-2
Loading...
Searching...
No Matches
SwerveModule.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
10
11namespace ctre {
12namespace phoenix6 {
13
14/* forward decls */
15namespace hardware {
16 class CANcoder;
17 class CANdi;
18 class TalonFX;
19 class TalonFXS;
20}
21namespace configs {
26}
27
28namespace swerve {
29
32
33/**
34 * \brief Swerve Module class that encapsulates a swerve module powered by
35 * CTR Electronics devices.
36 *
37 * This class handles the hardware devices and configures them for
38 * swerve module operation using the Phoenix 6 API.
39 *
40 * This class constructs hardware devices internally, so the user
41 * only specifies the constants (IDs, PID gains, gear ratios, etc).
42 * Getters for these hardware devices are available.
43 *
44 * \tparam DriveMotorT Type of the drive motor
45 * \tparam SteerMotorT Type of the steer motor
46 * \tparam EncoderT Type of the steer encoder
47 */
48template <
49 std::derived_from<hardware::traits::CommonTalon> DriveMotorT,
50 std::derived_from<hardware::traits::CommonTalon> SteerMotorT,
51 typename EncoderT
52>
53 requires std::same_as<EncoderT, hardware::CANcoder> ||
54 std::same_as<EncoderT, hardware::CANdi> ||
55 std::same_as<EncoderT, hardware::TalonFXS>
57public:
58 /**
59 * \brief Contains everything the swerve module needs to apply a request.
60 */
62
63 /**
64 * \brief All constants for a swerve module.
65 */
67
68protected:
69 /** \brief Number of times to attempt config applies. */
70 static constexpr int kNumConfigAttempts = 2;
71
72 /** \brief The underlying swerve module instance. */
74
75private:
76 DriveMotorT _driveMotor;
77 SteerMotorT _steerMotor;
78 EncoderT _encoder;
79
80public:
81 /**
82 * \brief Construct a SwerveModule with the specified constants.
83 *
84 * \param constants Constants used to construct the module
85 * \param canbus The CAN bus this module is on
86 * \param module The impl#SwerveModuleImpl to use
87 */
88 SwerveModule(Constants const &constants, CANBus canbus, impl::SwerveModuleImpl &module) :
89 _module{&module},
90 _driveMotor{constants.DriveMotorId, canbus},
91 _steerMotor{constants.SteerMotorId, canbus},
92 _encoder{constants.EncoderId, canbus}
93 {
95
96 typename DriveMotorT::Configuration driveConfigs = constants.DriveMotorInitialConfigs;
97 driveConfigs.MotorOutput.NeutralMode = signals::NeutralModeValue::Brake;
98
99 driveConfigs.Slot0 = constants.DriveMotorGains;
100 if constexpr (!std::same_as<configs::TalonFXSConfiguration, decltype(driveConfigs)>) {
101 driveConfigs.TorqueCurrent.PeakForwardTorqueCurrent = constants.SlipCurrent;
102 driveConfigs.TorqueCurrent.PeakReverseTorqueCurrent = -constants.SlipCurrent;
103 }
104 driveConfigs.CurrentLimits.StatorCurrentLimit = constants.SlipCurrent;
105 driveConfigs.CurrentLimits.StatorCurrentLimitEnable = true;
106
107 if constexpr (std::same_as<configs::TalonFXSConfiguration, decltype(driveConfigs)>) {
108 driveConfigs.ExternalFeedback.RotorToSensorRatio = 1.0;
109 driveConfigs.ExternalFeedback.SensorToMechanismRatio = 1.0;
110
111 switch (constants.DriveMotorType) {
113 printf(
114 "Cannot use TalonFX_Integrated drive motor type on Talon FXS ID %d. TalonFX_Integrated is only supported on Talon FX.",
115 GetDriveMotor().GetDeviceID()
116 );
117 break;
118
120 driveConfigs.Commutation.MotorArrangement = signals::MotorArrangementValue::NEO_JST;
121 break;
123 driveConfigs.Commutation.MotorArrangement = signals::MotorArrangementValue::VORTEX_JST;
124 break;
125 }
126 } else {
127 driveConfigs.Feedback.RotorToSensorRatio = 1.0;
128 driveConfigs.Feedback.SensorToMechanismRatio = 1.0;
129
131 printf("Drive motor Talon FX ID %d only supports TalonFX_Integrated.", GetDriveMotor().GetDeviceID());
132 }
133 }
134
135 driveConfigs.MotorOutput.Inverted = constants.DriveMotorInverted
138 for (int i = 0; i < kNumConfigAttempts; ++i) {
139 response = GetDriveMotor().GetConfigurator().Apply(driveConfigs);
140 if (response.IsOK()) break;
141 }
142 if (!response.IsOK()) {
143 printf("Talon ID %d failed config with error %s\n", GetDriveMotor().GetDeviceID(), response.GetName());
144 }
145
146 typename SteerMotorT::Configuration steerConfigs = constants.SteerMotorInitialConfigs;
147 steerConfigs.MotorOutput.NeutralMode = signals::NeutralModeValue::Brake;
148
149 steerConfigs.Slot0 = constants.SteerMotorGains;
150
151 if constexpr (std::same_as<configs::TalonFXSConfiguration, decltype(steerConfigs)>) {
152 switch (constants.SteerMotorType) {
154 printf(
155 "Cannot use TalonFX_Integrated steer motor type on Talon FXS ID %d. TalonFX_Integrated is only supported on Talon FX.",
156 GetSteerMotor().GetDeviceID()
157 );
158 break;
159
161 steerConfigs.Commutation.MotorArrangement = signals::MotorArrangementValue::Minion_JST;
162 break;
164 steerConfigs.Commutation.MotorArrangement = signals::MotorArrangementValue::NEO_JST;
165 break;
167 steerConfigs.Commutation.MotorArrangement = signals::MotorArrangementValue::VORTEX_JST;
168 break;
170 steerConfigs.Commutation.MotorArrangement = signals::MotorArrangementValue::NEO550_JST;
171 break;
173 steerConfigs.Commutation.MotorArrangement = signals::MotorArrangementValue::Brushed_DC;
174 steerConfigs.Commutation.BrushedMotorWiring = signals::BrushedMotorWiringValue::Leads_A_and_B;
175 break;
177 steerConfigs.Commutation.MotorArrangement = signals::MotorArrangementValue::Brushed_DC;
178 steerConfigs.Commutation.BrushedMotorWiring = signals::BrushedMotorWiringValue::Leads_A_and_C;
179 break;
181 steerConfigs.Commutation.MotorArrangement = signals::MotorArrangementValue::Brushed_DC;
182 steerConfigs.Commutation.BrushedMotorWiring = signals::BrushedMotorWiringValue::Leads_B_and_C;
183 break;
184 }
185
186 /* Modify configuration to use remote encoder setting */
187 steerConfigs.ExternalFeedback.FeedbackRemoteSensorID = constants.EncoderId;
188 switch (constants.FeedbackSource) {
190 steerConfigs.ExternalFeedback.ExternalFeedbackSensorSource = signals::ExternalFeedbackSensorSourceValue::FusedCANcoder;
191 break;
193 steerConfigs.ExternalFeedback.ExternalFeedbackSensorSource = signals::ExternalFeedbackSensorSourceValue::SyncCANcoder;
194 break;
196 steerConfigs.ExternalFeedback.ExternalFeedbackSensorSource = signals::ExternalFeedbackSensorSourceValue::RemoteCANcoder;
197 break;
198
200 steerConfigs.ExternalFeedback.ExternalFeedbackSensorSource = signals::ExternalFeedbackSensorSourceValue::FusedCANdiPWM1;
201 break;
203 steerConfigs.ExternalFeedback.ExternalFeedbackSensorSource = signals::ExternalFeedbackSensorSourceValue::FusedCANdiPWM2;
204 break;
206 steerConfigs.ExternalFeedback.ExternalFeedbackSensorSource = signals::ExternalFeedbackSensorSourceValue::SyncCANdiPWM1;
207 break;
209 steerConfigs.ExternalFeedback.ExternalFeedbackSensorSource = signals::ExternalFeedbackSensorSourceValue::SyncCANdiPWM2;
210 break;
212 steerConfigs.ExternalFeedback.ExternalFeedbackSensorSource = signals::ExternalFeedbackSensorSourceValue::RemoteCANdiPWM1;
213 break;
215 steerConfigs.ExternalFeedback.ExternalFeedbackSensorSource = signals::ExternalFeedbackSensorSourceValue::RemoteCANdiPWM2;
216 break;
217
219 steerConfigs.ExternalFeedback.ExternalFeedbackSensorSource = signals::ExternalFeedbackSensorSourceValue::PulseWidth;
220 steerConfigs.ExternalFeedback.AbsoluteSensorOffset = constants.EncoderOffset;
221 steerConfigs.ExternalFeedback.SensorPhase = constants.EncoderInverted
224 break;
225 }
226 steerConfigs.ExternalFeedback.RotorToSensorRatio = constants.SteerMotorGearRatio;
227 steerConfigs.ExternalFeedback.SensorToMechanismRatio = 1.0;
228 } else {
230 printf("Steer motor Talon FX ID %d only supports TalonFX_Integrated.", GetSteerMotor().GetDeviceID());
231 }
232
233 /* Modify configuration to use remote encoder setting */
234 steerConfigs.Feedback.FeedbackRemoteSensorID = constants.EncoderId;
235 switch (constants.FeedbackSource) {
237 steerConfigs.Feedback.FeedbackSensorSource = signals::FeedbackSensorSourceValue::FusedCANcoder;
238 break;
240 steerConfigs.Feedback.FeedbackSensorSource = signals::FeedbackSensorSourceValue::SyncCANcoder;
241 break;
243 steerConfigs.Feedback.FeedbackSensorSource = signals::FeedbackSensorSourceValue::RemoteCANcoder;
244 break;
245
247 steerConfigs.Feedback.FeedbackSensorSource = signals::FeedbackSensorSourceValue::FusedCANdiPWM1;
248 break;
250 steerConfigs.Feedback.FeedbackSensorSource = signals::FeedbackSensorSourceValue::FusedCANdiPWM2;
251 break;
253 steerConfigs.Feedback.FeedbackSensorSource = signals::FeedbackSensorSourceValue::SyncCANdiPWM1;
254 break;
256 steerConfigs.Feedback.FeedbackSensorSource = signals::FeedbackSensorSourceValue::SyncCANdiPWM2;
257 break;
259 steerConfigs.Feedback.FeedbackSensorSource = signals::FeedbackSensorSourceValue::RemoteCANdiPWM1;
260 break;
262 steerConfigs.Feedback.FeedbackSensorSource = signals::FeedbackSensorSourceValue::RemoteCANdiPWM2;
263 break;
264
266 printf(
267 "Cannot use Pulse Width steer feedback type on Talon FX ID %d. Pulse Width is only supported on Talon FXS.\n",
268 GetSteerMotor().GetDeviceID()
269 );
270 break;
271 }
272 steerConfigs.Feedback.RotorToSensorRatio = constants.SteerMotorGearRatio;
273 steerConfigs.Feedback.SensorToMechanismRatio = 1.0;
274 }
275
276 steerConfigs.MotionMagic.MotionMagicExpo_kV = 0.12_V / 1_tps * constants.SteerMotorGearRatio;
277 steerConfigs.MotionMagic.MotionMagicExpo_kA = 1.2_V / 1_tr_per_s_sq / constants.SteerMotorGearRatio;
278
279 steerConfigs.ClosedLoopGeneral.ContinuousWrap = true; // Enable continuous wrap for swerve modules
280
281 steerConfigs.MotorOutput.Inverted = constants.SteerMotorInverted
284 for (int i = 0; i < kNumConfigAttempts; ++i) {
285 response = GetSteerMotor().GetConfigurator().Apply(steerConfigs);
286 if (response.IsOK()) break;
287 }
288 if (!response.IsOK()) {
289 printf("Talon ID %d failed config with error %s\n", GetSteerMotor().GetDeviceID(), response.GetName());
290 }
291
292 typename EncoderT::Configuration encoderConfigs = constants.EncoderInitialConfigs;
293 if constexpr (std::same_as<configs::CANcoderConfiguration, decltype(encoderConfigs)>) {
294 encoderConfigs.MagnetSensor.MagnetOffset = constants.EncoderOffset;
295 encoderConfigs.MagnetSensor.SensorDirection = constants.EncoderInverted
298
299 for (int i = 0; i < kNumConfigAttempts; ++i) {
300 response = GetEncoder().GetConfigurator().Apply(encoderConfigs);
301 if (response.IsOK()) break;
302 }
303 if (!response.IsOK()) {
304 printf("Encoder ID %d failed config with error %s\n", GetEncoder().GetDeviceID(), response.GetName());
305 }
306 } else if constexpr (std::same_as<configs::CANdiConfiguration, decltype(encoderConfigs)>) {
307 for (int i = 0; i < kNumConfigAttempts; ++i) {
308 response = GetEncoder().GetConfigurator().Apply(encoderConfigs.DigitalInputs);
309 if (response.IsOK()) break;
310 }
311 if (!response.IsOK()) {
312 printf("Encoder ID %d failed config with error %s\n", GetEncoder().GetDeviceID(), response.GetName());
313 }
314
315 for (int i = 0; i < kNumConfigAttempts; ++i) {
316 response = GetEncoder().GetConfigurator().Apply(encoderConfigs.CustomParams);
317 if (response.IsOK()) break;
318 }
319 if (!response.IsOK()) {
320 printf("Encoder ID %d failed config with error %s\n", GetEncoder().GetDeviceID(), response.GetName());
321 }
322
323 switch (constants.FeedbackSource) {
327 encoderConfigs.PWM1.AbsoluteSensorOffset = constants.EncoderOffset;
328 encoderConfigs.PWM1.SensorDirection = constants.EncoderInverted;
329
330 for (int i = 0; i < kNumConfigAttempts; ++i) {
331 response = GetEncoder().GetConfigurator().Apply(encoderConfigs.PWM1);
332 if (response.IsOK()) break;
333 }
334 if (!response.IsOK()) {
335 printf("Encoder ID %d failed config with error %s\n", GetEncoder().GetDeviceID(), response.GetName());
336 }
337 break;
338
342 encoderConfigs.PWM2.AbsoluteSensorOffset = constants.EncoderOffset;
343 encoderConfigs.PWM2.SensorDirection = constants.EncoderInverted;
344
345 for (int i = 0; i < kNumConfigAttempts; ++i) {
346 response = GetEncoder().GetConfigurator().Apply(encoderConfigs.PWM2);
347 if (response.IsOK()) break;
348 }
349 if (!response.IsOK()) {
350 printf("Encoder ID %d failed config with error %s\n", GetEncoder().GetDeviceID(), response.GetName());
351 }
352 break;
353
354 default:
355 break;
356 }
357 }
358 }
359
360 virtual ~SwerveModule() = default;
361
362 /**
363 * \brief Applies the desired ModuleRequest to this module.
364 *
365 * \param moduleRequest The request to apply to this module
366 */
367 virtual void Apply(ModuleRequest const &moduleRequest)
368 {
369 return _module->Apply(moduleRequest);
370 }
371
372 /**
373 * \brief Controls this module using the specified drive and steer control requests.
374 *
375 * This is intended only to be used for characterization of the robot; do not use this for normal use.
376 *
377 * \param driveRequest The control request to apply to the drive motor
378 * \param steerRequest The control request to apply to the steer motor
379 */
380 template <
381 std::derived_from<controls::ControlRequest> DriveReq,
382 std::derived_from<controls::ControlRequest> SteerReq
383 >
384 void Apply(DriveReq &&driveRequest, SteerReq &&steerRequest)
385 {
386 return _module->Apply(std::forward<DriveReq>(driveRequest), std::forward<SteerReq>(steerRequest));
387 }
388
389 /**
390 * \brief Gets the state of this module and passes it back as a
391 * SwerveModulePosition object with latency compensated values.
392 *
393 * This function is blocking when it performs a refresh.
394 *
395 * \param refresh True if the signals should be refreshed
396 * \returns SwerveModulePosition containing this module's state.
397 */
398 SwerveModulePosition GetPosition(bool refresh)
399 {
400 return _module->GetPosition(refresh);
401 }
402
403 /**
404 * \brief Gets the last cached swerve module position.
405 * This differs from #GetPosition in that it will not
406 * perform any latency compensation or refresh the signals.
407 *
408 * \returns Last cached SwerveModulePosition
409 */
410 SwerveModulePosition GetCachedPosition() const
411 {
412 return _module->GetCachedPosition();
413 }
414
415 /**
416 * \brief Get the current velocity of the module.
417 *
418 * This is typically used for telemetry, as the SwerveModulePosition
419 * is used for odometry.
420 *
421 * \returns Current velocity of the module
422 */
423 SwerveModuleVelocity GetCurrentVelocity() const
424 {
425 return _module->GetCurrentVelocity();
426 }
427
428 /**
429 * \brief Get the target velocity of the module.
430 *
431 * This is typically used for telemetry.
432 *
433 * \returns Target velocity of the module
434 */
435 SwerveModuleVelocity GetTargetVelocity() const
436 {
437 return _module->GetTargetVelocity();
438 }
439
440 /**
441 * \brief Resets this module's drive motor position to 0 rotations.
442 */
443 virtual void ResetPosition()
444 {
445 return _module->ResetPosition();
446 }
447
448 /**
449 * \brief Gets the closed-loop output type to use for the drive motor.
450 *
451 * \returns Drive motor closed-loop output type
452 */
454 {
455 return _module->GetDriveClosedLoopOutputType();
456 }
457
458 /**
459 * \brief Gets the closed-loop output type to use for the steer motor.
460 *
461 * \returns Steer motor closed-loop output type
462 */
464 {
465 return _module->GetSteerClosedLoopOutputType();
466 }
467
468 /**
469 * \brief Gets this module's Drive Motor reference.
470 *
471 * This should be used only to access signals and change configurations that the
472 * swerve drivetrain does not configure itself.
473 *
474 * \returns This module's Drive Motor reference
475 */
476 DriveMotorT &GetDriveMotor()
477 {
478 return _driveMotor;
479 }
480 /**
481 * \brief Gets this module's Drive Motor reference.
482 *
483 * This should be used only to access signals and change configurations that the
484 * swerve drivetrain does not configure itself.
485 *
486 * \returns This module's Drive Motor reference
487 */
488 DriveMotorT const &GetDriveMotor() const
489 {
490 return _driveMotor;
491 }
492
493 /**
494 * \brief Gets this module's Steer Motor reference.
495 *
496 * This should be used only to access signals and change configurations that the
497 * swerve drivetrain does not configure itself.
498 *
499 * \returns This module's Steer Motor reference
500 */
501 SteerMotorT &GetSteerMotor()
502 {
503 return _steerMotor;
504 }
505 /**
506 * \brief Gets this module's Steer Motor reference.
507 *
508 * This should be used only to access signals and change configurations that the
509 * swerve drivetrain does not configure itself.
510 *
511 * \returns This module's Steer Motor reference
512 */
513 SteerMotorT const &GetSteerMotor() const
514 {
515 return _steerMotor;
516 }
517
518 /**
519 * \brief Gets this module's azimuth encoder reference.
520 *
521 * This should be used only to access signals and change configurations that the
522 * swerve drivetrain does not configure itself.
523 *
524 * \returns This module's azimuth encoder reference
525 */
526 EncoderT &GetEncoder()
527 {
528 return _encoder;
529 }
530 /**
531 * \brief Gets this module's azimuth encoder reference.
532 *
533 * This should be used only to access signals and change configurations that the
534 * swerve drivetrain does not configure itself.
535 *
536 * \returns This module's azimuth encoder reference
537 */
538 EncoderT const &GetEncoder() const
539 {
540 return _encoder;
541 }
542};
543
544}
545}
546}
Class for getting information about an available CAN bus.
Definition CANBus.hpp:142
All configurations for the hardware::CANcoder.
Definition CoreCANcoder.hpp:37
All configurations for the hardware::CANdi.
Definition CoreCANdi.hpp:42
All configurations for the hardware::TalonFX.
Definition CoreTalonFX.hpp:156
All configurations for the hardware::TalonFXS.
Definition CoreTalonFXS.hpp:131
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 Talon FX integrated motor controller.
Definition TalonFX.hpp:27
Class description for the Talon FXS motor controller.
Definition TalonFXS.hpp:27
impl::SwerveModuleImpl::ModuleRequest ModuleRequest
Contains everything the swerve module needs to apply a request.
Definition SwerveModule.hpp:61
virtual void Apply(ModuleRequest const &moduleRequest)
Applies the desired ModuleRequest to this module.
Definition SwerveModule.hpp:367
SwerveModulePosition GetCachedPosition() const
Gets the last cached swerve module position.
Definition SwerveModule.hpp:410
SteerMotorT & GetSteerMotor()
Gets this module's Steer Motor reference.
Definition SwerveModule.hpp:501
ClosedLoopOutputType GetSteerClosedLoopOutputType() const
Gets the closed-loop output type to use for the steer motor.
Definition SwerveModule.hpp:463
impl::SwerveModuleImpl * _module
The underlying swerve module instance.
Definition SwerveModule.hpp:73
SwerveModuleConstants< typename DriveMotorT::Configuration, typename SteerMotorT::Configuration, typename EncoderT::Configuration > Constants
All constants for a swerve module.
Definition SwerveModule.hpp:66
SteerMotorT const & GetSteerMotor() const
Gets this module's Steer Motor reference.
Definition SwerveModule.hpp:513
EncoderT const & GetEncoder() const
Gets this module's azimuth encoder reference.
Definition SwerveModule.hpp:538
void Apply(DriveReq &&driveRequest, SteerReq &&steerRequest)
Controls this module using the specified drive and steer control requests.
Definition SwerveModule.hpp:384
SwerveModuleVelocity GetTargetVelocity() const
Get the target velocity of the module.
Definition SwerveModule.hpp:435
ClosedLoopOutputType GetDriveClosedLoopOutputType() const
Gets the closed-loop output type to use for the drive motor.
Definition SwerveModule.hpp:453
EncoderT & GetEncoder()
Gets this module's azimuth encoder reference.
Definition SwerveModule.hpp:526
SwerveModulePosition GetPosition(bool refresh)
Gets the state of this module and passes it back as a SwerveModulePosition object with latency compen...
Definition SwerveModule.hpp:398
DriveMotorT & GetDriveMotor()
Gets this module's Drive Motor reference.
Definition SwerveModule.hpp:476
DriveMotorT const & GetDriveMotor() const
Gets this module's Drive Motor reference.
Definition SwerveModule.hpp:488
SwerveModule(Constants const &constants, CANBus canbus, impl::SwerveModuleImpl &module)
Construct a SwerveModule with the specified constants.
Definition SwerveModule.hpp:88
SwerveModuleVelocity GetCurrentVelocity() const
Get the current velocity of the module.
Definition SwerveModule.hpp:423
virtual void ResetPosition()
Resets this module's drive motor position to 0 rotations.
Definition SwerveModule.hpp:443
static constexpr int kNumConfigAttempts
Number of times to attempt config applies.
Definition SwerveModule.hpp:70
Swerve Module class that encapsulates a swerve module powered by CTR Electronics devices.
Definition SwerveModuleImpl.hpp:61
Status codes reported by APIs, including OK, warnings, and errors.
Definition StatusCodes.h:28
constexpr const char * GetName() const
Gets the name of this StatusCode.
Definition StatusCodes.h:867
constexpr bool IsOK() const
Definition StatusCodes.h:860
Definition ExternalFeedbackConfigs.hpp:21
Definition ExternalFeedbackConfigs.hpp:17
SteerRequestType
All possible control requests for the module steer motor.
Definition SwerveModuleImpl.hpp:25
DriveRequestType
All possible control requests for the module drive motor.
Definition SwerveModuleImpl.hpp:41
Definition SwerveModule.hpp:28
ClosedLoopOutputType
Supported closed-loop output types.
Definition SwerveModuleConstants.hpp:22
@ TalonFXS_Brushed_AC
Brushed motor connected to a Talon FXS on terminals A and C.
Definition SwerveModuleConstants.hpp:77
@ TalonFXS_Brushed_AB
Brushed motor connected to a Talon FXS on terminals A and B.
Definition SwerveModuleConstants.hpp:73
@ TalonFX_Integrated
Talon FX integrated brushless motor.
Definition SwerveModuleConstants.hpp:53
@ TalonFXS_Brushed_BC
Brushed motor connected to a Talon FXS on terminals B and C.
Definition SwerveModuleConstants.hpp:81
@ TalonFXS_NEO550_JST
Third party NEO550 brushless motor connected to a Talon FXS over JST.
Definition SwerveModuleConstants.hpp:69
@ TalonFXS_NEO_JST
Third party NEO brushless motor connected to a Talon FXS over JST.
Definition SwerveModuleConstants.hpp:61
@ TalonFXS_VORTEX_JST
Third party VORTEX brushless motor connected to a Talon FXS over JST.
Definition SwerveModuleConstants.hpp:65
@ TalonFXS_Minion_JST
CTR Electronics Minion® brushless motor connected to a Talon FXS over JST.
Definition SwerveModuleConstants.hpp:57
@ FusedCANcoder
Requires Pro; Use signals::FeedbackSensorSourceValue::FusedCANcoder for the steer motor.
Definition SwerveModuleConstants.hpp:92
@ SyncCANdiPWM2
Requires Pro; Use signals::FeedbackSensorSourceValue::SyncCANdiPWM2 for the steer motor.
Definition SwerveModuleConstants.hpp:122
@ SyncCANdiPWM1
Requires Pro; Use signals::FeedbackSensorSourceValue::SyncCANdiPWM1 for the steer motor.
Definition SwerveModuleConstants.hpp:117
@ RemoteCANdiPWM2
Use signals::FeedbackSensorSourceValue::RemoteCANdiPWM2 for the steer motor.
Definition SwerveModuleConstants.hpp:132
@ FusedCANdiPWM2
Requires Pro; Use signals::FeedbackSensorSourceValue::FusedCANdiPWM2 for the steer motor.
Definition SwerveModuleConstants.hpp:112
@ FusedCANdiPWM1
Requires Pro; Use signals::FeedbackSensorSourceValue::FusedCANdiPWM1 for the steer motor.
Definition SwerveModuleConstants.hpp:107
@ RemoteCANdiPWM1
Use signals::FeedbackSensorSourceValue::RemoteCANdiPWM1 for the steer motor.
Definition SwerveModuleConstants.hpp:127
@ SyncCANcoder
Requires Pro; Use signals::FeedbackSensorSourceValue::SyncCANcoder for the steer motor.
Definition SwerveModuleConstants.hpp:97
@ TalonFXS_PulseWidth
Use signals::ExternalFeedbackSensorSourceValue::PulseWidth for the steer motor.
Definition SwerveModuleConstants.hpp:137
@ RemoteCANcoder
Use signals::FeedbackSensorSourceValue::RemoteCANcoder for the steer motor.
Definition SwerveModuleConstants.hpp:102
@ TalonFX_Integrated
Talon FX integrated brushless motor.
Definition SwerveModuleConstants.hpp:35
@ TalonFXS_NEO_JST
Third party NEO brushless motor connected to a Talon FXS over JST.
Definition SwerveModuleConstants.hpp:39
@ TalonFXS_VORTEX_JST
Third party VORTEX brushless motor connected to a Talon FXS over JST.
Definition SwerveModuleConstants.hpp:43
Definition ExternalFeedbackConfigs.hpp:16
Definition motor_constants.h:14
static constexpr int Leads_A_and_B
Third party brushed DC motor with two leads.
Definition SpnEnums.hpp:3535
static constexpr int Leads_B_and_C
Third party brushed DC motor with two leads.
Definition SpnEnums.hpp:3559
static constexpr int Leads_A_and_C
Third party brushed DC motor with two leads.
Definition SpnEnums.hpp:3547
static constexpr int SyncCANcoder
Requires Phoenix Pro; Talon will synchronize its commutation sensor position against another CANcoder...
Definition SpnEnums.hpp:3176
static constexpr int FusedCANdiPWM2
Requires Phoenix Pro; Talon will fuse a pulse-width encoder remotely attached to the Sensor Input 2 (...
Definition SpnEnums.hpp:3225
static constexpr int SyncCANdiPWM1
Requires Phoenix Pro; Talon will synchronize its internal rotor position against the pulse-width enco...
Definition SpnEnums.hpp:3244
static constexpr int RemoteCANdiPWM1
Use a pulse-width encoder remotely attached to the Sensor Input 1 (S1IN) on CANdi™ (this also require...
Definition SpnEnums.hpp:3194
static constexpr int SyncCANdiPWM2
Requires Phoenix Pro; Talon will synchronize its internal rotor position against the pulse-width enco...
Definition SpnEnums.hpp:3256
static constexpr int RemoteCANcoder
Use another CANcoder on the same CAN bus (this also requires setting FeedbackRemoteSensorID).
Definition SpnEnums.hpp:3135
static constexpr int FusedCANdiPWM1
Requires Phoenix Pro; Talon will fuse a pulse-width encoder remotely attached to the Sensor Input 1 (...
Definition SpnEnums.hpp:3217
static constexpr int FusedCANcoder
Requires Phoenix Pro; Talon will fuse another CANcoder's information with the commutation sensor,...
Definition SpnEnums.hpp:3164
static constexpr int RemoteCANdiPWM2
Use a pulse-width encoder remotely attached to the Sensor Input 2 (S2IN) on CANdi™ (this also require...
Definition SpnEnums.hpp:3202
static constexpr int PulseWidth
Use a pulse-width encoder directly attached to the Talon data port.
Definition SpnEnums.hpp:3186
static constexpr int RemoteCANcoder
Use another CANcoder on the same CAN bus (this also requires setting FeedbackRemoteSensorID).
Definition SpnEnums.hpp:1592
static constexpr int SyncCANdiPWM2
Requires Phoenix Pro; Talon will synchronize its internal rotor position against the pulse-width enco...
Definition SpnEnums.hpp:1704
static constexpr int RemoteCANdiPWM2
Use a pulse-width encoder remotely attached to the Sensor Input 2 (S2IN) on the CTR Electronics' CANd...
Definition SpnEnums.hpp:1649
static constexpr int SyncCANdiPWM1
Requires Phoenix Pro; Talon will synchronize its internal rotor position against the pulse-width enco...
Definition SpnEnums.hpp:1692
static constexpr int SyncCANcoder
Requires Phoenix Pro; Talon will synchronize its internal rotor position against another CANcoder,...
Definition SpnEnums.hpp:1633
static constexpr int RemoteCANdiPWM1
Use a pulse-width encoder remotely attached to the Sensor Input 1 (S1IN) on the CTR Electronics' CANd...
Definition SpnEnums.hpp:1641
static constexpr int FusedCANdiPWM1
Requires Phoenix Pro; Talon will fuse a pulse-width encoder remotely attached to the Sensor Input 1 (...
Definition SpnEnums.hpp:1665
static constexpr int FusedCANcoder
Requires Phoenix Pro; Talon will fuse another CANcoder's information with the internal rotor,...
Definition SpnEnums.hpp:1621
static constexpr int FusedCANdiPWM2
Requires Phoenix Pro; Talon will fuse a pulse-width encoder remotely attached to the Sensor Input 2 (...
Definition SpnEnums.hpp:1673
static constexpr int CounterClockwise_Positive
Positive motor output results in counter-clockwise motion.
Definition SpnEnums.hpp:1455
static constexpr int Clockwise_Positive
Positive motor output results in clockwise motion.
Definition SpnEnums.hpp:1459
static constexpr int NEO_JST
Third party NEO brushless three phase motor (~6000 RPM at 12V).
Definition SpnEnums.hpp:2754
static constexpr int NEO550_JST
Third party NEO550 brushless three phase motor (~11000 RPM at 12V).
Definition SpnEnums.hpp:2766
static constexpr int Brushed_DC
Third party brushed DC motor with two leads.
Definition SpnEnums.hpp:2742
static constexpr int Minion_JST
CTR Electronics Minion® brushless three phase motor.
Definition SpnEnums.hpp:2730
static constexpr int VORTEX_JST
Third party VORTEX brushless three phase motor.
Definition SpnEnums.hpp:2778
static constexpr int Brake
Definition SpnEnums.hpp:1504
static constexpr int CounterClockwise_Positive
Counter-clockwise motion reports positive rotation.
Definition SpnEnums.hpp:190
static constexpr int Clockwise_Positive
Clockwise motion reports positive rotation.
Definition SpnEnums.hpp:194
static constexpr int Aligned
The sensor direction is normally aligned with the motor.
Definition SpnEnums.hpp:3328
static constexpr int Opposed
The sensor direction is normally opposed to the motor.
Definition SpnEnums.hpp:3332
All constants for a swerve module.
Definition SwerveModuleConstants.hpp:152
bool DriveMotorInverted
True if the drive motor is inverted.
Definition SwerveModuleConstants.hpp:184
wpi::units::scalar_t SteerMotorGearRatio
Gear ratio between the steer motor and the azimuth encoder.
Definition SwerveModuleConstants.hpp:205
SteerMotorArrangement SteerMotorType
Choose the motor used for the steer motor.
Definition SwerveModuleConstants.hpp:270
DriveMotorConfigsT DriveMotorInitialConfigs
The initial configs used to configure the drive motor of the swerve module.
Definition SwerveModuleConstants.hpp:306
configs::Slot0Configs DriveMotorGains
The drive motor closed-loop gains.
Definition SwerveModuleConstants.hpp:235
wpi::units::ampere_t SlipCurrent
The maximum amount of stator current the drive motors can apply without slippage.
Definition SwerveModuleConstants.hpp:248
configs::Slot0Configs SteerMotorGains
The steer motor closed-loop gains.
Definition SwerveModuleConstants.hpp:226
SteerFeedbackType FeedbackSource
Choose how the feedback sensors should be configured.
Definition SwerveModuleConstants.hpp:283
int EncoderId
CAN ID of the absolute encoder used for azimuth.
Definition SwerveModuleConstants.hpp:166
DriveMotorArrangement DriveMotorType
Choose the motor used for the drive motor.
Definition SwerveModuleConstants.hpp:263
bool EncoderInverted
True if the azimuth encoder is inverted from the azimuth.
Definition SwerveModuleConstants.hpp:196
SteerMotorConfigsT SteerMotorInitialConfigs
The initial configs used to configure the steer motor of the swerve module.
Definition SwerveModuleConstants.hpp:330
EncoderConfigsT EncoderInitialConfigs
The initial configs used to configure the azimuth encoder of the swerve module.
Definition SwerveModuleConstants.hpp:346
wpi::units::turn_t EncoderOffset
Offset of the azimuth encoder.
Definition SwerveModuleConstants.hpp:170
bool SteerMotorInverted
True if the steer motor is inverted from the azimuth.
Definition SwerveModuleConstants.hpp:190
Contains everything the swerve module needs to apply a request.
Definition SwerveModuleImpl.hpp:66