Package frc.spectrumLib.sim
Class LinearConfig
java.lang.Object
frc.spectrumLib.sim.LinearConfig
- All Implemented Interfaces:
Mountable.MountedConfig
Physical properties, Mechanism2d display settings, and the optional parent mount for a
LinearSim.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoublegetAngle()Angle of the linear stage on the Mechanism2d canvas, in degrees, where 0 is horizontal, 90 is vertical, and positive is counter-clockwise.doubleMass of the moving carriage in kilograms, fed to the physics sim.getColor()doubleDrum radius in metres, which converts motor rotations into carriage travel.doubleGear ratio between the motor and the elevator drum.doubleInitial X of the static root on the canvas, in metres.doubleInitial Y of the static root on the canvas, in 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 pixels.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 metres.intNumber of Kraken X60 motors driving the linear stage.doubleVisual length of the non-moving stage ligament, in metres.doubleCurrent X of the static root in metres, moved every tick while mounted.doubleCurrent Y of the static root in metres, moved every tick while mounted.booleanbooleanTrue when the sim geometry travels opposite the motor's positive direction.setAngle(double angle) setCarriageMass(double carriageMassKg) setLineWidth(double lineWidth) setMaxHeight(double lengthInches) Sets the top of the travel range.Attaches this stage to a parentArmSimso its root follows the arm tip.Attaches this stage to a parentLinearSimso its root follows that stage.setMovingLength(double lengthInches) Sets the moving ligament's visual length.setNumMotors(int numMotors) setReversedLinkage(boolean reversedLinkage) Mirrors the simulated motor so the sim's travel matches the motor's positive direction.setStaticLength(double lengthInches) Sets the static ligament's visual length.voidsetStaticRootX(double staticRootX) Current X of the static root in metres, moved every tick while mounted.voidsetStaticRootY(double staticRootY) Current Y of the static root in metres, moved every tick while mounted.
-
Constructor Details
-
LinearConfig
public LinearConfig(double x, double y, double gearing, double drumRadius)
-
-
Method Details
-
isMounted
public boolean isMounted() -
setReversedLinkage
Mirrors the simulated motor so the sim's travel matches the motor's positive direction. SeeSimMotor.simState(com.ctre.phoenix6.hardware.TalonFX, boolean). -
setNumMotors
-
setCarriageMass
-
setAngle
-
setColor
-
setLineWidth
-
setStaticLength
Sets the static ligament's visual length. Takes inches and stores metres. -
setMovingLength
Sets the moving ligament's visual length. Takes inches and stores metres. -
setMaxHeight
Sets the top of the travel range. Takes inches and stores metres. -
setMount
Attaches this stage to a parentLinearSimso its root follows that stage.- Parameters:
sim- the stage to follow, or null to leave this one unmounted
-
setMount
Attaches this stage to a parentArmSimso its root follows the arm tip.- Parameters:
sim- the arm to follow, or null to leave this stage unmounted
-
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, fed to the physics sim. -
getDrumRadius
public double getDrumRadius()Drum radius in metres, which converts motor rotations into carriage travel. -
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 on the Mechanism2d canvas, in degrees, where 0 is horizontal, 90 is vertical, and positive is counter-clockwise. -
getColor
-
getLineWidth
public double getLineWidth()Stroke width of the stage ligaments, in pixels. -
getInitialX
public double getInitialX()Initial X of the static root on the canvas, in metres.- Specified by:
getInitialXin interfaceMountable.MountedConfig
-
getInitialY
public double getInitialY()Initial Y of the static root on the canvas, in metres.- Specified by:
getInitialYin interfaceMountable.MountedConfig
-
getStaticRootX
public double getStaticRootX()Current X of the static root in metres, moved every tick while mounted. -
setStaticRootX
public void setStaticRootX(double staticRootX) Current X of the static root in metres, moved every tick while mounted. -
getStaticRootY
public double getStaticRootY()Current Y of the static root in metres, moved every tick while mounted. -
setStaticRootY
public void setStaticRootY(double staticRootY) Current Y of the static root in metres, moved every tick while mounted. -
getStaticLength
public double getStaticLength()Visual length of the non-moving stage ligament, in metres. -
getMovingLength
public double getMovingLength()Visual length of the moving stage ligament, in metres. -
getMount
The parent mount this linear stage is attached to, ornullif not mounted.- Specified by:
getMountin interfaceMountable.MountedConfig
-
getInitMountX
public double getInitMountX()X position of the mount at simulation start (metres).- Specified by:
getInitMountXin interfaceMountable.MountedConfig
-
getInitMountY
public double getInitMountY()Y position of the mount at simulation start (metres).- Specified by:
getInitMountYin interfaceMountable.MountedConfig
-
getInitMountAngle
public double getInitMountAngle()Angle of the mount at simulation start (radians).- Specified by:
getInitMountAnglein interfaceMountable.MountedConfig
-
isReversedLinkage
public boolean isReversedLinkage()True when the sim geometry travels opposite the motor's positive direction.
-