Class ArmSim

java.lang.Object
frc.spectrumLib.sim.ArmSim
All Implemented Interfaces:
Mount, Mountable

public class ArmSim extends Object implements Mount, Mountable
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.
  • Constructor Details

    • ArmSim

      public ArmSim(ArmConfig config, Mechanism2d mech, TalonFX motor, String name)
      Parameters:
      mech - the Mechanism2d canvas to draw the arm on
      name - 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:
      getDisplacementX in interface Mount
      Returns:
      horizontal displacement in metres
    • getDisplacementY

      public double getDisplacementY()
      How far the pivot has moved vertically from its initial position.
      Specified by:
      getDisplacementY in interface Mount
      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.
      Specified by:
      getAngle in interface Mount
      Returns:
      effective arm angle in radians
    • getMountX

      public double getMountX()
      The X coordinate of the arm pivot, which a child attaches to.
      Specified by:
      getMountX in interface Mount
      Returns:
      pivot X position in metres
    • getMountY

      public double getMountY()
      The Y coordinate of the arm pivot, which a child attaches to.
      Specified by:
      getMountY in interface Mount
      Returns:
      pivot Y position in metres
    • getConfig

      public ArmConfig getConfig()
    • getMountType

      public Mount.MountType getMountType()
      Always Mount.MountType.ARM, so children apply arm placement.
      Specified by:
      getMountType in interface Mount