Package swervelib.simulation
Class SwerveModuleSimulation
java.lang.Object
swervelib.simulation.SwerveModuleSimulation
Class to hold simulation data for
SwerveModule-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate doubleTime delta since last updateprivate doubleFake motor position.private doubleThe fake speed of the previous state, used to calculatefakePos.private doubleLast time queried.private SwerveModuleState2Current simulated swerve module state.private final edu.wpi.first.wpilibj.TimerMain timer to simulate the passage of time. -
Constructor Summary
ConstructorsConstructorDescriptionCreate simulation class and initialize module at 0. -
Method Summary
Modifier and TypeMethodDescriptionedu.wpi.first.math.kinematics.SwerveModulePositionGet the simulated swerve module position.getState()Get theSwerveModuleState2of the simulated module.voidupdateStateAndPosition(SwerveModuleState2 desiredState) Update the position and state of the module.
-
Field Details
-
timer
private final edu.wpi.first.wpilibj.Timer timerMain timer to simulate the passage of time. -
dt
private double dtTime delta since last update -
fakePos
private double fakePosFake motor position. -
fakeSpeed
private double fakeSpeedThe fake speed of the previous state, used to calculatefakePos. -
lastTime
private double lastTimeLast time queried. -
state
Current simulated swerve module state.
-
-
Constructor Details
-
SwerveModuleSimulation
public SwerveModuleSimulation()Create simulation class and initialize module at 0.
-
-
Method Details
-
updateStateAndPosition
Update the position and state of the module. Called fromSwerveModule.setDesiredState(swervelib.math.SwerveModuleState2, boolean, boolean)function when simulated.- Parameters:
desiredState- State the swerve module is set to.
-
getPosition
public edu.wpi.first.math.kinematics.SwerveModulePosition getPosition()Get the simulated swerve module position.- Returns:
SwerveModulePositionof the simulated module.
-
getState
Get theSwerveModuleState2of the simulated module.- Returns:
SwerveModuleState2of the simulated module.
-