Package com.marslib.mechanisms
Class RotaryMechanismIOSim
java.lang.Object
com.marslib.mechanisms.RotaryMechanismIOSim
- All Implemented Interfaces:
RotaryMechanismIO
Simulation implementation of the RotaryMechanismIO interface. Uses Dyn4j to run a rigid-body
physics simulation of a 1D rotary arm mechanism.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.marslib.mechanisms.RotaryMechanismIO
RotaryMechanismIO.RotaryMechanismIOInputs -
Constructor Summary
ConstructorsConstructorDescriptionRotaryMechanismIOSim(String mechanismName, double gearRatio, double jKgMetersSquared, double lengthMeters) Constructs a physical simulation instance for a 1D rotary arm mechanism. -
Method Summary
Modifier and TypeMethodDescriptionvoidsetClosedLoopPosition(double positionRad, 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.RotaryMechanismIO
setBrakeMode, setCurrentLimit, setEncoderPosition
-
Constructor Details
-
RotaryMechanismIOSim
public RotaryMechanismIOSim(String mechanismName, double gearRatio, double jKgMetersSquared, double lengthMeters) Constructs a physical simulation instance for a 1D rotary arm mechanism.This models the mechanism as a Dyn4j revolute joint and accurately calculates rotational inertia and forces based on an attached Kraken X60 motor.
- Parameters:
mechanismName- The unique identifier used for AdvantageKit logging (e.g. "Arm").gearRatio- The total gear reduction from motor to arm axis.jKgMetersSquared- The total moment of inertia of the rotating arm in kg*m^2.lengthMeters- The physical extended length of the arm for visualization and density mapping.
-
-
Method Details
-
updateInputs
- Specified by:
updateInputsin interfaceRotaryMechanismIO
-
setVoltage
public void setVoltage(double volts) - Specified by:
setVoltagein interfaceRotaryMechanismIO
-
setClosedLoopPosition
public void setClosedLoopPosition(double positionRad, double feedforwardVolts) Description copied from interface:RotaryMechanismIORuns a low latency closed-loop profile on motor with external feedforward.- Specified by:
setClosedLoopPositionin interfaceRotaryMechanismIO
-