Class TankTrajectory


  • public class TankTrajectory
    extends Trajectory
    Represents the trajectory of a tank-style robot as it moves through a Path. This class provides programmers with the target velocities of the left and right motors. This class can be created using the TankTrajectory(Trajectory, double) constructor, and can also be created by the Trajectory class using #getTankTrajectory().
    • Constructor Detail

      • TankTrajectory

        public TankTrajectory​(Trajectory trajectory,
                              double wheelBaseWidth)
        Creates a new TankTrajectory using the data found in the given Trajectory.
        Parameters:
        trajectory - The Trajectory to use to calculate the wheel velocities.
        wheelBaseWidth - The distance between the left and right wheels, measured parallel to the width of the robot.
    • Method Detail

      • convertTime

        public TankTrajectory convertTime​(Units.TIME desired)
        Converts the velocities to a specified unit of time. The velocities are originally in units per SECOND.
        Parameters:
        desired - The time unit to convert to.
        Returns:
        This Trajectory, after the convert is complete.
      • invertTurn

        public TankTrajectory invertTurn()
        Inverts the turn that the robot takes during the Path. Call this method if the robot turns the wrong directions while driving.
        Returns:
        This Trajectory, after the invert is complete.
      • invertDirection

        public TankTrajectory invertDirection()
        Inverts the direction of the robot as it drives through a path. Call this method if the robot is driving backwards when it should be driving forwards, or vice versa.
        Returns:
        This Trajectory, after the invert is complete.
      • getRawLeftVelocity

        public double getRawLeftVelocity()
        Returns the value of the left velocity in its original distance units per second.
        Returns:
        Target left velocity in distance units per second.
      • getRawRightVelocity

        public double getRawRightVelocity()
        Returns the value of the right velocity in its original distance units per second.
        Returns:
        Target right velocity in distance units per second.
      • getLeftVelocity

        public double getLeftVelocity()
        Returns the target velocity of the left drive wheels needed to stay on course with the path currently being driven. This value is returned in the raw motor controller units (assuming that a call to convertTime(frc.robot.util.hyperdrive.util.Units.TIME) was made with the right time unit), so the target velocity of the motors can be directly set to this value.
        Returns:
        The target velocity of the left wheels.
      • getRightVelocity

        public double getRightVelocity()
        Returns the target velocity of the right drive wheels in order to stay on course with the path currently being driven.This value is returned in the raw motor controller units (assuming that a call to convertTime(frc.robot.util.hyperdrive.util.Units.TIME) was made with the right time unit), so the target velocity of the motors can be directly set to this value.
        Returns:
        The target velocity of the right wheels.
      • getLeftPercentOutput

        public double getLeftPercentOutput​(double currentLeftVelocity)
        Calculates percent output of the left wheels needed to continue driving the path at this point.
        Parameters:
        currentLeftVelocity - The velocity of the right motors at this moment, in motor units.
        Returns:
        Target left percent output of the left motors.
      • getRightPercentOutput

        public double getRightPercentOutput​(double currentRightVelocity)
        Calculates the percent output of the right wheels needed to continue driving the path at this point.
        Parameters:
        currentRightVelocity - The velocity of the right motors at this moment, in motor units.
        Returns:
        Target right percent output of the right motors.