Class ArmConfig

java.lang.Object
frc.spectrumLib.sim.ArmConfig

public class ArmConfig extends Object
Configuration data for an arm simulation. Stores physical properties, display settings, and optional mount attachment used by ArmSim.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ArmConfig(double initialX, double initialY, double ratio, double length, double minAngleDegrees, double maxAngleDegrees, double startingAngleDegrees)
    Creates an ArmConfig with the required physical and display parameters.
  • Method Summary

    Modifier and Type
    Method
    Description
    Color used to draw the arm ligament in the Mechanism2d canvas.
    double
    Initial X position of the arm pivot in the Mechanism2d canvas (metres).
    double
    Initial Y position of the arm pivot in the Mechanism2d canvas (metres).
    double
    Angle of the mount at simulation start (radians).
    double
    X position of the mount at simulation start (metres).
    double
    Y position of the mount at simulation start (metres).
    double
    Visual length of the arm ligament in the Mechanism2d canvas (metres).
    double
    Maximum allowable arm angle (radians).
    double
    Minimum allowable arm angle (radians).
    The parent mount this arm is attached to, or null if not mounted.
    int
    Number of Kraken X60 motors driving the arm.
    double
    Current X position of the arm pivot used during simulation updates (metres).
    double
    Current Y position of the arm pivot used during simulation updates (metres).
    double
    Motor rotations required for one full revolution of the arm mechanism.
    double
    Distance from the pivot to the arm's centre of gravity used by the physics simulation (metres).
    double
    Moment of inertia used by the physics simulation (kg·m²).
    double
    Arm angle at the start of the simulation (radians).
    boolean
    When true the arm's visual angle is expressed in absolute robot-frame degrees; when false it is relative to the parent mount's current angle.
    boolean
    Whether this arm is attached to a parent Mount.
    boolean
    Whether the physics simulation should apply gravitational force to the arm.
    Sets the arm's display color in the Mechanism2d canvas.
    void
    setInitialX(double initialX)
    Initial X position of the arm pivot in the Mechanism2d canvas (metres).
    void
    setInitialY(double initialY)
    Initial Y position of the arm pivot in the Mechanism2d canvas (metres).
    void
    setLength(double length)
    Visual length of the arm ligament in the Mechanism2d canvas (metres).
    void
    setMaxAngle(double maxAngle)
    Maximum allowable arm angle (radians).
    void
    setMinAngle(double minAngle)
    Minimum allowable arm angle (radians).
    setMount(ArmSim sim, boolean absAngle)
    Attaches this arm to a parent ArmSim mount so its pivot tracks the parent arm's tip position.
    setMount(LinearSim sim, boolean fixedAngle)
    Attaches this arm to a LinearSim mount so its pivot tracks the linear stage's position.
    void
    setNumMotors(int numMotors)
    Number of Kraken X60 motors driving the arm.
    void
    setPivotX(double pivotX)
    Current X position of the arm pivot used during simulation updates (metres).
    void
    setPivotY(double pivotY)
    Current Y position of the arm pivot used during simulation updates (metres).
    void
    setRatio(double ratio)
    Motor rotations required for one full revolution of the arm mechanism.
    void
    setSimCGLength(double simCGLength)
    Distance from the pivot to the arm's centre of gravity used by the physics simulation (metres).
    void
    setSimMOI(double simMOI)
    Moment of inertia used by the physics simulation (kg·m²).
    setSimulatedGravity(boolean simulateGravity)
     
    void
    setSimulateGravity(boolean simulateGravity)
    Whether the physics simulation should apply gravitational force to the arm.
    void
    setStartingAngle(double startingAngle)
    Arm angle at the start of the simulation (radians).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ArmConfig

      public ArmConfig(double initialX, double initialY, double ratio, double length, double minAngleDegrees, double maxAngleDegrees, double startingAngleDegrees)
      Creates an ArmConfig with the required physical and display parameters. Angle arguments are specified in degrees and stored internally as radians.
      Parameters:
      initialX - initial X position of the pivot in the Mechanism2d canvas (metres)
      initialY - initial Y position of the pivot in the Mechanism2d canvas (metres)
      ratio - motor rotations per one full arm revolution
      length - visual arm length in the Mechanism2d canvas (metres)
      minAngleDegrees - minimum allowable arm angle in degrees
      maxAngleDegrees - maximum allowable arm angle in degrees
      startingAngleDegrees - initial arm angle in degrees
  • Method Details

    • setColor

      public ArmConfig setColor(Color8Bit color)
      Sets the arm's display color in the Mechanism2d canvas.
      Parameters:
      color - the color to use
      Returns:
      this config for chaining
    • setSimulatedGravity

      public ArmConfig setSimulatedGravity(boolean simulateGravity)
    • setMount

      public ArmConfig setMount(LinearSim sim, boolean fixedAngle)
      Attaches this arm to a LinearSim mount so its pivot tracks the linear stage's position.
      Parameters:
      sim - the linear stage to mount onto, or null to leave unmounted
      fixedAngle - when true the arm angle is treated as absolute; when false it is relative to the mount's current angle
      Returns:
      this config for chaining
    • setMount

      public ArmConfig setMount(ArmSim sim, boolean absAngle)
      Attaches this arm to a parent ArmSim mount so its pivot tracks the parent arm's tip position.
      Parameters:
      sim - the parent arm to mount onto, or null to leave unmounted
      absAngle - when true the arm angle is expressed in the absolute robot frame; when false it is relative to the parent arm's current angle
      Returns:
      this config for chaining
    • getNumMotors

      public int getNumMotors()
      Number of Kraken X60 motors driving the arm.
    • setNumMotors

      public void setNumMotors(int numMotors)
      Number of Kraken X60 motors driving the arm.
    • getInitialX

      public double getInitialX()
      Initial X position of the arm pivot in the Mechanism2d canvas (metres).
    • setInitialX

      public void setInitialX(double initialX)
      Initial X position of the arm pivot in the Mechanism2d canvas (metres).
    • getInitialY

      public double getInitialY()
      Initial Y position of the arm pivot in the Mechanism2d canvas (metres).
    • setInitialY

      public void setInitialY(double initialY)
      Initial Y position of the arm pivot in the Mechanism2d canvas (metres).
    • getPivotX

      public double getPivotX()
      Current X position of the arm pivot used during simulation updates (metres).
    • setPivotX

      public void setPivotX(double pivotX)
      Current X position of the arm pivot used during simulation updates (metres).
    • getPivotY

      public double getPivotY()
      Current Y position of the arm pivot used during simulation updates (metres).
    • setPivotY

      public void setPivotY(double pivotY)
      Current Y position of the arm pivot used during simulation updates (metres).
    • getRatio

      public double getRatio()
      Motor rotations required for one full revolution of the arm mechanism.
    • setRatio

      public void setRatio(double ratio)
      Motor rotations required for one full revolution of the arm mechanism.
    • getLength

      public double getLength()
      Visual length of the arm ligament in the Mechanism2d canvas (metres).
    • setLength

      public void setLength(double length)
      Visual length of the arm ligament in the Mechanism2d canvas (metres).
    • getSimMOI

      public double getSimMOI()
      Moment of inertia used by the physics simulation (kg·m²).
    • setSimMOI

      public void setSimMOI(double simMOI)
      Moment of inertia used by the physics simulation (kg·m²).
    • getSimCGLength

      public double getSimCGLength()
      Distance from the pivot to the arm's centre of gravity used by the physics simulation (metres).
    • setSimCGLength

      public void setSimCGLength(double simCGLength)
      Distance from the pivot to the arm's centre of gravity used by the physics simulation (metres).
    • getMinAngle

      public double getMinAngle()
      Minimum allowable arm angle (radians).
    • setMinAngle

      public void setMinAngle(double minAngle)
      Minimum allowable arm angle (radians).
    • getMaxAngle

      public double getMaxAngle()
      Maximum allowable arm angle (radians).
    • setMaxAngle

      public void setMaxAngle(double maxAngle)
      Maximum allowable arm angle (radians).
    • getStartingAngle

      public double getStartingAngle()
      Arm angle at the start of the simulation (radians).
    • setStartingAngle

      public void setStartingAngle(double startingAngle)
      Arm angle at the start of the simulation (radians).
    • isSimulateGravity

      public boolean isSimulateGravity()
      Whether the physics simulation should apply gravitational force to the arm.
    • setSimulateGravity

      public void setSimulateGravity(boolean simulateGravity)
      Whether the physics simulation should apply gravitational force to the arm.
    • isMounted

      public boolean isMounted()
      Whether this arm is attached to a parent Mount.
    • getMount

      public Mount getMount()
      The parent mount this arm is attached to, or null if not mounted.
    • getInitMountX

      public double getInitMountX()
      X position of the mount at simulation start (metres).
    • getInitMountY

      public double getInitMountY()
      Y position of the mount at simulation start (metres).
    • getInitMountAngle

      public double getInitMountAngle()
      Angle of the mount at simulation start (radians).
    • isAbsAngle

      public boolean isAbsAngle()
      When true the arm's visual angle is expressed in absolute robot-frame degrees; when false it is relative to the parent mount's current angle.
    • getColor

      public Color8Bit getColor()
      Color used to draw the arm ligament in the Mechanism2d canvas.