Package com.marslib.mechanisms
Class FlywheelIOSim
java.lang.Object
com.marslib.mechanisms.FlywheelIOSim
- All Implemented Interfaces:
FlywheelIO
Simulation implementation of the FlywheelIO interface. Uses WPILib's FlywheelSim to model 1D
rotational dynamics and integrates with the centralized MARSPhysicsWorld electrical model for
realistic battery sag accurately mapped to current draw.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.marslib.mechanisms.FlywheelIO
FlywheelIO.FlywheelIOInputs -
Constructor Summary
ConstructorsConstructorDescriptionFlywheelIOSim(edu.wpi.first.math.system.plant.DCMotor gearbox, double gearing, double momentOfInertiaKgMetersSquared) Constructs a physical simulation instance for a 1D flywheel mechanism. -
Method Summary
Modifier and TypeMethodDescriptionvoidsetClosedLoopVelocity(double velocityRadPerSec, double feedforwardVolts) Runs a low latency closed-loop velocity profile on motor with external feedforward.voidsetVoltage(double volts) voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.marslib.mechanisms.FlywheelIO
setBrakeMode, setCurrentLimit
-
Constructor Details
-
FlywheelIOSim
public FlywheelIOSim(edu.wpi.first.math.system.plant.DCMotor gearbox, double gearing, double momentOfInertiaKgMetersSquared) Constructs a physical simulation instance for a 1D flywheel mechanism.- Parameters:
gearbox- The WPILib DCMotor model representing the physical motor (e.g. Kraken X60).gearing- The total gear reduction from motor to flywheel.momentOfInertiaKgMetersSquared- The moment of inertia of the rotating flywheel in kg*m^2.
-
-
Method Details
-
updateInputs
- Specified by:
updateInputsin interfaceFlywheelIO
-
setVoltage
public void setVoltage(double volts) - Specified by:
setVoltagein interfaceFlywheelIO
-
setClosedLoopVelocity
public void setClosedLoopVelocity(double velocityRadPerSec, double feedforwardVolts) Description copied from interface:FlywheelIORuns a low latency closed-loop velocity profile on motor with external feedforward.- Specified by:
setClosedLoopVelocityin interfaceFlywheelIO
-