Package frc.spectrumLib.sim
Class RollerConfig
java.lang.Object
frc.spectrumLib.sim.RollerConfig
Configuration data for a roller mechanism simulation. Stores physical properties, display colors,
canvas position, and optional mount attachment used by
RollerSim.-
Constructor Summary
ConstructorsConstructorDescriptionRollerConfig(double diameterInches) Creates a RollerConfig for a roller with the given diameter. -
Method Summary
Modifier and TypeMethodDescriptionintNumber of radial lines used to draw the roller circle in the Mechanism2d canvas.Color displayed when the roller is spinning in the forward direction.doubleGear ratio between the motor and the roller output shaft.doubleInitial X position of the roller axle in the Mechanism2d canvas (metres).doubleInitial Y position of the roller axle in the Mechanism2d canvas (metres).doubleAngle of the mount at simulation start (radians).doubleX position of the mount at simulation start (metres).doubleY position of the mount at simulation start (metres).getMount()The parent mount this roller is attached to, ornullif not mounted.Color displayed when the roller is stationary or below the velocity threshold.Color displayed when the roller is spinning in the reverse direction.doubleOuter diameter of the roller in inches, used for physics and visual scaling.doubleMoment of inertia of the roller used by the flywheel physics simulation (kg·m²).booleanWhether this roller is attached to a parentMount.setGearRatio(double ratio) Sets the gear ratio between the motor and the roller output shaft.Attaches this roller to anArmSimmount so its axle tracks the arm tip's position.Attaches this roller to aLinearSimmount so its axle tracks the linear stage's position.setPosition(double x, double y) Sets the initial position of the roller axle in the Mechanism2d canvas.setSimMOI(double moi) Sets the moment of inertia used by the flywheel physics simulation.
-
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
-
setGearRatio
Sets the gear ratio between the motor and the roller output shaft.- Parameters:
ratio- gear ratio (motor rotations per roller rotation)- Returns:
- this config for chaining
-
setSimMOI
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
Sets the initial position of the roller axle in the Mechanism2d canvas.- Parameters:
x- initial X position in metresy- initial Y position in metres- Returns:
- this config for chaining
-
setMount
Attaches this roller to aLinearSimmount so its axle tracks the linear stage's position.- Parameters:
sim- the linear stage to mount onto, ornullto leave unmounted- Returns:
- this config for chaining
-
setMount
Attaches this roller to anArmSimmount so its axle tracks the arm tip's position.- Parameters:
sim- the parent arm to mount onto, ornullto 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
Color displayed when the roller is stationary or below the velocity threshold. -
getFwdColor
Color displayed when the roller is spinning in the forward direction. -
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 parentMount. -
getMount
The parent mount this roller is attached to, ornullif 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).
-