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. Updates the TalonFX sim state each robot period and animates both a static backing
ligament and a moving stage ligament in a
Mechanism2d canvas. Implements Mount so
other mechanisms can be attached to the moving stage, and implements Mountable so this
stage can itself be attached to a parent mount.-
Nested Class Summary
Nested classes/interfaces inherited from interface Mount
Mount.MountType -
Constructor Summary
ConstructorsConstructorDescriptionLinearSim(LinearConfig config, Mechanism2d mech, TalonFX motor, String name) Creates and registers a linear mechanism simulation. -
Method Summary
Modifier and TypeMethodDescriptiondoublegetAngle()Returns the effective absolute angle of the linear stage in radians, adding the parent mount's angle when mounted.Configuration containing physical properties and display settings for this linear stage.doubleReturns the horizontal component of the stage's current displacement from its initial position, accounting for the parent mount's angle when mounted.doubleReturns the vertical component of the stage's current displacement from its initial position, accounting for the parent mount's angle when mounted.AlwaysMount.MountType.LINEAR; used by child mechanisms to determine positioning logic.doubleReturns the X coordinate of the static root of this stage, used by child mechanisms as their mount point.doubleReturns the Y coordinate of the static root of this stage, used by child mechanisms as their mount point.voidupdate(double dt) Advances the elevator physics simulation by one robot period, updates the TalonFX rotor position and velocity, and refreshes both the static and moving Mechanism2d ligaments.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Mountable
getUpdatedX, getUpdatedX, getUpdatedX, getUpdatedX, getUpdatedY, getUpdatedY, getUpdatedY, getUpdatedY
-
Constructor Details
-
LinearSim
Creates and registers a linear mechanism simulation.- Parameters:
config- physical and display configuration for the linear stagemech- the Mechanism2d canvas to draw the stage onmotor- the TalonFX driving the stagename- unique name prefix used for Mechanism2d element labels
-
-
Method Details
-
update
public void update(double dt) Advances the elevator physics simulation by one robot period, updates the TalonFX rotor position and velocity, and refreshes both the static and moving Mechanism2d ligaments. -
getDisplacementX
public double getDisplacementX()Returns the horizontal component of the stage's current displacement from its initial position, accounting for the parent mount's angle when mounted.- Specified by:
getDisplacementXin interfaceMount- Returns:
- horizontal displacement in metres
-
getDisplacementY
public double getDisplacementY()Returns the vertical component of the stage's current displacement from its initial position, accounting for the parent mount's angle when mounted.- Specified by:
getDisplacementYin interfaceMount- Returns:
- vertical displacement in metres
-
getAngle
-
getMountX
-
getMountY
-
getConfig
Configuration containing physical properties and display settings for this linear stage. -
getMountType
AlwaysMount.MountType.LINEAR; used by child mechanisms to determine positioning logic.- Specified by:
getMountTypein interfaceMount- Returns:
- this mount's
Mount.MountType
-