Class ModuleIOSim
java.lang.Object
frc.robot.subsystems.drive.module.ModuleIOSim
- All Implemented Interfaces:
ModuleIO
Physics simulation implementation of
ModuleIO.
This class uses SparkMaxSim to simulate the Spark MAX motor controllers, backed by
DCMotorSim physics models for accurate motor behavior. The Spark's built-in closed-loop
PID is used for velocity and position control, matching the real robot's ModuleIOSpark.
-
Nested Class Summary
Nested classes/interfaces inherited from interface frc.robot.subsystems.drive.module.ModuleIO
ModuleIO.ModuleIOInputs -
Constructor Summary
ConstructorsConstructorDescriptionModuleIOSim(int module) Creates a new ModuleIOSim and initializes the simulated Spark MAX motor controllers. -
Method Summary
Modifier and TypeMethodDescriptionvoidsetDriveOpenLoop(Voltage output) Run the drive motor at the specified open loop voltage.voidsetDriveVelocity(AngularVelocity velocity) Run the drive motor at the specified angular velocity.voidsetTurnOpenLoop(Voltage output) Run the turn motor at the specified open loop voltage.voidsetTurnPosition(Angle rotation) Run the turn motor to the specified rotation.voidupdateHighFreq(double timestampSec) Polls high-frequency data for the 200Hz odometry loop.voidupdateInputs(ModuleIO.ModuleIOInputs inputs) Updates the set of loggable inputs.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface frc.robot.subsystems.drive.module.ModuleIO
clearFaults
-
Constructor Details
-
ModuleIOSim
public ModuleIOSim(int module) Creates a new ModuleIOSim and initializes the simulated Spark MAX motor controllers.- Parameters:
module- The module index (0 for front-left, 1 for front-right, 2 for back-left, 3 for back-right).
-
-
Method Details
-
updateHighFreq
public void updateHighFreq(double timestampSec) Description copied from interface:ModuleIOPolls high-frequency data for the 200Hz odometry loop.- Specified by:
updateHighFreqin interfaceModuleIO- Parameters:
timestampSec- The exact timestamp of the current 200Hz tick.
-
updateInputs
Description copied from interface:ModuleIOUpdates the set of loggable inputs.- Specified by:
updateInputsin interfaceModuleIO- Parameters:
inputs- The inputs object to update.
-
setDriveOpenLoop
Description copied from interface:ModuleIORun the drive motor at the specified open loop voltage.- Specified by:
setDriveOpenLoopin interfaceModuleIO- Parameters:
output- The voltage to apply.
-
setTurnOpenLoop
Description copied from interface:ModuleIORun the turn motor at the specified open loop voltage.- Specified by:
setTurnOpenLoopin interfaceModuleIO- Parameters:
output- The voltage to apply.
-
setDriveVelocity
Description copied from interface:ModuleIORun the drive motor at the specified angular velocity.- Specified by:
setDriveVelocityin interfaceModuleIO- Parameters:
velocity- The target velocity in radians per second.
-
setTurnPosition
Description copied from interface:ModuleIORun the turn motor to the specified rotation.- Specified by:
setTurnPositionin interfaceModuleIO- Parameters:
rotation- The target angle as an Angle measure.
-