Package frc.spectrumLib.swerve
Class MapleSimSwerveDrivetrain
java.lang.Object
frc.spectrumLib.swerve.MapleSimSwerveDrivetrain
Injects Maple-Sim data into a CTRE
SwerveDrivetrain. Stands in for SimSwerveDrivetrain.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classPhysics sim for one CTRE swerve module, wired to that module's motor controllers.static classFeeds Maple-Sim's rotor state into a TalonFX's sim state and returns the voltage the motor asks for.static classSteer adapter that also drives the remote CANcoder's sim state. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMapleSimSwerveDrivetrain(Time simPeriod, Mass robotMassWithBumpers, Distance bumperLengthX, Distance bumperWidthY, DCMotor driveMotorModel, DCMotor steerMotorModel, double wheelCOF, Translation2d[] moduleLocations, Pigeon2 pigeon, SwerveModule<TalonFX, TalonFX, CANcoder>[] modules, SwerveModuleConstants<TalonFXConfiguration, TalonFXConfiguration, CANcoderConfiguration>... moduleConstants) Builds the sim starting at pose zero, then takes over the global sim state: it overrides the simulation timings and installs a freshArena2026Rebuiltwith efficiency mode on as the SimulatedArena instance. -
Method Summary
Modifier and TypeMethodDescriptionstatic SwerveModuleConstants<?,?, ?>[] regulateModuleConstantsForSimulation(SwerveModuleConstants<?, ?, ?>[] moduleConstants) Applies simulation-only constant overrides to every module.voidupdate()Steps the arena and copies the resulting yaw and yaw rate into the Pigeon2's sim state.
-
Field Details
-
mapleSimDrive
-
-
Constructor Details
-
MapleSimSwerveDrivetrain
public MapleSimSwerveDrivetrain(Time simPeriod, Mass robotMassWithBumpers, Distance bumperLengthX, Distance bumperWidthY, DCMotor driveMotorModel, DCMotor steerMotorModel, double wheelCOF, Translation2d[] moduleLocations, Pigeon2 pigeon, SwerveModule<TalonFX, TalonFX, CANcoder>[] modules, SwerveModuleConstants<TalonFXConfiguration, TalonFXConfiguration, CANcoderConfiguration>... moduleConstants) Builds the sim starting at pose zero, then takes over the global sim state: it overrides the simulation timings and installs a freshArena2026Rebuiltwith efficiency mode on as the SimulatedArena instance.- Parameters:
moduleLocations- module locations in the order FL, FR, BL, BRdriveMotorModel- drive motor model, typically DCMotor.getKrakenX60Foc()
-
-
Method Details
-
update
public void update()Steps the arena and copies the resulting yaw and yaw rate into the Pigeon2's sim state. -
regulateModuleConstantsForSimulation
public static SwerveModuleConstants<?,?, regulateModuleConstantsForSimulation?>[] (SwerveModuleConstants<?, ?, ?>[] moduleConstants) Applies simulation-only constant overrides to every module. SeeregulateModuleConstantForSimulation(SwerveModuleConstants)for what changes and why.
-