Package frc.spectrumLib.sim
Interface Mountable
public interface Mountable
Mixin interface for simulation components that can be attached to a
Mount. Provides
default geometry helpers that compute the component's updated canvas position each simulation
period, taking the parent mount's type, current position, and current angle into account.-
Method Summary
Modifier and TypeMethodDescriptionstatic doublegetAngleOffset(double initialX, double initialY, double mountX, double mountY, double startingAngle) Returns the radians a mounted object should be away from a mount based on their initial positionsstatic doublegetDistance(double x1, double y1, double x2, double y2) Computes the straight-line distance between two points on the canvas.default doublegetUpdatedX(ArmConfig config) Convenience overload that derives all geometry parameters from anArmConfig.default doublegetUpdatedX(LinearConfig config) Convenience overload that derives all geometry parameters from aLinearConfig.default doublegetUpdatedX(Mount.MountType mountType, double initialX, double initialY, double initMountX, double initMountY, double initMountAngle, double mountX, double mountY, double displacementX, double displacementY, double mountAngle) Computes the updated X position of a mounted component given full explicit geometry parameters.default doublegetUpdatedX(RollerConfig config) Convenience overload that derives all geometry parameters from aRollerConfig.default doublegetUpdatedY(ArmConfig config) Convenience overload that derives all geometry parameters from anArmConfig.default doublegetUpdatedY(LinearConfig config) Convenience overload that derives all geometry parameters from aLinearConfig.default doublegetUpdatedY(Mount.MountType mountType, double initialX, double initialY, double initMountX, double initMountY, double initMountAngle, double mountX, double mountY, double displacementX, double displacementY, double mountAngle) Computes the updated Y position of a mounted component given full explicit geometry parameters.default doublegetUpdatedY(RollerConfig config) Convenience overload that derives all geometry parameters from aRollerConfig.static doublegetXWithAngle(double radius, double angle, double displacementX) Computes the X coordinate of a point atradiusdistance fromdisplacementXin the direction ofangle.static doublegetYWithAngle(double radius, double angle, double displacementY) Computes the Y coordinate of a point atradiusdistance fromdisplacementYin the direction ofangle.
-
Method Details
-
getUpdatedX
default double getUpdatedX(Mount.MountType mountType, double initialX, double initialY, double initMountX, double initMountY, double initMountAngle, double mountX, double mountY, double displacementX, double displacementY, double mountAngle) Computes the updated X position of a mounted component given full explicit geometry parameters.- Parameters:
mountType- type of the parent mount (ARM or LINEAR)initialX- component's initial X position on the canvas (metres)initialY- component's initial Y position on the canvas (metres)initMountX- mount's X position at simulation start (metres)initMountY- mount's Y position at simulation start (metres)initMountAngle- mount's angle at simulation start (radians)mountX- mount's current X position (metres)mountY- mount's current Y position (metres)displacementX- mount's current horizontal displacement from its initial position (metres)displacementY- mount's current vertical displacement from its initial position (metres)mountAngle- mount's current angle (radians)- Returns:
- updated X position of the component on the canvas (metres)
-
getUpdatedY
default double getUpdatedY(Mount.MountType mountType, double initialX, double initialY, double initMountX, double initMountY, double initMountAngle, double mountX, double mountY, double displacementX, double displacementY, double mountAngle) Computes the updated Y position of a mounted component given full explicit geometry parameters.- Parameters:
mountType- type of the parent mount (ARM or LINEAR)initialX- component's initial X position on the canvas (metres)initialY- component's initial Y position on the canvas (metres)initMountX- mount's X position at simulation start (metres)initMountY- mount's Y position at simulation start (metres)initMountAngle- mount's angle at simulation start (radians)mountX- mount's current X position (metres)mountY- mount's current Y position (metres)displacementX- mount's current horizontal displacement from its initial position (metres)displacementY- mount's current vertical displacement from its initial position (metres)mountAngle- mount's current angle (radians)- Returns:
- updated Y position of the component on the canvas (metres)
-
getUpdatedX
Convenience overload that derives all geometry parameters from aRollerConfig.- Parameters:
config- the roller configuration carrying mount and initial-position data- Returns:
- updated X position on the canvas (metres)
-
getUpdatedX
Convenience overload that derives all geometry parameters from anArmConfig.- Parameters:
config- the arm configuration carrying mount and initial-position data- Returns:
- updated X position on the canvas (metres)
-
getUpdatedX
Convenience overload that derives all geometry parameters from aLinearConfig.- Parameters:
config- the linear stage configuration carrying mount and initial-position data- Returns:
- updated X position on the canvas (metres)
-
getUpdatedY
Convenience overload that derives all geometry parameters from aRollerConfig.- Parameters:
config- the roller configuration carrying mount and initial-position data- Returns:
- updated Y position on the canvas (metres)
-
getUpdatedY
Convenience overload that derives all geometry parameters from anArmConfig.- Parameters:
config- the arm configuration carrying mount and initial-position data- Returns:
- updated Y position on the canvas (metres)
-
getUpdatedY
Convenience overload that derives all geometry parameters from aLinearConfig.- Parameters:
config- the linear stage configuration carrying mount and initial-position data- Returns:
- updated Y position on the canvas (metres)
-
getAngleOffset
static double getAngleOffset(double initialX, double initialY, double mountX, double mountY, double startingAngle) Returns the radians a mounted object should be away from a mount based on their initial positions -
getDistance
static double getDistance(double x1, double y1, double x2, double y2) Computes the straight-line distance between two points on the canvas.- Parameters:
x1- X coordinate of the first point (metres)y1- Y coordinate of the first point (metres)x2- X coordinate of the second point (metres)y2- Y coordinate of the second point (metres)- Returns:
- Euclidean distance in metres
-
getXWithAngle
static double getXWithAngle(double radius, double angle, double displacementX) Computes the X coordinate of a point atradiusdistance fromdisplacementXin the direction ofangle.- Parameters:
radius- distance from the reference point (metres)angle- direction angle in radiansdisplacementX- reference X coordinate (metres)- Returns:
- resulting X coordinate (metres)
-
getYWithAngle
static double getYWithAngle(double radius, double angle, double displacementY) Computes the Y coordinate of a point atradiusdistance fromdisplacementYin the direction ofangle.- Parameters:
radius- distance from the reference point (metres)angle- direction angle in radiansdisplacementY- reference Y coordinate (metres)- Returns:
- resulting Y coordinate (metres)
-