Package frc.spectrumLib.sim
Class LinearSim
java.lang.Object
frc.spectrumLib.sim.LinearSim
WPILib-backed simulation of a linear (elevator-style) mechanism driven by one or more Kraken X60
motors. Advances the TalonFX sim state on the shared
SimLoop thread and animates a static
backing ligament plus a moving stage ligament in a Mechanism2d canvas. Implements Mount so other mechanisms can attach to the moving stage, and Mountable so this stage
can itself attach to a parent mount.-
Nested Class Summary
Nested classes/interfaces inherited from interface frc.spectrumLib.sim.Mount
Mount.MountTypeNested classes/interfaces inherited from interface frc.spectrumLib.sim.Mountable
Mountable.MountedConfig -
Constructor Summary
ConstructorsConstructorDescriptionLinearSim(LinearConfig config, Mechanism2d mech, TalonFX motor, String name) -
Method Summary
Modifier and TypeMethodDescriptiondoublegetAngle()Stage angle in radians, plus the parent mount's angle when mounted.doubleHorizontal distance the carriage has travelled, projected along the stage angle.doubleVertical distance the carriage has travelled, projected along the stage angle.AlwaysMount.MountType.LINEAR, so children apply linear placement.doubleThe X coordinate of this stage's static root, which a child attaches to.doubleThe Y coordinate of this stage's static root, which a child attaches to.voidupdate(double dt) One sim tick: steps the elevator, feeds the rotor state back, and redraws.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface frc.spectrumLib.sim.Mountable
getUpdatedX, getUpdatedX, getUpdatedY, getUpdatedY
-
Constructor Details
-
LinearSim
- Parameters:
mech- the Mechanism2d canvas to draw the stage onname- prefix for this sim's Mechanism2d element labels
-
-
Method Details
-
update
public void update(double dt) One sim tick: steps the elevator, feeds the rotor state back, and redraws. -
getDisplacementX
public double getDisplacementX()Horizontal distance the carriage has travelled, projected along the stage angle.- Specified by:
getDisplacementXin interfaceMount- Returns:
- horizontal displacement in metres
-
getDisplacementY
public double getDisplacementY()Vertical distance the carriage has travelled, projected along the stage angle.- Specified by:
getDisplacementYin interfaceMount- Returns:
- vertical displacement in metres
-
getAngle
public double getAngle()Stage angle in radians, plus the parent mount's angle when mounted. -
getMountX
public double getMountX()The X coordinate of this stage's static root, which a child attaches to. -
getMountY
public double getMountY()The Y coordinate of this stage's static root, which a child attaches to. -
getConfig
-
getMountType
AlwaysMount.MountType.LINEAR, so children apply linear placement.- Specified by:
getMountTypein interfaceMount
-