Package frc.spectrumLib.sim
Class ArmSim
java.lang.Object
frc.spectrumLib.sim.ArmSim
WPILib-backed simulation of a single-jointed arm driven by one or more Kraken X60 motors.
Advances the TalonFX sim state on the shared
SimLoop thread and animates the arm in a
Mechanism2d canvas. Implements Mount so other mechanisms can attach to the arm
tip, and Mountable so this arm 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoublegetAngle()The arm's own angle, plus the parent mount's angle unless the config asked for an absolute angle.doubledoubleHow far the pivot has moved horizontally from its initial position.doubleHow far the pivot has moved vertically from its initial position.AlwaysMount.MountType.ARM, so children apply arm placement.doubleThe X coordinate of the arm pivot, which a child attaches to.doubleThe Y coordinate of the arm pivot, which a child attaches to.voidupdate(double dt) One sim tick: steps the arm physics, 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
-
ArmSim
- Parameters:
mech- the Mechanism2d canvas to draw the arm onname- prefix for this sim's Mechanism2d element labels
-
-
Method Details
-
update
public void update(double dt) One sim tick: steps the arm physics, feeds the rotor state back, and redraws. -
getAngleRads
public double getAngleRads() -
getDisplacementX
public double getDisplacementX()How far the pivot has moved horizontally from its initial position.- Specified by:
getDisplacementXin interfaceMount- Returns:
- horizontal displacement in metres
-
getDisplacementY
public double getDisplacementY()How far the pivot has moved vertically from its initial position.- Specified by:
getDisplacementYin interfaceMount- Returns:
- vertical displacement in metres
-
getAngle
public double getAngle()The arm's own angle, plus the parent mount's angle unless the config asked for an absolute angle. -
getMountX
public double getMountX()The X coordinate of the arm pivot, which a child attaches to. -
getMountY
public double getMountY()The Y coordinate of the arm pivot, which a child attaches to. -
getConfig
-
getMountType
AlwaysMount.MountType.ARM, so children apply arm placement.- Specified by:
getMountTypein interfaceMount
-