Class ArmConfig

java.lang.Object
frc.spectrumLib.sim.ArmConfig
All Implemented Interfaces:
Mountable.MountedConfig

public class ArmConfig extends Object implements Mountable.MountedConfig
Physical properties, display settings, and the optional parent mount for an ArmSim.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ArmConfig(double initialX, double initialY, double ratio, double length, double minAngleDegrees, double maxAngleDegrees, double startingAngleDegrees)
    Angle arguments arrive in degrees and are stored in radians.
  • Method Summary

    Modifier and Type
    Method
    Description
    Color used to draw the arm ligament in the Mechanism2d canvas.
    double
    Initial pivot X on the Mechanism2d canvas, in metres.
    double
    Initial pivot Y on the Mechanism2d canvas, in 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 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 pivot X in metres, moved every tick while mounted.
    double
    Current pivot Y in metres, moved every tick while mounted.
    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
    True keeps the arm's own angle absolute in the robot frame.
    boolean
     
    boolean
    True when the sim geometry travels opposite the motor's positive direction.
    boolean
     
     
    void
    setInitialX(double initialX)
    Initial pivot X on the Mechanism2d canvas, in metres.
    void
    setInitialY(double initialY)
    Initial pivot Y on the Mechanism2d canvas, in metres.
    void
    setLength(double length)
    Visual length of the arm ligament, in 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 so its pivot follows that arm's tip.
    setMount(LinearSim sim, boolean fixedAngle)
    Attaches this arm to a LinearSim so its pivot follows that stage.
    void
    setNumMotors(int numMotors)
    Number of Kraken X60 motors driving the arm.
    void
    setPivotX(double pivotX)
    Current pivot X in metres, moved every tick while mounted.
    void
    setPivotY(double pivotY)
    Current pivot Y in metres, moved every tick while mounted.
    void
    setRatio(double ratio)
    Motor rotations required for one full revolution of the arm mechanism.
    setReversedLinkage(boolean reversedLinkage)
    Mirrors the simulated motor so the sim's travel matches the motor's positive direction.
    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)
     
    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)
      Angle arguments arrive in degrees and are stored in radians.
      Parameters:
      ratio - motor rotations per one full arm revolution
  • Method Details

    • isMounted

      public boolean isMounted()
    • setReversedLinkage

      public ArmConfig setReversedLinkage(boolean reversedLinkage)
      Mirrors the simulated motor so the sim's travel matches the motor's positive direction. See SimMotor.simState(com.ctre.phoenix6.hardware.TalonFX, boolean).
    • setColor

      public ArmConfig setColor(Color8Bit color)
    • setSimulatedGravity

      public ArmConfig setSimulatedGravity(boolean simulateGravity)
    • setMount

      public ArmConfig setMount(LinearSim sim, boolean fixedAngle)
      Attaches this arm to a LinearSim so its pivot follows that stage.
      Parameters:
      sim - the stage to follow, or null to leave this arm unmounted
      fixedAngle - true treats the arm angle as absolute, false adds the mount's current angle
    • setMount

      public ArmConfig setMount(ArmSim sim, boolean absAngle)
      Attaches this arm to a parent ArmSim so its pivot follows that arm's tip.
      Parameters:
      sim - the arm to follow, or null to leave this arm unmounted
      absAngle - true treats the arm angle as absolute, false adds the parent's current angle
    • 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 pivot X on the Mechanism2d canvas, in metres.
      Specified by:
      getInitialX in interface Mountable.MountedConfig
    • setInitialX

      public void setInitialX(double initialX)
      Initial pivot X on the Mechanism2d canvas, in metres.
    • getInitialY

      public double getInitialY()
      Initial pivot Y on the Mechanism2d canvas, in metres.
      Specified by:
      getInitialY in interface Mountable.MountedConfig
    • setInitialY

      public void setInitialY(double initialY)
      Initial pivot Y on the Mechanism2d canvas, in metres.
    • getPivotX

      public double getPivotX()
      Current pivot X in metres, moved every tick while mounted.
    • setPivotX

      public void setPivotX(double pivotX)
      Current pivot X in metres, moved every tick while mounted.
    • getPivotY

      public double getPivotY()
      Current pivot Y in metres, moved every tick while mounted.
    • setPivotY

      public void setPivotY(double pivotY)
      Current pivot Y in metres, moved every tick while mounted.
    • 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 metres.
    • setLength

      public void setLength(double length)
      Visual length of the arm ligament, in 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()
    • setSimulateGravity

      public void setSimulateGravity(boolean simulateGravity)
    • getMount

      public Mount getMount()
      The parent mount this arm is attached to, or null if not mounted.
      Specified by:
      getMount in interface Mountable.MountedConfig
    • getInitMountX

      public double getInitMountX()
      X position of the mount at simulation start (metres).
      Specified by:
      getInitMountX in interface Mountable.MountedConfig
    • getInitMountY

      public double getInitMountY()
      Y position of the mount at simulation start (metres).
      Specified by:
      getInitMountY in interface Mountable.MountedConfig
    • getInitMountAngle

      public double getInitMountAngle()
      Angle of the mount at simulation start (radians).
      Specified by:
      getInitMountAngle in interface Mountable.MountedConfig
    • isAbsAngle

      public boolean isAbsAngle()
      True keeps the arm's own angle absolute in the robot frame. False adds the parent mount's angle to it, in radians.
    • getColor

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

      public boolean isReversedLinkage()
      True when the sim geometry travels opposite the motor's positive direction.