Class RollerConfig

java.lang.Object
frc.spectrumLib.sim.RollerConfig

public class RollerConfig extends Object
Configuration data for a roller mechanism simulation. Stores physical properties, display colors, canvas position, and optional mount attachment used by RollerSim.
  • Constructor Details

    • RollerConfig

      public RollerConfig(double diameterInches)
      Creates a RollerConfig for a roller with the given diameter.
      Parameters:
      diameterInches - outer diameter of the roller in inches
  • Method Details

    • setReversedLinkage

      public RollerConfig 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).
      Parameters:
      reversedLinkage - true when the sim travels opposite the motor
      Returns:
      this config, for chaining
    • setGearRatio

      public RollerConfig setGearRatio(double ratio)
      Sets the gear ratio.
      Parameters:
      ratio - the ratio of motor speed to roller speed
      Returns:
      this config, for chaining
    • setSimMOI

      public RollerConfig setSimMOI(double moi)
      Sets the moment of inertia used by the flywheel physics simulation.
      Parameters:
      moi - moment of inertia in kg·m²
      Returns:
      this config for chaining
    • setPosition

      public RollerConfig setPosition(double x, double y)
      Sets the initial position of the roller axle in the Mechanism2d canvas.
      Parameters:
      x - initial X position in metres
      y - initial Y position in metres
      Returns:
      this config for chaining
    • setMount

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

      public RollerConfig setMount(ArmSim sim)
      Attaches this roller to an ArmSim mount so its axle tracks the arm tip's position.
      Parameters:
      sim - the parent arm to mount onto, or null to leave unmounted
      Returns:
      this config for chaining
    • getRollerDiameterInches

      public double getRollerDiameterInches()
      Outer diameter of the roller in inches, used for physics and visual scaling.
    • getBackgroundLines

      public int getBackgroundLines()
      Number of radial lines used to draw the roller circle in the Mechanism2d canvas.
    • getGearRatio

      public double getGearRatio()
      Gear ratio between the motor and the roller output shaft.
    • getSimMOI

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

      public Color8Bit getOffColor()
      Color displayed when the roller is stationary or below the velocity threshold.
    • getFwdColor

      public Color8Bit getFwdColor()
      Color displayed when the roller is spinning in the forward direction.
    • getRevColor

      public Color8Bit getRevColor()
      Color displayed when the roller is spinning in the reverse direction.
    • getInitialX

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

      public double getInitialY()
      Initial Y position of the roller axle in the Mechanism2d canvas (metres).
    • isMounted

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

      public Mount getMount()
      The parent mount this roller 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).
    • isReversedLinkage

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