Class LaunchTrajectory

java.lang.Object
com.marswars.geometry.LaunchTrajectory

public class LaunchTrajectory extends Object
  • 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 purposes
      target - Where you want to shoot (X, Y and Z) in the form of a Translation3d
      launch_height - The height of the launcher in meters
      high_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 purposes
      target - Where you want to shoot (X, Y and Z) in the form of a Translation3d
      launch_height - The height of the launcher in meters
      fixedAngle - 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 meters
      velocity - 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

      public void setTarget(Translation3d target)
      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

      public LaunchTrajectory.TrajectorySol getSolution(Pose2d position)
      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 Pose2d
      maxPoints - 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)