Package frc.spectrumLib.sim
Class ArmConfig
java.lang.Object
frc.spectrumLib.sim.ArmConfig
Configuration data for an arm simulation. Stores physical properties, display settings, and
optional mount attachment used by
ArmSim.-
Constructor Summary
ConstructorsConstructorDescriptionArmConfig(double initialX, double initialY, double ratio, double length, double minAngleDegrees, double maxAngleDegrees, double startingAngleDegrees) Creates an ArmConfig with the required physical and display parameters. -
Method Summary
Modifier and TypeMethodDescriptiongetColor()Color used to draw the arm ligament in the Mechanism2d canvas.doubleInitial X position of the arm pivot in the Mechanism2d canvas (metres).doubleInitial Y position of the arm pivot 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).doubleVisual length of the arm ligament in the Mechanism2d canvas (metres).doubleMaximum allowable arm angle (radians).doubleMinimum allowable arm angle (radians).getMount()The parent mount this arm is attached to, ornullif not mounted.intNumber of Kraken X60 motors driving the arm.doubleCurrent X position of the arm pivot used during simulation updates (metres).doubleCurrent Y position of the arm pivot used during simulation updates (metres).doublegetRatio()Motor rotations required for one full revolution of the arm mechanism.doubleDistance from the pivot to the arm's centre of gravity used by the physics simulation (metres).doubleMoment of inertia used by the physics simulation (kg·m²).doubleArm angle at the start of the simulation (radians).booleanWhentruethe arm's visual angle is expressed in absolute robot-frame degrees; whenfalseit is relative to the parent mount's current angle.booleanWhether this arm is attached to a parentMount.booleanWhether the physics simulation should apply gravitational force to the arm.Sets the arm's display color in the Mechanism2d canvas.voidsetInitialX(double initialX) Initial X position of the arm pivot in the Mechanism2d canvas (metres).voidsetInitialY(double initialY) Initial Y position of the arm pivot in the Mechanism2d canvas (metres).voidsetLength(double length) Visual length of the arm ligament in the Mechanism2d canvas (metres).voidsetMaxAngle(double maxAngle) Maximum allowable arm angle (radians).voidsetMinAngle(double minAngle) Minimum allowable arm angle (radians).Attaches this arm to a parentArmSimmount so its pivot tracks the parent arm's tip position.Attaches this arm to aLinearSimmount so its pivot tracks the linear stage's position.voidsetNumMotors(int numMotors) Number of Kraken X60 motors driving the arm.voidsetPivotX(double pivotX) Current X position of the arm pivot used during simulation updates (metres).voidsetPivotY(double pivotY) Current Y position of the arm pivot used during simulation updates (metres).voidsetRatio(double ratio) Motor rotations required for one full revolution of the arm mechanism.voidsetSimCGLength(double simCGLength) Distance from the pivot to the arm's centre of gravity used by the physics simulation (metres).voidsetSimMOI(double simMOI) Moment of inertia used by the physics simulation (kg·m²).setSimulatedGravity(boolean simulateGravity) voidsetSimulateGravity(boolean simulateGravity) Whether the physics simulation should apply gravitational force to the arm.voidsetStartingAngle(double startingAngle) Arm angle at the start of the simulation (radians).
-
Constructor Details
-
ArmConfig
public ArmConfig(double initialX, double initialY, double ratio, double length, double minAngleDegrees, double maxAngleDegrees, double startingAngleDegrees) Creates an ArmConfig with the required physical and display parameters. Angle arguments are specified in degrees and stored internally as radians.- Parameters:
initialX- initial X position of the pivot in the Mechanism2d canvas (metres)initialY- initial Y position of the pivot in the Mechanism2d canvas (metres)ratio- motor rotations per one full arm revolutionlength- visual arm length in the Mechanism2d canvas (metres)minAngleDegrees- minimum allowable arm angle in degreesmaxAngleDegrees- maximum allowable arm angle in degreesstartingAngleDegrees- initial arm angle in degrees
-
-
Method Details
-
setColor
Sets the arm's display color in the Mechanism2d canvas.- Parameters:
color- the color to use- Returns:
- this config for chaining
-
setSimulatedGravity
-
setMount
Attaches this arm to aLinearSimmount so its pivot tracks the linear stage's position.- Parameters:
sim- the linear stage to mount onto, ornullto leave unmountedfixedAngle- whentruethe arm angle is treated as absolute; whenfalseit is relative to the mount's current angle- Returns:
- this config for chaining
-
setMount
Attaches this arm to a parentArmSimmount so its pivot tracks the parent arm's tip position.- Parameters:
sim- the parent arm to mount onto, ornullto leave unmountedabsAngle- whentruethe arm angle is expressed in the absolute robot frame; whenfalseit is relative to the parent arm's current angle- Returns:
- this config for chaining
-
getNumMotors
public int getNumMotors()Number of Kraken X60 motors driving the arm. -
setNumMotors
public void setNumMotors(int numMotors) Number of Kraken X60 motors driving the arm. -
getInitialX
public double getInitialX()Initial X position of the arm pivot in the Mechanism2d canvas (metres). -
setInitialX
public void setInitialX(double initialX) Initial X position of the arm pivot in the Mechanism2d canvas (metres). -
getInitialY
public double getInitialY()Initial Y position of the arm pivot in the Mechanism2d canvas (metres). -
setInitialY
public void setInitialY(double initialY) Initial Y position of the arm pivot in the Mechanism2d canvas (metres). -
getPivotX
public double getPivotX()Current X position of the arm pivot used during simulation updates (metres). -
setPivotX
public void setPivotX(double pivotX) Current X position of the arm pivot used during simulation updates (metres). -
getPivotY
public double getPivotY()Current Y position of the arm pivot used during simulation updates (metres). -
setPivotY
public void setPivotY(double pivotY) Current Y position of the arm pivot used during simulation updates (metres). -
getRatio
public double getRatio()Motor rotations required for one full revolution of the arm mechanism. -
setRatio
public void setRatio(double ratio) Motor rotations required for one full revolution of the arm mechanism. -
getLength
public double getLength()Visual length of the arm ligament in the Mechanism2d canvas (metres). -
setLength
public void setLength(double length) Visual length of the arm ligament in the Mechanism2d canvas (metres). -
getSimMOI
public double getSimMOI()Moment of inertia used by the physics simulation (kg·m²). -
setSimMOI
public void setSimMOI(double simMOI) Moment of inertia used by the physics simulation (kg·m²). -
getSimCGLength
public double getSimCGLength()Distance from the pivot to the arm's centre of gravity used by the physics simulation (metres). -
setSimCGLength
public void setSimCGLength(double simCGLength) Distance from the pivot to the arm's centre of gravity used by the physics simulation (metres). -
getMinAngle
public double getMinAngle()Minimum allowable arm angle (radians). -
setMinAngle
public void setMinAngle(double minAngle) Minimum allowable arm angle (radians). -
getMaxAngle
public double getMaxAngle()Maximum allowable arm angle (radians). -
setMaxAngle
public void setMaxAngle(double maxAngle) Maximum allowable arm angle (radians). -
getStartingAngle
public double getStartingAngle()Arm angle at the start of the simulation (radians). -
setStartingAngle
public void setStartingAngle(double startingAngle) Arm angle at the start of the simulation (radians). -
isSimulateGravity
public boolean isSimulateGravity()Whether the physics simulation should apply gravitational force to the arm. -
setSimulateGravity
public void setSimulateGravity(boolean simulateGravity) Whether the physics simulation should apply gravitational force to the arm. -
isMounted
public boolean isMounted()Whether this arm is attached to a parentMount. -
getMount
The parent mount this arm 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). -
isAbsAngle
public boolean isAbsAngle()Whentruethe arm's visual angle is expressed in absolute robot-frame degrees; whenfalseit is relative to the parent mount's current angle. -
getColor
Color used to draw the arm ligament in the Mechanism2d canvas.
-