Package frc.spectrumLib.sim
Class LinearConfig
java.lang.Object
frc.spectrumLib.sim.LinearConfig
Configuration data for a linear (elevator-style) mechanism simulation. Stores physical
properties, Mechanism2d display settings, and optional mount attachment used by
LinearSim.-
Constructor Summary
ConstructorsConstructorDescriptionLinearConfig(double x, double y, double gearing, double drumRadius) Creates a LinearConfig with the minimum required positioning and mechanical parameters. -
Method Summary
Modifier and TypeMethodDescriptiondoublegetAngle()Angle of the linear stage in the Mechanism2d canvas (degrees; 0 = horizontal, 90 = vertical, CCW positive).doubleMass of the moving carriage in kilograms, used by the physics simulation.getColor()Color of the moving stage ligament in the Mechanism2d canvas.doubleRadius of the elevator drum in metres, used to convert rotations to linear position.doubleGear ratio between the motor and the elevator drum.doubleInitial X position of the static root in the Mechanism2d canvas (metres).doubleInitial Y position of the static root 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).doubleStroke width of the stage ligaments in the Mechanism2d canvas.doubleMaximum travel height of the mechanism in metres.doubleMinimum travel height of the mechanism in metres.getMount()The parent mount this linear stage is attached to, ornullif not mounted.doubleVisual length of the moving stage ligament in the Mechanism2d canvas (metres).intNumber of Kraken X60 motors driving the linear stage.doubleVisual length of the static (non-moving) stage ligament in the Mechanism2d canvas (metres).doubleCurrent X position of the static root, updated when mounted (metres).doubleCurrent Y position of the static root, updated when mounted (metres).booleanWhether this linear stage is attached to a parentMount.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 parentArmSimmount so its root tracks the arm tip's position.Attaches this linear stage to a parentLinearSimmount 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.voidsetStaticRootX(double staticRootX) Current X position of the static root, updated when mounted (metres).voidsetStaticRootY(double staticRootY) Current Y position of the static root, updated when mounted (metres).
-
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 drumdrumRadius- radius of the elevator drum in metres
-
-
Method Details
-
setNumMotors
Sets the number of motors driving this linear stage.- Parameters:
numMotors- number of Kraken X60 motors- Returns:
- this config for chaining
-
setCarriageMass
Sets the carriage mass used by the physics simulation.- Parameters:
carriageMassKg- mass of the moving carriage in kilograms- Returns:
- this config for chaining
-
setAngle
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
Sets the color of the moving stage ligament in the Mechanism2d canvas.- Parameters:
color- the display color- Returns:
- this config for chaining
-
setLineWidth
Sets the stroke width of the stage ligaments in the Mechanism2d canvas.- Parameters:
lineWidth- stroke width in pixels- Returns:
- this config for chaining
-
setStaticLength
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
Sets the visual length of the moving stage ligament.- Parameters:
lengthInches- length in inches; stored internally as metres- Returns:
- this config for chaining
-
setMaxHeight
Sets the maximum travel height of the mechanism.- Parameters:
lengthInches- maximum height in inches; stored internally as metres- Returns:
- this config for chaining
-
setMount
Attaches this linear stage to a parentLinearSimmount so its root tracks the parent stage's position.- Parameters:
sim- the parent linear stage to mount onto, ornullto leave unmounted- Returns:
- this config for chaining
-
setMount
Attaches this linear stage to a parentArmSimmount so its root tracks the arm tip's position.- Parameters:
sim- the parent arm to mount onto, ornullto 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
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 parentMount. -
getMount
The parent mount this linear stage 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).
-