Package frc.spectrumLib.sim
Class ArmConfig
java.lang.Object
frc.spectrumLib.sim.ArmConfig
- All Implemented Interfaces:
Mountable.MountedConfig
Physical properties, display settings, and the optional parent mount for an
ArmSim.-
Constructor Summary
ConstructorsConstructorDescriptionArmConfig(double initialX, double initialY, double ratio, double length, double minAngleDegrees, double maxAngleDegrees, double startingAngleDegrees) Angle arguments arrive in degrees and are stored in radians. -
Method Summary
Modifier and TypeMethodDescriptiongetColor()Color used to draw the arm ligament in the Mechanism2d canvas.doubleInitial pivot X on the Mechanism2d canvas, in metres.doubleInitial pivot Y on the Mechanism2d 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).doubleVisual length of the arm ligament, in 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 pivot X in metres, moved every tick while mounted.doubleCurrent pivot Y in metres, moved every tick while mounted.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).booleanTrue keeps the arm's own angle absolute in the robot frame.booleanbooleanTrue when the sim geometry travels opposite the motor's positive direction.booleanvoidsetInitialX(double initialX) Initial pivot X on the Mechanism2d canvas, in metres.voidsetInitialY(double initialY) Initial pivot Y on the Mechanism2d canvas, in metres.voidsetLength(double length) Visual length of the arm ligament, in metres.voidsetMaxAngle(double maxAngle) Maximum allowable arm angle (radians).voidsetMinAngle(double minAngle) Minimum allowable arm angle (radians).Attaches this arm to a parentArmSimso its pivot follows that arm's tip.Attaches this arm to aLinearSimso its pivot follows that stage.voidsetNumMotors(int numMotors) Number of Kraken X60 motors driving the arm.voidsetPivotX(double pivotX) Current pivot X in metres, moved every tick while mounted.voidsetPivotY(double pivotY) Current pivot Y in metres, moved every tick while mounted.voidsetRatio(double ratio) Motor rotations required for one full revolution of the arm mechanism.setReversedLinkage(boolean reversedLinkage) Mirrors the simulated motor so the sim's travel matches the motor's positive direction.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) 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) Angle arguments arrive in degrees and are stored in radians.- Parameters:
ratio- motor rotations per one full arm revolution
-
-
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). -
setColor
-
setSimulatedGravity
-
setMount
Attaches this arm to aLinearSimso its pivot follows that stage.- Parameters:
sim- the stage to follow, or null to leave this arm unmountedfixedAngle- true treats the arm angle as absolute, false adds the mount's current angle
-
setMount
Attaches this arm to a parentArmSimso its pivot follows that arm's tip.- Parameters:
sim- the arm to follow, or null to leave this arm unmountedabsAngle- true treats the arm angle as absolute, false adds the parent's current angle
-
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 pivot X on the Mechanism2d canvas, in metres.- Specified by:
getInitialXin interfaceMountable.MountedConfig
-
setInitialX
public void setInitialX(double initialX) Initial pivot X on the Mechanism2d canvas, in metres. -
getInitialY
public double getInitialY()Initial pivot Y on the Mechanism2d canvas, in metres.- Specified by:
getInitialYin interfaceMountable.MountedConfig
-
setInitialY
public void setInitialY(double initialY) Initial pivot Y on the Mechanism2d canvas, in metres. -
getPivotX
public double getPivotX()Current pivot X in metres, moved every tick while mounted. -
setPivotX
public void setPivotX(double pivotX) Current pivot X in metres, moved every tick while mounted. -
getPivotY
public double getPivotY()Current pivot Y in metres, moved every tick while mounted. -
setPivotY
public void setPivotY(double pivotY) Current pivot Y in metres, moved every tick while mounted. -
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 metres. -
setLength
public void setLength(double length) Visual length of the arm ligament, in 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() -
setSimulateGravity
public void setSimulateGravity(boolean simulateGravity) -
getMount
The parent mount this arm 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
-
isAbsAngle
public boolean isAbsAngle()True keeps the arm's own angle absolute in the robot frame. False adds the parent mount's angle to it, in radians. -
getColor
Color used to draw the arm ligament in the Mechanism2d canvas. -
isReversedLinkage
public boolean isReversedLinkage()True when the sim geometry travels opposite the motor's positive direction.
-