CTRE Phoenix 6 C++ 24.50.0-alpha-2
SwerveModuleConstants.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
11
12#include <units/length.h>
13#include <units/moment_of_inertia.h>
14#include <units/velocity.h>
15
16namespace ctre {
17namespace phoenix6 {
18namespace swerve {
19
20/**
21 * \brief Supported closed-loop output types.
22 */
24 Voltage = 0,
25 /** \brief Requires Pro */
27};
28
29/**
30 * \brief Supported feedback sensors for the steer motors.
31 */
33 /**
34 * \brief Requires Pro; Use signals#FeedbackSensorSourceValue#FusedCANcoder
35 * for the steer motor.
36 */
37 FusedCANcoder = 0,
38 /**
39 * \brief Requires Pro; Use signals#FeedbackSensorSourceValue#SyncCANcoder
40 * for the steer motor.
41 */
42 SyncCANcoder = 1,
43 /**
44 * \brief Use signals#FeedbackSensorSourceValue#RemoteCANcoder
45 * for the steer motor.
46 */
48};
49
50/**
51 * \brief All constants for a swerve module.
52 */
54 constexpr SwerveModuleConstants() = default;
55
56 /**
57 * \brief CAN ID of the steer motor.
58 */
59 int SteerMotorId = 0;
60 /**
61 * \brief CAN ID of the drive motor.
62 */
63 int DriveMotorId = 0;
64 /**
65 * \brief CAN ID of the CANcoder used for azimuth.
66 */
67 int CANcoderId = 0;
68 /**
69 * \brief Offset of the CANcoder.
70 */
71 units::angle::turn_t CANcoderOffset = 0_tr;
72 /**
73 * \brief The location of this module's wheels relative to the physical center
74 * of the robot in meters along the X axis of the robot.
75 */
76 units::length::meter_t LocationX = 0_m;
77 /**
78 * \brief The location of this module's wheels relative to the physical center
79 * of the robot in meters along the Y axis of the robot.
80 */
81 units::length::meter_t LocationY = 0_m;
82 /**
83 * \brief True if the drive motor is inverted.
84 */
85 bool DriveMotorInverted = false;
86 /**
87 * \brief True if the steer motor is inverted from the CANcoder.
88 */
89 bool SteerMotorInverted = false;
90 /**
91 * \brief Gear ratio between the drive motor and the wheel.
92 */
93 units::dimensionless::scalar_t DriveMotorGearRatio = 0;
94 /**
95 * \brief Gear ratio between the steer motor and the CANcoder. For example, the
96 * SDS Mk4 has a steering ratio of 12.8.
97 */
98 units::dimensionless::scalar_t SteerMotorGearRatio = 0;
99 /**
100 * \brief Coupled gear ratio between the CANcoder and the drive motor.
101 *
102 * For a typical swerve module, the azimuth turn motor also drives the wheel a
103 * nontrivial amount, which affects the accuracy of odometry and control. This
104 * ratio represents the number of rotations of the drive motor caused by a
105 * rotation of the azimuth.
106 */
107 units::dimensionless::scalar_t CouplingGearRatio = 0;
108 /**
109 * \brief Radius of the driving wheel in meters.
110 */
111 units::length::meter_t WheelRadius = 0_m;
112 /**
113 * \brief The steer motor closed-loop gains.
114 *
115 * The steer motor uses the control ouput type specified by
116 * SteerMotorClosedLoopOutput and any SwerveModule#SteerRequestType.
117 */
119 /**
120 * \brief The drive motor closed-loop gains.
121 *
122 * When using closed-loop control, the drive motor uses the control output type
123 * specified by DriveMotorClosedLoopOutput and any closed-loop
124 * SwerveModule#DriveRequestType.
125 */
127 /**
128 * \brief The closed-loop output type to use for the steer motors.
129 */
131 /**
132 * \brief The closed-loop output type to use for the drive motors.
133 */
135 /**
136 * \brief The maximum amount of stator current the drive motors can apply
137 * without slippage.
138 */
139 units::current::ampere_t SlipCurrent = 120_A;
140 /**
141 * \brief When using open-loop drive control, this specifies the speed at which
142 * the robot travels when driven with 12 volts. This is used to approximate the
143 * output for a desired velocity. If using closed loop control, this value is
144 * ignored.
145 */
146 units::velocity::meters_per_second_t SpeedAt12Volts = 0_mps;
147 /**
148 * \brief Choose how the feedback sensors should be configured.
149 *
150 * If the robot does not support Pro, then this should be set to RemoteCANcoder.
151 * Otherwise, users have the option to use either FusedCANcoder or SyncCANcoder
152 * depending on if there is a risk that the CANcoder can fail in a way to
153 * provide "good" data.
154 *
155 * If this is set to FusedCANcoder or SyncCANcoder when the steer motor is not
156 * Pro-licensed, the device will automatically fall back to RemoteCANcoder and
157 * report a UsingProFeatureOnUnlicensedDevice status code.
158 */
160 /**
161 * \brief The initial configs used to configure the drive motor of the swerve
162 * module. The default value is the factory-default.
163 *
164 * Users may change the initial configuration as they need. Any config that's
165 * not referenced in the SwerveModuleConstants class is available to be changed.
166 *
167 * The list of configs that will be overwritten is as follows:
168 *
169 * - configs#MotorOutputConfigs#NeutralMode (Brake mode, overwritten with
170 * SwerveDrivetrain#ConfigNeutralMode)
171 * - configs#MotorOutputConfigs#Inverted
172 * (SwerveModuleConstants#DriveMotorInverted)
173 * - configs#Slot0Configs (SwerveModuleConstants#DriveMotorGains)
174 * - configs#CurrentLimitsConfigs#StatorCurrentLimit /
175 * configs#TorqueCurrentConfigs#PeakForwardTorqueCurrent /
176 * configs#TorqueCurrentConfigs#PeakReverseTorqueCurrent
177 * (SwerveModuleConstants#SlipCurrent)
178 * - configs#CurrentLimitsConfigs#StatorCurrentLimitEnable (Enabled)
179 *
180 */
182 /**
183 * \brief The initial configs used to configure the steer motor of the swerve
184 * module. The default value is the factory-default.
185 *
186 * Users may change the initial configuration as they need. Any config that's
187 * not referenced in the SwerveModuleConstants class is available to be changed.
188 *
189 * The list of configs that will be overwritten is as follows:
190 *
191 * - configs#MotorOutputConfigs#NeutralMode (Brake mode)
192 * - configs#MotorOutputConfigs#Inverted
193 * (SwerveModuleConstants#SteerMotorInverted)
194 * - configs#Slot0Configs (SwerveModuleConstants#SteerMotorGains)
195 * - configs#FeedbackConfigs#FeedbackRemoteSensorID
196 * (SwerveModuleConstants#CANcoderId)
197 * - configs#FeedbackConfigs#FeedbackSensorSource
198 * (SwerveModuleConstants#FeedbackSource)
199 * - configs#FeedbackConfigs#RotorToSensorRatio
200 * (SwerveModuleConstants#SteerMotorGearRatio)
201 * - configs#MotionMagicConfigs (Calculated from gear ratios)
202 * - configs#ClosedLoopGeneralConfigs#ContinuousWrap (true)
203 *
204 */
206 /**
207 * \brief The initial configs used to configure the CANcoder of the swerve
208 * module. The default value is the factory-default.
209 *
210 * Users may change the initial configuration as they need. Any config that's
211 * not referenced in the SwerveModuleConstants class is available to be changed.
212 *
213 * The list of configs that will be overwritten is as follows:
214 *
215 * - configs#MagnetSensorConfigs#MagnetOffset
216 * (SwerveModuleConstants#CANcoderOffset)
217 *
218 */
220 /**
221 * \brief Simulated azimuthal inertia.
222 */
223 units::moment_of_inertia::kilogram_square_meter_t SteerInertia = 0.00001_kg_sq_m;
224 /**
225 * \brief Simulated drive inertia.
226 */
227 units::moment_of_inertia::kilogram_square_meter_t DriveInertia = 0.001_kg_sq_m;
228 /**
229 * \brief Simulated steer voltage required to overcome friction.
230 */
231 units::voltage::volt_t SteerFrictionVoltage = 0.25_V;
232 /**
233 * \brief Simulated drive voltage required to overcome friction.
234 */
235 units::voltage::volt_t DriveFrictionVoltage = 0.25_V;
236
237 /**
238 * \brief Modifies the SteerMotorId parameter and returns itself.
239 *
240 * CAN ID of the steer motor.
241 *
242 * \param newSteerMotorId Parameter to modify
243 * \returns this object
244 */
245 constexpr SwerveModuleConstants &WithSteerMotorId(int newSteerMotorId)
246 {
247 this->SteerMotorId = newSteerMotorId;
248 return *this;
249 }
250
251 /**
252 * \brief Modifies the DriveMotorId parameter and returns itself.
253 *
254 * CAN ID of the drive motor.
255 *
256 * \param newDriveMotorId Parameter to modify
257 * \returns this object
258 */
259 constexpr SwerveModuleConstants &WithDriveMotorId(int newDriveMotorId)
260 {
261 this->DriveMotorId = newDriveMotorId;
262 return *this;
263 }
264
265 /**
266 * \brief Modifies the CANcoderId parameter and returns itself.
267 *
268 * CAN ID of the CANcoder used for azimuth.
269 *
270 * \param newCANcoderId Parameter to modify
271 * \returns this object
272 */
273 constexpr SwerveModuleConstants &WithCANcoderId(int newCANcoderId)
274 {
275 this->CANcoderId = newCANcoderId;
276 return *this;
277 }
278
279 /**
280 * \brief Modifies the CANcoderOffset parameter and returns itself.
281 *
282 * Offset of the CANcoder.
283 *
284 * \param newCANcoderOffset Parameter to modify
285 * \returns this object
286 */
287 constexpr SwerveModuleConstants &WithCANcoderOffset(units::angle::turn_t newCANcoderOffset)
288 {
289 this->CANcoderOffset = newCANcoderOffset;
290 return *this;
291 }
292
293 /**
294 * \brief Modifies the LocationX parameter and returns itself.
295 *
296 * The location of this module's wheels relative to the physical center of the
297 * robot in meters along the X axis of the robot.
298 *
299 * \param newLocationX Parameter to modify
300 * \returns this object
301 */
302 constexpr SwerveModuleConstants &WithLocationX(units::length::meter_t newLocationX)
303 {
304 this->LocationX = newLocationX;
305 return *this;
306 }
307
308 /**
309 * \brief Modifies the LocationY parameter and returns itself.
310 *
311 * The location of this module's wheels relative to the physical center of the
312 * robot in meters along the Y axis of the robot.
313 *
314 * \param newLocationY Parameter to modify
315 * \returns this object
316 */
317 constexpr SwerveModuleConstants &WithLocationY(units::length::meter_t newLocationY)
318 {
319 this->LocationY = newLocationY;
320 return *this;
321 }
322
323 /**
324 * \brief Modifies the DriveMotorInverted parameter and returns itself.
325 *
326 * True if the drive motor is inverted.
327 *
328 * \param newDriveMotorInverted Parameter to modify
329 * \returns this object
330 */
331 constexpr SwerveModuleConstants &WithDriveMotorInverted(bool newDriveMotorInverted)
332 {
333 this->DriveMotorInverted = newDriveMotorInverted;
334 return *this;
335 }
336
337 /**
338 * \brief Modifies the SteerMotorInverted parameter and returns itself.
339 *
340 * True if the steer motor is inverted from the CANcoder.
341 *
342 * \param newSteerMotorInverted Parameter to modify
343 * \returns this object
344 */
345 constexpr SwerveModuleConstants &WithSteerMotorInverted(bool newSteerMotorInverted)
346 {
347 this->SteerMotorInverted = newSteerMotorInverted;
348 return *this;
349 }
350
351 /**
352 * \brief Modifies the DriveMotorGearRatio parameter and returns itself.
353 *
354 * Gear ratio between the drive motor and the wheel.
355 *
356 * \param newDriveMotorGearRatio Parameter to modify
357 * \returns this object
358 */
359 constexpr SwerveModuleConstants &WithDriveMotorGearRatio(units::dimensionless::scalar_t newDriveMotorGearRatio)
360 {
361 this->DriveMotorGearRatio = newDriveMotorGearRatio;
362 return *this;
363 }
364
365 /**
366 * \brief Modifies the SteerMotorGearRatio parameter and returns itself.
367 *
368 * Gear ratio between the steer motor and the CANcoder. For example, the SDS Mk4
369 * has a steering ratio of 12.8.
370 *
371 * \param newSteerMotorGearRatio Parameter to modify
372 * \returns this object
373 */
374 constexpr SwerveModuleConstants &WithSteerMotorGearRatio(units::dimensionless::scalar_t newSteerMotorGearRatio)
375 {
376 this->SteerMotorGearRatio = newSteerMotorGearRatio;
377 return *this;
378 }
379
380 /**
381 * \brief Modifies the CouplingGearRatio parameter and returns itself.
382 *
383 * Coupled gear ratio between the CANcoder and the drive motor.
384 *
385 * For a typical swerve module, the azimuth turn motor also drives the wheel a
386 * nontrivial amount, which affects the accuracy of odometry and control. This
387 * ratio represents the number of rotations of the drive motor caused by a
388 * rotation of the azimuth.
389 *
390 * \param newCouplingGearRatio Parameter to modify
391 * \returns this object
392 */
393 constexpr SwerveModuleConstants &WithCouplingGearRatio(units::dimensionless::scalar_t newCouplingGearRatio)
394 {
395 this->CouplingGearRatio = newCouplingGearRatio;
396 return *this;
397 }
398
399 /**
400 * \brief Modifies the WheelRadius parameter and returns itself.
401 *
402 * Radius of the driving wheel in meters.
403 *
404 * \param newWheelRadius Parameter to modify
405 * \returns this object
406 */
407 constexpr SwerveModuleConstants &WithWheelRadius(units::length::meter_t newWheelRadius)
408 {
409 this->WheelRadius = newWheelRadius;
410 return *this;
411 }
412
413 /**
414 * \brief Modifies the SteerMotorGains parameter and returns itself.
415 *
416 * The steer motor closed-loop gains.
417 *
418 * The steer motor uses the control ouput type specified by
419 * SteerMotorClosedLoopOutput and any SwerveModule#SteerRequestType.
420 *
421 * \param newSteerMotorGains Parameter to modify
422 * \returns this object
423 */
425 {
426 this->SteerMotorGains = newSteerMotorGains;
427 return *this;
428 }
429
430 /**
431 * \brief Modifies the DriveMotorGains parameter and returns itself.
432 *
433 * The drive motor closed-loop gains.
434 *
435 * When using closed-loop control, the drive motor uses the control output type
436 * specified by DriveMotorClosedLoopOutput and any closed-loop
437 * SwerveModule#DriveRequestType.
438 *
439 * \param newDriveMotorGains Parameter to modify
440 * \returns this object
441 */
443 {
444 this->DriveMotorGains = newDriveMotorGains;
445 return *this;
446 }
447
448 /**
449 * \brief Modifies the SteerMotorClosedLoopOutput parameter and returns itself.
450 *
451 * The closed-loop output type to use for the steer motors.
452 *
453 * \param newSteerMotorClosedLoopOutput Parameter to modify
454 * \returns this object
455 */
457 {
458 this->SteerMotorClosedLoopOutput = newSteerMotorClosedLoopOutput;
459 return *this;
460 }
461
462 /**
463 * \brief Modifies the DriveMotorClosedLoopOutput parameter and returns itself.
464 *
465 * The closed-loop output type to use for the drive motors.
466 *
467 * \param newDriveMotorClosedLoopOutput Parameter to modify
468 * \returns this object
469 */
471 {
472 this->DriveMotorClosedLoopOutput = newDriveMotorClosedLoopOutput;
473 return *this;
474 }
475
476 /**
477 * \brief Modifies the SlipCurrent parameter and returns itself.
478 *
479 * The maximum amount of stator current the drive motors can apply without
480 * slippage.
481 *
482 * \param newSlipCurrent Parameter to modify
483 * \returns this object
484 */
485 constexpr SwerveModuleConstants &WithSlipCurrent(units::current::ampere_t newSlipCurrent)
486 {
487 this->SlipCurrent = newSlipCurrent;
488 return *this;
489 }
490
491 /**
492 * \brief Modifies the SpeedAt12Volts parameter and returns itself.
493 *
494 * When using open-loop drive control, this specifies the speed at which the
495 * robot travels when driven with 12 volts. This is used to approximate the
496 * output for a desired velocity. If using closed loop control, this value is
497 * ignored.
498 *
499 * \param newSpeedAt12Volts Parameter to modify
500 * \returns this object
501 */
502 constexpr SwerveModuleConstants &WithSpeedAt12Volts(units::velocity::meters_per_second_t newSpeedAt12Volts)
503 {
504 this->SpeedAt12Volts = newSpeedAt12Volts;
505 return *this;
506 }
507
508 /**
509 * \brief Modifies the FeedbackSource parameter and returns itself.
510 *
511 * Choose how the feedback sensors should be configured.
512 *
513 * If the robot does not support Pro, then this should be set to RemoteCANcoder.
514 * Otherwise, users have the option to use either FusedCANcoder or SyncCANcoder
515 * depending on if there is a risk that the CANcoder can fail in a way to
516 * provide "good" data.
517 *
518 * If this is set to FusedCANcoder or SyncCANcoder when the steer motor is not
519 * Pro-licensed, the device will automatically fall back to RemoteCANcoder and
520 * report a UsingProFeatureOnUnlicensedDevice status code.
521 *
522 * \param newFeedbackSource Parameter to modify
523 * \returns this object
524 */
526 {
527 this->FeedbackSource = newFeedbackSource;
528 return *this;
529 }
530
531 /**
532 * \brief Modifies the DriveMotorInitialConfigs parameter and returns itself.
533 *
534 * The initial configs used to configure the drive motor of the swerve module.
535 * The default value is the factory-default.
536 *
537 * Users may change the initial configuration as they need. Any config that's
538 * not referenced in the SwerveModuleConstants class is available to be changed.
539 *
540 * The list of configs that will be overwritten is as follows:
541 *
542 * - configs#MotorOutputConfigs#NeutralMode (Brake mode, overwritten with
543 * SwerveDrivetrain#ConfigNeutralMode)
544 * - configs#MotorOutputConfigs#Inverted
545 * (SwerveModuleConstants#DriveMotorInverted)
546 * - configs#Slot0Configs (SwerveModuleConstants#DriveMotorGains)
547 * - configs#CurrentLimitsConfigs#StatorCurrentLimit /
548 * configs#TorqueCurrentConfigs#PeakForwardTorqueCurrent /
549 * configs#TorqueCurrentConfigs#PeakReverseTorqueCurrent
550 * (SwerveModuleConstants#SlipCurrent)
551 * - configs#CurrentLimitsConfigs#StatorCurrentLimitEnable (Enabled)
552 *
553 *
554 * \param newDriveMotorInitialConfigs Parameter to modify
555 * \returns this object
556 */
558 {
559 this->DriveMotorInitialConfigs = newDriveMotorInitialConfigs;
560 return *this;
561 }
562
563 /**
564 * \brief Modifies the SteerMotorInitialConfigs parameter and returns itself.
565 *
566 * The initial configs used to configure the steer motor of the swerve module.
567 * The default value is the factory-default.
568 *
569 * Users may change the initial configuration as they need. Any config that's
570 * not referenced in the SwerveModuleConstants class is available to be changed.
571 *
572 * The list of configs that will be overwritten is as follows:
573 *
574 * - configs#MotorOutputConfigs#NeutralMode (Brake mode)
575 * - configs#MotorOutputConfigs#Inverted
576 * (SwerveModuleConstants#SteerMotorInverted)
577 * - configs#Slot0Configs (SwerveModuleConstants#SteerMotorGains)
578 * - configs#FeedbackConfigs#FeedbackRemoteSensorID
579 * (SwerveModuleConstants#CANcoderId)
580 * - configs#FeedbackConfigs#FeedbackSensorSource
581 * (SwerveModuleConstants#FeedbackSource)
582 * - configs#FeedbackConfigs#RotorToSensorRatio
583 * (SwerveModuleConstants#SteerMotorGearRatio)
584 * - configs#MotionMagicConfigs (Calculated from gear ratios)
585 * - configs#ClosedLoopGeneralConfigs#ContinuousWrap (true)
586 *
587 *
588 * \param newSteerMotorInitialConfigs Parameter to modify
589 * \returns this object
590 */
592 {
593 this->SteerMotorInitialConfigs = newSteerMotorInitialConfigs;
594 return *this;
595 }
596
597 /**
598 * \brief Modifies the CANcoderInitialConfigs parameter and returns itself.
599 *
600 * The initial configs used to configure the CANcoder of the swerve module. The
601 * default value is the factory-default.
602 *
603 * Users may change the initial configuration as they need. Any config that's
604 * not referenced in the SwerveModuleConstants class is available to be changed.
605 *
606 * The list of configs that will be overwritten is as follows:
607 *
608 * - configs#MagnetSensorConfigs#MagnetOffset
609 * (SwerveModuleConstants#CANcoderOffset)
610 *
611 *
612 * \param newCANcoderInitialConfigs Parameter to modify
613 * \returns this object
614 */
616 {
617 this->CANcoderInitialConfigs = newCANcoderInitialConfigs;
618 return *this;
619 }
620
621 /**
622 * \brief Modifies the SteerInertia parameter and returns itself.
623 *
624 * Simulated azimuthal inertia.
625 *
626 * \param newSteerInertia Parameter to modify
627 * \returns this object
628 */
629 constexpr SwerveModuleConstants &WithSteerInertia(units::moment_of_inertia::kilogram_square_meter_t newSteerInertia)
630 {
631 this->SteerInertia = newSteerInertia;
632 return *this;
633 }
634
635 /**
636 * \brief Modifies the DriveInertia parameter and returns itself.
637 *
638 * Simulated drive inertia.
639 *
640 * \param newDriveInertia Parameter to modify
641 * \returns this object
642 */
643 constexpr SwerveModuleConstants &WithDriveInertia(units::moment_of_inertia::kilogram_square_meter_t newDriveInertia)
644 {
645 this->DriveInertia = newDriveInertia;
646 return *this;
647 }
648
649 /**
650 * \brief Modifies the SteerFrictionVoltage parameter and returns itself.
651 *
652 * Simulated steer voltage required to overcome friction.
653 *
654 * \param newSteerFrictionVoltage Parameter to modify
655 * \returns this object
656 */
657 constexpr SwerveModuleConstants &WithSteerFrictionVoltage(units::voltage::volt_t newSteerFrictionVoltage)
658 {
659 this->SteerFrictionVoltage = newSteerFrictionVoltage;
660 return *this;
661 }
662
663 /**
664 * \brief Modifies the DriveFrictionVoltage parameter and returns itself.
665 *
666 * Simulated drive voltage required to overcome friction.
667 *
668 * \param newDriveFrictionVoltage Parameter to modify
669 * \returns this object
670 */
671 constexpr SwerveModuleConstants &WithDriveFrictionVoltage(units::voltage::volt_t newDriveFrictionVoltage)
672 {
673 this->DriveFrictionVoltage = newDriveFrictionVoltage;
674 return *this;
675 }
676
677};
678
679/**
680 * \brief Constants that are common across the swerve modules, used
681 * for creating instances of module-specific SwerveModuleConstants.
682 */
684 constexpr SwerveModuleConstantsFactory() = default;
685
686 /**
687 * \brief Gear ratio between the drive motor and the wheel.
688 */
689 units::dimensionless::scalar_t DriveMotorGearRatio = 0;
690 /**
691 * \brief Gear ratio between the steer motor and the CANcoder. For example, the
692 * SDS Mk4 has a steering ratio of 12.8.
693 */
694 units::dimensionless::scalar_t SteerMotorGearRatio = 0;
695 /**
696 * \brief Coupled gear ratio between the CANcoder and the drive motor.
697 *
698 * For a typical swerve module, the azimuth turn motor also drives the wheel a
699 * nontrivial amount, which affects the accuracy of odometry and control. This
700 * ratio represents the number of rotations of the drive motor caused by a
701 * rotation of the azimuth.
702 */
703 units::dimensionless::scalar_t CouplingGearRatio = 0;
704 /**
705 * \brief Radius of the driving wheel in meters.
706 */
707 units::length::meter_t WheelRadius = 0_m;
708 /**
709 * \brief The steer motor closed-loop gains.
710 *
711 * The steer motor uses the control ouput type specified by
712 * SteerMotorClosedLoopOutput and any SwerveModule#SteerRequestType.
713 */
715 /**
716 * \brief The drive motor closed-loop gains.
717 *
718 * When using closed-loop control, the drive motor uses the control output type
719 * specified by DriveMotorClosedLoopOutput and any closed-loop
720 * SwerveModule#DriveRequestType.
721 */
723 /**
724 * \brief The closed-loop output type to use for the steer motors.
725 */
727 /**
728 * \brief The closed-loop output type to use for the drive motors.
729 */
731 /**
732 * \brief The maximum amount of stator current the drive motors can apply
733 * without slippage.
734 */
735 units::current::ampere_t SlipCurrent = 120_A;
736 /**
737 * \brief When using open-loop drive control, this specifies the speed at which
738 * the robot travels when driven with 12 volts. This is used to approximate the
739 * output for a desired velocity. If using closed loop control, this value is
740 * ignored.
741 */
742 units::velocity::meters_per_second_t SpeedAt12Volts = 0_mps;
743 /**
744 * \brief Choose how the feedback sensors should be configured.
745 *
746 * If the robot does not support Pro, then this should be set to RemoteCANcoder.
747 * Otherwise, users have the option to use either FusedCANcoder or SyncCANcoder
748 * depending on if there is a risk that the CANcoder can fail in a way to
749 * provide "good" data.
750 *
751 * If this is set to FusedCANcoder or SyncCANcoder when the steer motor is not
752 * Pro-licensed, the device will automatically fall back to RemoteCANcoder and
753 * report a UsingProFeatureOnUnlicensedDevice status code.
754 */
756 /**
757 * \brief The initial configs used to configure the drive motor of the swerve
758 * module. The default value is the factory-default.
759 *
760 * Users may change the initial configuration as they need. Any config that's
761 * not referenced in the SwerveModuleConstants class is available to be changed.
762 *
763 * The list of configs that will be overwritten is as follows:
764 *
765 * - configs#MotorOutputConfigs#NeutralMode (Brake mode, overwritten with
766 * SwerveDrivetrain#ConfigNeutralMode)
767 * - configs#MotorOutputConfigs#Inverted
768 * (SwerveModuleConstants#DriveMotorInverted)
769 * - configs#Slot0Configs (SwerveModuleConstants#DriveMotorGains)
770 * - configs#CurrentLimitsConfigs#StatorCurrentLimit /
771 * configs#TorqueCurrentConfigs#PeakForwardTorqueCurrent /
772 * configs#TorqueCurrentConfigs#PeakReverseTorqueCurrent
773 * (SwerveModuleConstants#SlipCurrent)
774 * - configs#CurrentLimitsConfigs#StatorCurrentLimitEnable (Enabled)
775 *
776 */
778 /**
779 * \brief The initial configs used to configure the steer motor of the swerve
780 * module. The default value is the factory-default.
781 *
782 * Users may change the initial configuration as they need. Any config that's
783 * not referenced in the SwerveModuleConstants class is available to be changed.
784 *
785 * The list of configs that will be overwritten is as follows:
786 *
787 * - configs#MotorOutputConfigs#NeutralMode (Brake mode)
788 * - configs#MotorOutputConfigs#Inverted
789 * (SwerveModuleConstants#SteerMotorInverted)
790 * - configs#Slot0Configs (SwerveModuleConstants#SteerMotorGains)
791 * - configs#FeedbackConfigs#FeedbackRemoteSensorID
792 * (SwerveModuleConstants#CANcoderId)
793 * - configs#FeedbackConfigs#FeedbackSensorSource
794 * (SwerveModuleConstants#FeedbackSource)
795 * - configs#FeedbackConfigs#RotorToSensorRatio
796 * (SwerveModuleConstants#SteerMotorGearRatio)
797 * - configs#MotionMagicConfigs (Calculated from gear ratios)
798 * - configs#ClosedLoopGeneralConfigs#ContinuousWrap (true)
799 *
800 */
802 /**
803 * \brief The initial configs used to configure the CANcoder of the swerve
804 * module. The default value is the factory-default.
805 *
806 * Users may change the initial configuration as they need. Any config that's
807 * not referenced in the SwerveModuleConstants class is available to be changed.
808 *
809 * The list of configs that will be overwritten is as follows:
810 *
811 * - configs#MagnetSensorConfigs#MagnetOffset
812 * (SwerveModuleConstants#CANcoderOffset)
813 *
814 */
816 /**
817 * \brief Simulated azimuthal inertia.
818 */
819 units::moment_of_inertia::kilogram_square_meter_t SteerInertia = 0.00001_kg_sq_m;
820 /**
821 * \brief Simulated drive inertia.
822 */
823 units::moment_of_inertia::kilogram_square_meter_t DriveInertia = 0.001_kg_sq_m;
824 /**
825 * \brief Simulated steer voltage required to overcome friction.
826 */
827 units::voltage::volt_t SteerFrictionVoltage = 0.25_V;
828 /**
829 * \brief Simulated drive voltage required to overcome friction.
830 */
831 units::voltage::volt_t DriveFrictionVoltage = 0.25_V;
832
833 /**
834 * \brief Modifies the DriveMotorGearRatio parameter and returns itself.
835 *
836 * Gear ratio between the drive motor and the wheel.
837 *
838 * \param newDriveMotorGearRatio Parameter to modify
839 * \returns this object
840 */
841 constexpr SwerveModuleConstantsFactory &WithDriveMotorGearRatio(units::dimensionless::scalar_t newDriveMotorGearRatio)
842 {
843 this->DriveMotorGearRatio = newDriveMotorGearRatio;
844 return *this;
845 }
846
847 /**
848 * \brief Modifies the SteerMotorGearRatio parameter and returns itself.
849 *
850 * Gear ratio between the steer motor and the CANcoder. For example, the SDS Mk4
851 * has a steering ratio of 12.8.
852 *
853 * \param newSteerMotorGearRatio Parameter to modify
854 * \returns this object
855 */
856 constexpr SwerveModuleConstantsFactory &WithSteerMotorGearRatio(units::dimensionless::scalar_t newSteerMotorGearRatio)
857 {
858 this->SteerMotorGearRatio = newSteerMotorGearRatio;
859 return *this;
860 }
861
862 /**
863 * \brief Modifies the CouplingGearRatio parameter and returns itself.
864 *
865 * Coupled gear ratio between the CANcoder and the drive motor.
866 *
867 * For a typical swerve module, the azimuth turn motor also drives the wheel a
868 * nontrivial amount, which affects the accuracy of odometry and control. This
869 * ratio represents the number of rotations of the drive motor caused by a
870 * rotation of the azimuth.
871 *
872 * \param newCouplingGearRatio Parameter to modify
873 * \returns this object
874 */
875 constexpr SwerveModuleConstantsFactory &WithCouplingGearRatio(units::dimensionless::scalar_t newCouplingGearRatio)
876 {
877 this->CouplingGearRatio = newCouplingGearRatio;
878 return *this;
879 }
880
881 /**
882 * \brief Modifies the WheelRadius parameter and returns itself.
883 *
884 * Radius of the driving wheel in meters.
885 *
886 * \param newWheelRadius Parameter to modify
887 * \returns this object
888 */
889 constexpr SwerveModuleConstantsFactory &WithWheelRadius(units::length::meter_t newWheelRadius)
890 {
891 this->WheelRadius = newWheelRadius;
892 return *this;
893 }
894
895 /**
896 * \brief Modifies the SteerMotorGains parameter and returns itself.
897 *
898 * The steer motor closed-loop gains.
899 *
900 * The steer motor uses the control ouput type specified by
901 * SteerMotorClosedLoopOutput and any SwerveModule#SteerRequestType.
902 *
903 * \param newSteerMotorGains Parameter to modify
904 * \returns this object
905 */
907 {
908 this->SteerMotorGains = newSteerMotorGains;
909 return *this;
910 }
911
912 /**
913 * \brief Modifies the DriveMotorGains parameter and returns itself.
914 *
915 * The drive motor closed-loop gains.
916 *
917 * When using closed-loop control, the drive motor uses the control output type
918 * specified by DriveMotorClosedLoopOutput and any closed-loop
919 * SwerveModule#DriveRequestType.
920 *
921 * \param newDriveMotorGains Parameter to modify
922 * \returns this object
923 */
925 {
926 this->DriveMotorGains = newDriveMotorGains;
927 return *this;
928 }
929
930 /**
931 * \brief Modifies the SteerMotorClosedLoopOutput parameter and returns itself.
932 *
933 * The closed-loop output type to use for the steer motors.
934 *
935 * \param newSteerMotorClosedLoopOutput Parameter to modify
936 * \returns this object
937 */
939 {
940 this->SteerMotorClosedLoopOutput = newSteerMotorClosedLoopOutput;
941 return *this;
942 }
943
944 /**
945 * \brief Modifies the DriveMotorClosedLoopOutput parameter and returns itself.
946 *
947 * The closed-loop output type to use for the drive motors.
948 *
949 * \param newDriveMotorClosedLoopOutput Parameter to modify
950 * \returns this object
951 */
953 {
954 this->DriveMotorClosedLoopOutput = newDriveMotorClosedLoopOutput;
955 return *this;
956 }
957
958 /**
959 * \brief Modifies the SlipCurrent parameter and returns itself.
960 *
961 * The maximum amount of stator current the drive motors can apply without
962 * slippage.
963 *
964 * \param newSlipCurrent Parameter to modify
965 * \returns this object
966 */
967 constexpr SwerveModuleConstantsFactory &WithSlipCurrent(units::current::ampere_t newSlipCurrent)
968 {
969 this->SlipCurrent = newSlipCurrent;
970 return *this;
971 }
972
973 /**
974 * \brief Modifies the SpeedAt12Volts parameter and returns itself.
975 *
976 * When using open-loop drive control, this specifies the speed at which the
977 * robot travels when driven with 12 volts. This is used to approximate the
978 * output for a desired velocity. If using closed loop control, this value is
979 * ignored.
980 *
981 * \param newSpeedAt12Volts Parameter to modify
982 * \returns this object
983 */
984 constexpr SwerveModuleConstantsFactory &WithSpeedAt12Volts(units::velocity::meters_per_second_t newSpeedAt12Volts)
985 {
986 this->SpeedAt12Volts = newSpeedAt12Volts;
987 return *this;
988 }
989
990 /**
991 * \brief Modifies the FeedbackSource parameter and returns itself.
992 *
993 * Choose how the feedback sensors should be configured.
994 *
995 * If the robot does not support Pro, then this should be set to RemoteCANcoder.
996 * Otherwise, users have the option to use either FusedCANcoder or SyncCANcoder
997 * depending on if there is a risk that the CANcoder can fail in a way to
998 * provide "good" data.
999 *
1000 * If this is set to FusedCANcoder or SyncCANcoder when the steer motor is not
1001 * Pro-licensed, the device will automatically fall back to RemoteCANcoder and
1002 * report a UsingProFeatureOnUnlicensedDevice status code.
1003 *
1004 * \param newFeedbackSource Parameter to modify
1005 * \returns this object
1006 */
1008 {
1009 this->FeedbackSource = newFeedbackSource;
1010 return *this;
1011 }
1012
1013 /**
1014 * \brief Modifies the DriveMotorInitialConfigs parameter and returns itself.
1015 *
1016 * The initial configs used to configure the drive motor of the swerve module.
1017 * The default value is the factory-default.
1018 *
1019 * Users may change the initial configuration as they need. Any config that's
1020 * not referenced in the SwerveModuleConstants class is available to be changed.
1021 *
1022 * The list of configs that will be overwritten is as follows:
1023 *
1024 * - configs#MotorOutputConfigs#NeutralMode (Brake mode, overwritten with
1025 * SwerveDrivetrain#ConfigNeutralMode)
1026 * - configs#MotorOutputConfigs#Inverted
1027 * (SwerveModuleConstants#DriveMotorInverted)
1028 * - configs#Slot0Configs (SwerveModuleConstants#DriveMotorGains)
1029 * - configs#CurrentLimitsConfigs#StatorCurrentLimit /
1030 * configs#TorqueCurrentConfigs#PeakForwardTorqueCurrent /
1031 * configs#TorqueCurrentConfigs#PeakReverseTorqueCurrent
1032 * (SwerveModuleConstants#SlipCurrent)
1033 * - configs#CurrentLimitsConfigs#StatorCurrentLimitEnable (Enabled)
1034 *
1035 *
1036 * \param newDriveMotorInitialConfigs Parameter to modify
1037 * \returns this object
1038 */
1040 {
1041 this->DriveMotorInitialConfigs = newDriveMotorInitialConfigs;
1042 return *this;
1043 }
1044
1045 /**
1046 * \brief Modifies the SteerMotorInitialConfigs parameter and returns itself.
1047 *
1048 * The initial configs used to configure the steer motor of the swerve module.
1049 * The default value is the factory-default.
1050 *
1051 * Users may change the initial configuration as they need. Any config that's
1052 * not referenced in the SwerveModuleConstants class is available to be changed.
1053 *
1054 * The list of configs that will be overwritten is as follows:
1055 *
1056 * - configs#MotorOutputConfigs#NeutralMode (Brake mode)
1057 * - configs#MotorOutputConfigs#Inverted
1058 * (SwerveModuleConstants#SteerMotorInverted)
1059 * - configs#Slot0Configs (SwerveModuleConstants#SteerMotorGains)
1060 * - configs#FeedbackConfigs#FeedbackRemoteSensorID
1061 * (SwerveModuleConstants#CANcoderId)
1062 * - configs#FeedbackConfigs#FeedbackSensorSource
1063 * (SwerveModuleConstants#FeedbackSource)
1064 * - configs#FeedbackConfigs#RotorToSensorRatio
1065 * (SwerveModuleConstants#SteerMotorGearRatio)
1066 * - configs#MotionMagicConfigs (Calculated from gear ratios)
1067 * - configs#ClosedLoopGeneralConfigs#ContinuousWrap (true)
1068 *
1069 *
1070 * \param newSteerMotorInitialConfigs Parameter to modify
1071 * \returns this object
1072 */
1074 {
1075 this->SteerMotorInitialConfigs = newSteerMotorInitialConfigs;
1076 return *this;
1077 }
1078
1079 /**
1080 * \brief Modifies the CANcoderInitialConfigs parameter and returns itself.
1081 *
1082 * The initial configs used to configure the CANcoder of the swerve module. The
1083 * default value is the factory-default.
1084 *
1085 * Users may change the initial configuration as they need. Any config that's
1086 * not referenced in the SwerveModuleConstants class is available to be changed.
1087 *
1088 * The list of configs that will be overwritten is as follows:
1089 *
1090 * - configs#MagnetSensorConfigs#MagnetOffset
1091 * (SwerveModuleConstants#CANcoderOffset)
1092 *
1093 *
1094 * \param newCANcoderInitialConfigs Parameter to modify
1095 * \returns this object
1096 */
1098 {
1099 this->CANcoderInitialConfigs = newCANcoderInitialConfigs;
1100 return *this;
1101 }
1102
1103 /**
1104 * \brief Modifies the SteerInertia parameter and returns itself.
1105 *
1106 * Simulated azimuthal inertia.
1107 *
1108 * \param newSteerInertia Parameter to modify
1109 * \returns this object
1110 */
1111 constexpr SwerveModuleConstantsFactory &WithSteerInertia(units::moment_of_inertia::kilogram_square_meter_t newSteerInertia)
1112 {
1113 this->SteerInertia = newSteerInertia;
1114 return *this;
1115 }
1116
1117 /**
1118 * \brief Modifies the DriveInertia parameter and returns itself.
1119 *
1120 * Simulated drive inertia.
1121 *
1122 * \param newDriveInertia Parameter to modify
1123 * \returns this object
1124 */
1125 constexpr SwerveModuleConstantsFactory &WithDriveInertia(units::moment_of_inertia::kilogram_square_meter_t newDriveInertia)
1126 {
1127 this->DriveInertia = newDriveInertia;
1128 return *this;
1129 }
1130
1131 /**
1132 * \brief Modifies the SteerFrictionVoltage parameter and returns itself.
1133 *
1134 * Simulated steer voltage required to overcome friction.
1135 *
1136 * \param newSteerFrictionVoltage Parameter to modify
1137 * \returns this object
1138 */
1139 constexpr SwerveModuleConstantsFactory &WithSteerFrictionVoltage(units::voltage::volt_t newSteerFrictionVoltage)
1140 {
1141 this->SteerFrictionVoltage = newSteerFrictionVoltage;
1142 return *this;
1143 }
1144
1145 /**
1146 * \brief Modifies the DriveFrictionVoltage parameter and returns itself.
1147 *
1148 * Simulated drive voltage required to overcome friction.
1149 *
1150 * \param newDriveFrictionVoltage Parameter to modify
1151 * \returns this object
1152 */
1153 constexpr SwerveModuleConstantsFactory &WithDriveFrictionVoltage(units::voltage::volt_t newDriveFrictionVoltage)
1154 {
1155 this->DriveFrictionVoltage = newDriveFrictionVoltage;
1156 return *this;
1157 }
1158
1159 /**
1160 * \brief Creates the constants for a swerve module with the given properties.
1161 *
1162 * \param steerMotorId CAN ID of the steer motor.
1163 * \param driveMotorId CAN ID of the drive motor.
1164 * \param cancoderId CAN ID of the CANcoder used for azimuth.
1165 * \param cancoderOffset Offset of the CANcoder.
1166 * \param locationX The location of this module's wheels relative to the physical center of the robot in meters along the X axis of the robot.
1167 * \param locationY The location of this module's wheels relative to the physical center of the robot in meters along the Y axis of the robot.
1168 * \param driveMotorInverted True if the drive motor is inverted.
1169 * \param steerMotorInverted True if the steer motor is inverted from the CANcoder.
1170 * \returns Constants for the swerve module
1171 */
1173 int steerMotorId,
1174 int driveMotorId,
1175 int cancoderId,
1176 units::angle::turn_t cancoderOffset,
1177 units::length::meter_t locationX,
1178 units::length::meter_t locationY,
1179 bool driveMotorInverted,
1180 bool steerMotorInverted) const
1181 {
1182 return SwerveModuleConstants{}
1183 .WithSteerMotorId(steerMotorId)
1184 .WithDriveMotorId(driveMotorId)
1185 .WithCANcoderId(cancoderId)
1186 .WithCANcoderOffset(cancoderOffset)
1187 .WithLocationX(locationX)
1188 .WithLocationY(locationY)
1189 .WithDriveMotorInverted(driveMotorInverted)
1190 .WithSteerMotorInverted(steerMotorInverted)
1209 }
1210};
1211
1212}
1213}
1214}
Class for CANcoder, a CAN based magnetic encoder that provides absolute and relative position along w...
Definition: CoreCANcoder.hpp:38
Gains for the specified slot.
Definition: Configs.hpp:3713
Class description for the Talon FX integrated motor controller.
Definition: CoreTalonFX.hpp:100
ClosedLoopOutputType
Supported closed-loop output types.
Definition: SwerveModuleConstants.hpp:23
SteerFeedbackType
Supported feedback sensors for the steer motors.
Definition: SwerveModuleConstants.hpp:32
@ FusedCANcoder
Requires Pro; Use signals::FeedbackSensorSourceValue::FusedCANcoder for the steer motor.
@ SyncCANcoder
Requires Pro; Use signals::FeedbackSensorSourceValue::SyncCANcoder for the steer motor.
@ RemoteCANcoder
Use signals::FeedbackSensorSourceValue::RemoteCANcoder for the steer motor.
Represents the state of one swerve module.
Definition: StatusCodes.h:18
Constants that are common across the swerve modules, used for creating instances of module-specific S...
Definition: SwerveModuleConstants.hpp:683
constexpr SwerveModuleConstantsFactory & WithDriveFrictionVoltage(units::voltage::volt_t newDriveFrictionVoltage)
Modifies the DriveFrictionVoltage parameter and returns itself.
Definition: SwerveModuleConstants.hpp:1153
units::length::meter_t WheelRadius
Radius of the driving wheel in meters.
Definition: SwerveModuleConstants.hpp:707
constexpr SwerveModuleConstantsFactory & WithSteerMotorGearRatio(units::dimensionless::scalar_t newSteerMotorGearRatio)
Modifies the SteerMotorGearRatio parameter and returns itself.
Definition: SwerveModuleConstants.hpp:856
SteerFeedbackType FeedbackSource
Choose how the feedback sensors should be configured.
Definition: SwerveModuleConstants.hpp:755
ClosedLoopOutputType SteerMotorClosedLoopOutput
The closed-loop output type to use for the steer motors.
Definition: SwerveModuleConstants.hpp:726
configs::TalonFXConfiguration SteerMotorInitialConfigs
The initial configs used to configure the steer motor of the swerve module.
Definition: SwerveModuleConstants.hpp:801
constexpr SwerveModuleConstantsFactory & WithSteerMotorClosedLoopOutput(ClosedLoopOutputType newSteerMotorClosedLoopOutput)
Modifies the SteerMotorClosedLoopOutput parameter and returns itself.
Definition: SwerveModuleConstants.hpp:938
configs::CANcoderConfiguration CANcoderInitialConfigs
The initial configs used to configure the CANcoder of the swerve module.
Definition: SwerveModuleConstants.hpp:815
constexpr SwerveModuleConstantsFactory & WithFeedbackSource(SteerFeedbackType newFeedbackSource)
Modifies the FeedbackSource parameter and returns itself.
Definition: SwerveModuleConstants.hpp:1007
units::moment_of_inertia::kilogram_square_meter_t DriveInertia
Simulated drive inertia.
Definition: SwerveModuleConstants.hpp:823
units::moment_of_inertia::kilogram_square_meter_t SteerInertia
Simulated azimuthal inertia.
Definition: SwerveModuleConstants.hpp:819
constexpr SwerveModuleConstantsFactory & WithDriveInertia(units::moment_of_inertia::kilogram_square_meter_t newDriveInertia)
Modifies the DriveInertia parameter and returns itself.
Definition: SwerveModuleConstants.hpp:1125
constexpr SwerveModuleConstantsFactory & WithSlipCurrent(units::current::ampere_t newSlipCurrent)
Modifies the SlipCurrent parameter and returns itself.
Definition: SwerveModuleConstants.hpp:967
constexpr SwerveModuleConstantsFactory & WithSteerMotorInitialConfigs(configs::TalonFXConfiguration newSteerMotorInitialConfigs)
Modifies the SteerMotorInitialConfigs parameter and returns itself.
Definition: SwerveModuleConstants.hpp:1073
constexpr SwerveModuleConstantsFactory & WithSteerFrictionVoltage(units::voltage::volt_t newSteerFrictionVoltage)
Modifies the SteerFrictionVoltage parameter and returns itself.
Definition: SwerveModuleConstants.hpp:1139
constexpr SwerveModuleConstantsFactory & WithDriveMotorGearRatio(units::dimensionless::scalar_t newDriveMotorGearRatio)
Modifies the DriveMotorGearRatio parameter and returns itself.
Definition: SwerveModuleConstants.hpp:841
configs::Slot0Configs DriveMotorGains
The drive motor closed-loop gains.
Definition: SwerveModuleConstants.hpp:722
configs::TalonFXConfiguration DriveMotorInitialConfigs
The initial configs used to configure the drive motor of the swerve module.
Definition: SwerveModuleConstants.hpp:777
ClosedLoopOutputType DriveMotorClosedLoopOutput
The closed-loop output type to use for the drive motors.
Definition: SwerveModuleConstants.hpp:730
constexpr SwerveModuleConstantsFactory & WithDriveMotorGains(configs::Slot0Configs newDriveMotorGains)
Modifies the DriveMotorGains parameter and returns itself.
Definition: SwerveModuleConstants.hpp:924
units::dimensionless::scalar_t DriveMotorGearRatio
Gear ratio between the drive motor and the wheel.
Definition: SwerveModuleConstants.hpp:689
constexpr SwerveModuleConstantsFactory & WithCANcoderInitialConfigs(configs::CANcoderConfiguration newCANcoderInitialConfigs)
Modifies the CANcoderInitialConfigs parameter and returns itself.
Definition: SwerveModuleConstants.hpp:1097
constexpr SwerveModuleConstantsFactory & WithDriveMotorClosedLoopOutput(ClosedLoopOutputType newDriveMotorClosedLoopOutput)
Modifies the DriveMotorClosedLoopOutput parameter and returns itself.
Definition: SwerveModuleConstants.hpp:952
units::voltage::volt_t SteerFrictionVoltage
Simulated steer voltage required to overcome friction.
Definition: SwerveModuleConstants.hpp:827
constexpr SwerveModuleConstantsFactory & WithWheelRadius(units::length::meter_t newWheelRadius)
Modifies the WheelRadius parameter and returns itself.
Definition: SwerveModuleConstants.hpp:889
constexpr SwerveModuleConstantsFactory & WithSteerInertia(units::moment_of_inertia::kilogram_square_meter_t newSteerInertia)
Modifies the SteerInertia parameter and returns itself.
Definition: SwerveModuleConstants.hpp:1111
configs::Slot0Configs SteerMotorGains
The steer motor closed-loop gains.
Definition: SwerveModuleConstants.hpp:714
constexpr SwerveModuleConstantsFactory & WithCouplingGearRatio(units::dimensionless::scalar_t newCouplingGearRatio)
Modifies the CouplingGearRatio parameter and returns itself.
Definition: SwerveModuleConstants.hpp:875
constexpr SwerveModuleConstantsFactory & WithSpeedAt12Volts(units::velocity::meters_per_second_t newSpeedAt12Volts)
Modifies the SpeedAt12Volts parameter and returns itself.
Definition: SwerveModuleConstants.hpp:984
units::voltage::volt_t DriveFrictionVoltage
Simulated drive voltage required to overcome friction.
Definition: SwerveModuleConstants.hpp:831
constexpr SwerveModuleConstants CreateModuleConstants(int steerMotorId, int driveMotorId, int cancoderId, units::angle::turn_t cancoderOffset, units::length::meter_t locationX, units::length::meter_t locationY, bool driveMotorInverted, bool steerMotorInverted) const
Creates the constants for a swerve module with the given properties.
Definition: SwerveModuleConstants.hpp:1172
units::velocity::meters_per_second_t SpeedAt12Volts
When using open-loop drive control, this specifies the speed at which the robot travels when driven w...
Definition: SwerveModuleConstants.hpp:742
units::current::ampere_t SlipCurrent
The maximum amount of stator current the drive motors can apply without slippage.
Definition: SwerveModuleConstants.hpp:735
constexpr SwerveModuleConstantsFactory & WithSteerMotorGains(configs::Slot0Configs newSteerMotorGains)
Modifies the SteerMotorGains parameter and returns itself.
Definition: SwerveModuleConstants.hpp:906
constexpr SwerveModuleConstantsFactory & WithDriveMotorInitialConfigs(configs::TalonFXConfiguration newDriveMotorInitialConfigs)
Modifies the DriveMotorInitialConfigs parameter and returns itself.
Definition: SwerveModuleConstants.hpp:1039
units::dimensionless::scalar_t SteerMotorGearRatio
Gear ratio between the steer motor and the CANcoder.
Definition: SwerveModuleConstants.hpp:694
units::dimensionless::scalar_t CouplingGearRatio
Coupled gear ratio between the CANcoder and the drive motor.
Definition: SwerveModuleConstants.hpp:703
All constants for a swerve module.
Definition: SwerveModuleConstants.hpp:53
int DriveMotorId
CAN ID of the drive motor.
Definition: SwerveModuleConstants.hpp:63
units::velocity::meters_per_second_t SpeedAt12Volts
When using open-loop drive control, this specifies the speed at which the robot travels when driven w...
Definition: SwerveModuleConstants.hpp:146
constexpr SwerveModuleConstants & WithWheelRadius(units::length::meter_t newWheelRadius)
Modifies the WheelRadius parameter and returns itself.
Definition: SwerveModuleConstants.hpp:407
constexpr SwerveModuleConstants & WithSteerInertia(units::moment_of_inertia::kilogram_square_meter_t newSteerInertia)
Modifies the SteerInertia parameter and returns itself.
Definition: SwerveModuleConstants.hpp:629
units::length::meter_t WheelRadius
Radius of the driving wheel in meters.
Definition: SwerveModuleConstants.hpp:111
constexpr SwerveModuleConstants & WithSteerFrictionVoltage(units::voltage::volt_t newSteerFrictionVoltage)
Modifies the SteerFrictionVoltage parameter and returns itself.
Definition: SwerveModuleConstants.hpp:657
constexpr SwerveModuleConstants & WithCouplingGearRatio(units::dimensionless::scalar_t newCouplingGearRatio)
Modifies the CouplingGearRatio parameter and returns itself.
Definition: SwerveModuleConstants.hpp:393
units::moment_of_inertia::kilogram_square_meter_t DriveInertia
Simulated drive inertia.
Definition: SwerveModuleConstants.hpp:227
int CANcoderId
CAN ID of the CANcoder used for azimuth.
Definition: SwerveModuleConstants.hpp:67
constexpr SwerveModuleConstants & WithFeedbackSource(SteerFeedbackType newFeedbackSource)
Modifies the FeedbackSource parameter and returns itself.
Definition: SwerveModuleConstants.hpp:525
units::dimensionless::scalar_t CouplingGearRatio
Coupled gear ratio between the CANcoder and the drive motor.
Definition: SwerveModuleConstants.hpp:107
constexpr SwerveModuleConstants & WithSteerMotorGearRatio(units::dimensionless::scalar_t newSteerMotorGearRatio)
Modifies the SteerMotorGearRatio parameter and returns itself.
Definition: SwerveModuleConstants.hpp:374
configs::Slot0Configs DriveMotorGains
The drive motor closed-loop gains.
Definition: SwerveModuleConstants.hpp:126
constexpr SwerveModuleConstants & WithSteerMotorInitialConfigs(const configs::TalonFXConfiguration &newSteerMotorInitialConfigs)
Modifies the SteerMotorInitialConfigs parameter and returns itself.
Definition: SwerveModuleConstants.hpp:591
constexpr SwerveModuleConstants & WithSteerMotorInverted(bool newSteerMotorInverted)
Modifies the SteerMotorInverted parameter and returns itself.
Definition: SwerveModuleConstants.hpp:345
configs::CANcoderConfiguration CANcoderInitialConfigs
The initial configs used to configure the CANcoder of the swerve module.
Definition: SwerveModuleConstants.hpp:219
constexpr SwerveModuleConstants & WithLocationX(units::length::meter_t newLocationX)
Modifies the LocationX parameter and returns itself.
Definition: SwerveModuleConstants.hpp:302
bool DriveMotorInverted
True if the drive motor is inverted.
Definition: SwerveModuleConstants.hpp:85
constexpr SwerveModuleConstants & WithDriveInertia(units::moment_of_inertia::kilogram_square_meter_t newDriveInertia)
Modifies the DriveInertia parameter and returns itself.
Definition: SwerveModuleConstants.hpp:643
constexpr SwerveModuleConstants & WithDriveMotorId(int newDriveMotorId)
Modifies the DriveMotorId parameter and returns itself.
Definition: SwerveModuleConstants.hpp:259
constexpr SwerveModuleConstants & WithDriveMotorInitialConfigs(const configs::TalonFXConfiguration &newDriveMotorInitialConfigs)
Modifies the DriveMotorInitialConfigs parameter and returns itself.
Definition: SwerveModuleConstants.hpp:557
constexpr SwerveModuleConstants & WithDriveMotorClosedLoopOutput(ClosedLoopOutputType newDriveMotorClosedLoopOutput)
Modifies the DriveMotorClosedLoopOutput parameter and returns itself.
Definition: SwerveModuleConstants.hpp:470
configs::TalonFXConfiguration DriveMotorInitialConfigs
The initial configs used to configure the drive motor of the swerve module.
Definition: SwerveModuleConstants.hpp:181
constexpr SwerveModuleConstants & WithSteerMotorId(int newSteerMotorId)
Modifies the SteerMotorId parameter and returns itself.
Definition: SwerveModuleConstants.hpp:245
constexpr SwerveModuleConstants & WithLocationY(units::length::meter_t newLocationY)
Modifies the LocationY parameter and returns itself.
Definition: SwerveModuleConstants.hpp:317
units::current::ampere_t SlipCurrent
The maximum amount of stator current the drive motors can apply without slippage.
Definition: SwerveModuleConstants.hpp:139
constexpr SwerveModuleConstants & WithSteerMotorGains(const configs::Slot0Configs &newSteerMotorGains)
Modifies the SteerMotorGains parameter and returns itself.
Definition: SwerveModuleConstants.hpp:424
constexpr SwerveModuleConstants & WithCANcoderId(int newCANcoderId)
Modifies the CANcoderId parameter and returns itself.
Definition: SwerveModuleConstants.hpp:273
units::voltage::volt_t DriveFrictionVoltage
Simulated drive voltage required to overcome friction.
Definition: SwerveModuleConstants.hpp:235
units::angle::turn_t CANcoderOffset
Offset of the CANcoder.
Definition: SwerveModuleConstants.hpp:71
units::dimensionless::scalar_t DriveMotorGearRatio
Gear ratio between the drive motor and the wheel.
Definition: SwerveModuleConstants.hpp:93
units::voltage::volt_t SteerFrictionVoltage
Simulated steer voltage required to overcome friction.
Definition: SwerveModuleConstants.hpp:231
bool SteerMotorInverted
True if the steer motor is inverted from the CANcoder.
Definition: SwerveModuleConstants.hpp:89
constexpr SwerveModuleConstants & WithSpeedAt12Volts(units::velocity::meters_per_second_t newSpeedAt12Volts)
Modifies the SpeedAt12Volts parameter and returns itself.
Definition: SwerveModuleConstants.hpp:502
constexpr SwerveModuleConstants & WithDriveMotorGearRatio(units::dimensionless::scalar_t newDriveMotorGearRatio)
Modifies the DriveMotorGearRatio parameter and returns itself.
Definition: SwerveModuleConstants.hpp:359
constexpr SwerveModuleConstants & WithSteerMotorClosedLoopOutput(ClosedLoopOutputType newSteerMotorClosedLoopOutput)
Modifies the SteerMotorClosedLoopOutput parameter and returns itself.
Definition: SwerveModuleConstants.hpp:456
ClosedLoopOutputType SteerMotorClosedLoopOutput
The closed-loop output type to use for the steer motors.
Definition: SwerveModuleConstants.hpp:130
units::moment_of_inertia::kilogram_square_meter_t SteerInertia
Simulated azimuthal inertia.
Definition: SwerveModuleConstants.hpp:223
units::length::meter_t LocationY
The location of this module's wheels relative to the physical center of the robot in meters along the...
Definition: SwerveModuleConstants.hpp:81
constexpr SwerveModuleConstants & WithCANcoderInitialConfigs(const configs::CANcoderConfiguration &newCANcoderInitialConfigs)
Modifies the CANcoderInitialConfigs parameter and returns itself.
Definition: SwerveModuleConstants.hpp:615
ClosedLoopOutputType DriveMotorClosedLoopOutput
The closed-loop output type to use for the drive motors.
Definition: SwerveModuleConstants.hpp:134
units::length::meter_t LocationX
The location of this module's wheels relative to the physical center of the robot in meters along the...
Definition: SwerveModuleConstants.hpp:76
constexpr SwerveModuleConstants & WithSlipCurrent(units::current::ampere_t newSlipCurrent)
Modifies the SlipCurrent parameter and returns itself.
Definition: SwerveModuleConstants.hpp:485
constexpr SwerveModuleConstants & WithDriveMotorInverted(bool newDriveMotorInverted)
Modifies the DriveMotorInverted parameter and returns itself.
Definition: SwerveModuleConstants.hpp:331
SteerFeedbackType FeedbackSource
Choose how the feedback sensors should be configured.
Definition: SwerveModuleConstants.hpp:159
constexpr SwerveModuleConstants & WithDriveFrictionVoltage(units::voltage::volt_t newDriveFrictionVoltage)
Modifies the DriveFrictionVoltage parameter and returns itself.
Definition: SwerveModuleConstants.hpp:671
constexpr SwerveModuleConstants & WithDriveMotorGains(const configs::Slot0Configs &newDriveMotorGains)
Modifies the DriveMotorGains parameter and returns itself.
Definition: SwerveModuleConstants.hpp:442
configs::Slot0Configs SteerMotorGains
The steer motor closed-loop gains.
Definition: SwerveModuleConstants.hpp:118
constexpr SwerveModuleConstants & WithCANcoderOffset(units::angle::turn_t newCANcoderOffset)
Modifies the CANcoderOffset parameter and returns itself.
Definition: SwerveModuleConstants.hpp:287
configs::TalonFXConfiguration SteerMotorInitialConfigs
The initial configs used to configure the steer motor of the swerve module.
Definition: SwerveModuleConstants.hpp:205
int SteerMotorId
CAN ID of the steer motor.
Definition: SwerveModuleConstants.hpp:59
units::dimensionless::scalar_t SteerMotorGearRatio
Gear ratio between the steer motor and the CANcoder.
Definition: SwerveModuleConstants.hpp:98