Package com.marswars.geometry
Class LaunchTrajectory
java.lang.Object
com.marswars.geometry.LaunchTrajectory
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassClass representing a solution for the trajectory -
Constructor Summary
ConstructorsConstructorDescriptionLaunchTrajectory(String logging_prefix, Translation3d target, double launch_height, boolean high_arc) Constructor for LaunchTrajectory with variable angleLaunchTrajectory(String logging_prefix, Translation3d target, double launch_height, double fixedAngle) Constructor for LaunchTrajectory with fixed angle shooter -
Method Summary
Modifier and TypeMethodDescriptionvoidaddVelocityPoint(double range, double velocity) Adds points to the linear interpolation tabledoubleGets the fixed angle (only valid if isFixedAngle() returns true)getSolution(Pose2d position) Gives a valid shooter trajectory for a given robot positiongetTrajectoryVisualization(LaunchTrajectory.TrajectorySol solution, Pose2d position) Generates a trajectory visualization with default parametersgetTrajectoryVisualization(LaunchTrajectory.TrajectorySol solution, Pose2d position, int maxPoints) Generates a trajectory visualization as an array of Translation3d pointsbooleanChecks if this trajectory uses a fixed angle shootervoidsetHighArc(boolean high_arc) Setter for high_arc; change the arc type live (only valid for variable angle shooters)voidsetTarget(Translation3d target) Setter for target; change the target live
-
Constructor Details
-
LaunchTrajectory
public LaunchTrajectory(String logging_prefix, Translation3d target, double launch_height, boolean high_arc) Constructor for LaunchTrajectory with variable angle- Parameters:
logging_prefix- Prefix string for logging purposestarget- Where you want to shoot (X, Y and Z) in the form of a Translation3dlaunch_height- The height of the launcher in metershigh_arc- Whether you want the higher arc or the lower arc (true for higher)
-
LaunchTrajectory
public LaunchTrajectory(String logging_prefix, Translation3d target, double launch_height, double fixedAngle) Constructor for LaunchTrajectory with fixed angle shooter- Parameters:
logging_prefix- Prefix string for logging purposestarget- Where you want to shoot (X, Y and Z) in the form of a Translation3dlaunch_height- The height of the launcher in metersfixedAngle- The fixed exit angle of the shooter in radians
-
-
Method Details
-
addVelocityPoint
public void addVelocityPoint(double range, double velocity) Adds points to the linear interpolation table- Parameters:
range- distance from target in metersvelocity- exit velocity for given distance in meters / second
-
isFixedAngle
public boolean isFixedAngle()Checks if this trajectory uses a fixed angle shooter- Returns:
- true if using fixed angle, false if using variable angle
-
getFixedAngle
public double getFixedAngle()Gets the fixed angle (only valid if isFixedAngle() returns true)- Returns:
- the fixed angle in radians
-
setTarget
Setter for target; change the target live- Parameters:
target- Z, Y, and Z of target for shot in the form of a Translation3d
-
setHighArc
public void setHighArc(boolean high_arc) Setter for high_arc; change the arc type live (only valid for variable angle shooters)- Parameters:
high_arc- true for higher arc, false for lower arc
-
getSolution
Gives a valid shooter trajectory for a given robot position- Parameters:
position- robot position (X and Y) in the form of a Pose2d- Returns:
- returns a TrajectorySol that contains velocity, exit angle, and heading angle
-
getTrajectoryVisualization
public Translation3d[] getTrajectoryVisualization(LaunchTrajectory.TrajectorySol solution, Pose2d position, int maxPoints) Generates a trajectory visualization as an array of Translation3d points- Parameters:
solution- TrajectorySol obtained from getSolution()position- robot position (X and Y) in the form of a Pose2dmaxPoints- maximum number of points to calculate (recommended: 20-50 for good resolution)- Returns:
- array of Translation3d points representing the trajectory, empty array if invalid
-
getTrajectoryVisualization
public Translation3d[] getTrajectoryVisualization(LaunchTrajectory.TrajectorySol solution, Pose2d position) Generates a trajectory visualization with default parameters- Parameters:
solution- TrajectorySol obtained from getSolution()position- robot position (X and Y) in the form of a Pose2d- Returns:
- array of Translation3d points representing the trajectory (30 points default)
-