Class LinearConfig

java.lang.Object
frc.spectrumLib.sim.LinearConfig

public class LinearConfig extends Object
Configuration data for a linear (elevator-style) mechanism simulation. Stores physical properties, Mechanism2d display settings, and optional mount attachment used by LinearSim.
  • Constructor Summary

    Constructors
    Constructor
    Description
    LinearConfig(double x, double y, double gearing, double drumRadius)
    Creates a LinearConfig with the minimum required positioning and mechanical parameters.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Angle of the linear stage in the Mechanism2d canvas (degrees; 0 = horizontal, 90 = vertical, CCW positive).
    double
    Mass of the moving carriage in kilograms, used by the physics simulation.
    Color of the moving stage ligament in the Mechanism2d canvas.
    double
    Radius of the elevator drum in metres, used to convert rotations to linear position.
    double
    Gear ratio between the motor and the elevator drum.
    double
    Initial X position of the static root in the Mechanism2d canvas (metres).
    double
    Initial Y position of the static root 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
    Stroke width of the stage ligaments in the Mechanism2d canvas.
    double
    Maximum travel height of the mechanism in metres.
    double
    Minimum travel height of the mechanism in metres.
    The parent mount this linear stage is attached to, or null if not mounted.
    double
    Visual length of the moving stage ligament in the Mechanism2d canvas (metres).
    int
    Number of Kraken X60 motors driving the linear stage.
    double
    Visual length of the static (non-moving) stage ligament in the Mechanism2d canvas (metres).
    double
    Current X position of the static root, updated when mounted (metres).
    double
    Current Y position of the static root, updated when mounted (metres).
    boolean
    Whether this linear stage is attached to a parent Mount.
    setAngle(double angle)
    Sets the orientation angle of the linear stage in the Mechanism2d canvas.
    setCarriageMass(double carriageMassKg)
    Sets the carriage mass used by the physics simulation.
    Sets the color of the moving stage ligament in the Mechanism2d canvas.
    setLineWidth(double lineWidth)
    Sets the stroke width of the stage ligaments in the Mechanism2d canvas.
    setMaxHeight(double lengthInches)
    Sets the maximum travel height of the mechanism.
    Attaches this linear stage to a parent ArmSim mount so its root tracks the arm tip's position.
    Attaches this linear stage to a parent LinearSim mount so its root tracks the parent stage's position.
    setMovingLength(double lengthInches)
    Sets the visual length of the moving stage ligament.
    setNumMotors(int numMotors)
    Sets the number of motors driving this linear stage.
    setStaticLength(double lengthInches)
    Sets the visual length of the static (non-moving) stage ligament.
    void
    setStaticRootX(double staticRootX)
    Current X position of the static root, updated when mounted (metres).
    void
    setStaticRootY(double staticRootY)
    Current Y position of the static root, updated when mounted (metres).

    Methods inherited from class java.lang.Object

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

    • LinearConfig

      public LinearConfig(double x, double y, double gearing, double drumRadius)
      Creates a LinearConfig with the minimum required positioning and mechanical parameters.
      Parameters:
      x - initial X position of the stage root in the Mechanism2d canvas (metres)
      y - initial Y position of the stage root in the Mechanism2d canvas (metres)
      gearing - gear ratio between the motor and the elevator drum
      drumRadius - radius of the elevator drum in metres
  • Method Details

    • setNumMotors

      public LinearConfig setNumMotors(int numMotors)
      Sets the number of motors driving this linear stage.
      Parameters:
      numMotors - number of Kraken X60 motors
      Returns:
      this config for chaining
    • setCarriageMass

      public LinearConfig setCarriageMass(double carriageMassKg)
      Sets the carriage mass used by the physics simulation.
      Parameters:
      carriageMassKg - mass of the moving carriage in kilograms
      Returns:
      this config for chaining
    • setAngle

      public LinearConfig setAngle(double angle)
      Sets the orientation angle of the linear stage in the Mechanism2d canvas.
      Parameters:
      angle - angle in degrees (0 = horizontal, 90 = vertical, CCW positive)
      Returns:
      this config for chaining
    • setColor

      public LinearConfig setColor(Color8Bit color)
      Sets the color of the moving stage ligament in the Mechanism2d canvas.
      Parameters:
      color - the display color
      Returns:
      this config for chaining
    • setLineWidth

      public LinearConfig setLineWidth(double lineWidth)
      Sets the stroke width of the stage ligaments in the Mechanism2d canvas.
      Parameters:
      lineWidth - stroke width in pixels
      Returns:
      this config for chaining
    • setStaticLength

      public LinearConfig setStaticLength(double lengthInches)
      Sets the visual length of the static (non-moving) stage ligament.
      Parameters:
      lengthInches - length in inches; stored internally as metres
      Returns:
      this config for chaining
    • setMovingLength

      public LinearConfig setMovingLength(double lengthInches)
      Sets the visual length of the moving stage ligament.
      Parameters:
      lengthInches - length in inches; stored internally as metres
      Returns:
      this config for chaining
    • setMaxHeight

      public LinearConfig setMaxHeight(double lengthInches)
      Sets the maximum travel height of the mechanism.
      Parameters:
      lengthInches - maximum height in inches; stored internally as metres
      Returns:
      this config for chaining
    • setMount

      public LinearConfig setMount(LinearSim sim)
      Attaches this linear stage to a parent LinearSim mount so its root tracks the parent stage's position.
      Parameters:
      sim - the parent linear stage to mount onto, or null to leave unmounted
      Returns:
      this config for chaining
    • setMount

      public LinearConfig setMount(ArmSim sim)
      Attaches this linear stage to a parent ArmSim mount so its root tracks the arm tip's position.
      Parameters:
      sim - the parent arm to mount onto, or null to leave unmounted
      Returns:
      this config for chaining
    • getNumMotors

      public int getNumMotors()
      Number of Kraken X60 motors driving the linear stage.
    • getElevatorGearing

      public double getElevatorGearing()
      Gear ratio between the motor and the elevator drum.
    • getCarriageMassKg

      public double getCarriageMassKg()
      Mass of the moving carriage in kilograms, used by the physics simulation.
    • getDrumRadius

      public double getDrumRadius()
      Radius of the elevator drum in metres, used to convert rotations to linear position.
    • getMinHeight

      public double getMinHeight()
      Minimum travel height of the mechanism in metres.
    • getMaxHeight

      public double getMaxHeight()
      Maximum travel height of the mechanism in metres.
    • getAngle

      public double getAngle()
      Angle of the linear stage in the Mechanism2d canvas (degrees; 0 = horizontal, 90 = vertical, CCW positive).
    • getColor

      public Color8Bit getColor()
      Color of the moving stage ligament in the Mechanism2d canvas.
    • getLineWidth

      public double getLineWidth()
      Stroke width of the stage ligaments in the Mechanism2d canvas.
    • getInitialX

      public double getInitialX()
      Initial X position of the static root in the Mechanism2d canvas (metres).
    • getInitialY

      public double getInitialY()
      Initial Y position of the static root in the Mechanism2d canvas (metres).
    • getStaticRootX

      public double getStaticRootX()
      Current X position of the static root, updated when mounted (metres).
    • setStaticRootX

      public void setStaticRootX(double staticRootX)
      Current X position of the static root, updated when mounted (metres).
    • getStaticRootY

      public double getStaticRootY()
      Current Y position of the static root, updated when mounted (metres).
    • setStaticRootY

      public void setStaticRootY(double staticRootY)
      Current Y position of the static root, updated when mounted (metres).
    • getStaticLength

      public double getStaticLength()
      Visual length of the static (non-moving) stage ligament in the Mechanism2d canvas (metres).
    • getMovingLength

      public double getMovingLength()
      Visual length of the moving stage ligament in the Mechanism2d canvas (metres).
    • isMounted

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

      public Mount getMount()
      The parent mount this linear stage 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).