Class Trajectory

  • Direct Known Subclasses:
    TankTrajectory

    public class Trajectory
    extends java.lang.Object
    Represents the desired path of movement of the robot at any point while driving through a path. This class is the main class, which holds only the crude turn and speed values, and cannot be used to set the target velocity of any drivetrain motors without further calculations. Users should use this class to calculate target velocities or positions of their motors by using the getTankTrajectory(double wheelBaseWidth) method. More similar methods will be implemented in the future if support for different drivetrains such as swerve drive is added.
    • Constructor Summary

      Constructors 
      Constructor Description
      Trajectory​(double velocity, double distance, double turn, IEmulateParams parameters, IController controller, double motorUnitsPerUnit)
      Creates a new Trajectory, defining that the robot should drive at the given velocity for a certain distance ahead, while turning to the angular displacement given by turnAhead.
      Trajectory​(Trajectory trajectory)
      Creates a new Trajectory, copying the specified Trajectory
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      IController getController()
      Returns the controller that this Trajectory uses.
      double getDistance()
      Returns the distance that the robot will cover while moving through the trajectory.
      double getMotorUnitsPerUnit()
      Returns the units per unit value that was passed into the constructor.
      IEmulateParams getParameters()
      Returns the parameters that this Trajectory uses.
      TankTrajectory getTankTrajectory​(double wheelBaseWidth)
      Returns the trajectory information in a format that can drive tank-style robots.
      double getTurn()
      Returns the angular displacment, in radians, of the robot as it moves through the trajectory.
      double getVelocity()
      Returns the target velocity of the robot as it goes through this trajectory.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • velocity

        protected double velocity
      • distance

        protected double distance
      • turn

        protected double turn
      • motorUnitsPerUnit

        protected final double motorUnitsPerUnit
    • Constructor Detail

      • Trajectory

        public Trajectory​(double velocity,
                          double distance,
                          double turn,
                          IEmulateParams parameters,
                          IController controller,
                          double motorUnitsPerUnit)
        Creates a new Trajectory, defining that the robot should drive at the given velocity for a certain distance ahead, while turning to the angular displacement given by turnAhead.
        Parameters:
        velocity - The velocity of the robot.
        distance - The length of the path immediately ahead of the robot.
        turn - The magnitude of the turn immediately ahead of the robot, in radians.
        parameters - The parameters being used for driving.
        controller - The controller to use to calculate outputs
        motorUnitsPerUnit - A scalar to convert from motor units to actual units. See the Hyperdrive constructor for more.
      • Trajectory

        public Trajectory​(Trajectory trajectory)
        Creates a new Trajectory, copying the specified Trajectory
        Parameters:
        trajectory - The trajectory to copy.
    • Method Detail

      • getVelocity

        public double getVelocity()
        Returns the target velocity of the robot as it goes through this trajectory.
        Returns:
        Velocity of the robot.
      • getDistance

        public double getDistance()
        Returns the distance that the robot will cover while moving through the trajectory.
        Returns:
        Distance of the trajectory.
      • getTurn

        public double getTurn()
        Returns the angular displacment, in radians, of the robot as it moves through the trajectory.
        Returns:
        The turn of the robot.
      • getParameters

        public IEmulateParams getParameters()
        Returns the parameters that this Trajectory uses.
        Returns:
        Parameters used to drive the robot.
      • getController

        public IController getController()
        Returns the controller that this Trajectory uses.
        Returns:
        Controller used to drive the robot.
      • getTankTrajectory

        public TankTrajectory getTankTrajectory​(double wheelBaseWidth)
        Returns the trajectory information in a format that can drive tank-style robots.
        Parameters:
        wheelBaseWidth - The distance between the left and right wheels, measured parallel to the width of the robot.
        Returns:
        A TankTrajectory, which contains the left and right wheel velocities required to keep the robot on course.
      • getMotorUnitsPerUnit

        public final double getMotorUnitsPerUnit()
        Returns the units per unit value that was passed into the constructor.
        Returns:
        Motor units per unit scalar.