Package com.marslib.mechanisms
Class LinearMechanismIOSim
java.lang.Object
com.marslib.mechanisms.LinearMechanismIOSim
- All Implemented Interfaces:
LinearMechanismIO
Simulation implementation of the LinearMechanismIO interface. Uses Dyn4j to run a rigid-body
physics simulation of a 1D elevator mechanism.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.marslib.mechanisms.LinearMechanismIO
LinearMechanismIO.LinearMechanismIOInputs -
Constructor Summary
ConstructorsConstructorDescriptionLinearMechanismIOSim(String mechanismName, double gearRatio, double spoolDiameterMeters, double massKg) Constructs a physical simulation instance for a 1D linear elevator mechanism. -
Method Summary
Modifier and TypeMethodDescriptionvoidsetClosedLoopPosition(double positionMeters, double feedforwardVolts) Runs a low latency closed-loop 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.LinearMechanismIO
setBrakeMode, setCurrentLimit
-
Constructor Details
-
LinearMechanismIOSim
public LinearMechanismIOSim(String mechanismName, double gearRatio, double spoolDiameterMeters, double massKg) Constructs a physical simulation instance for a 1D linear elevator mechanism.This models the mechanism as a Dyn4j prismatic joint and accurately calculates forces based on an attached Kraken X60 motor and the physical spool parameters.
- Parameters:
mechanismName- The unique identifier used for AdvantageKit logging (e.g. "Elevator").gearRatio- The total gear reduction from motor to spool (e.g., 25.0 for a 25:1 reduction).spoolDiameterMeters- The diameter of the driven spool in meters.massKg- The physical mass of the moving carriage and its load in kilograms.
-
-
Method Details
-
updateInputs
- Specified by:
updateInputsin interfaceLinearMechanismIO
-
setVoltage
public void setVoltage(double volts) - Specified by:
setVoltagein interfaceLinearMechanismIO
-
setClosedLoopPosition
public void setClosedLoopPosition(double positionMeters, double feedforwardVolts) Description copied from interface:LinearMechanismIORuns a low latency closed-loop profile on motor with external feedforward.- Specified by:
setClosedLoopPositionin interfaceLinearMechanismIO
-