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