Class TankTrajectory
- java.lang.Object
-
- frc.robot.util.hyperdrive.emulation.Trajectory
-
- frc.robot.util.hyperdrive.emulation.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 theTankTrajectory(Trajectory, double)
constructor, and can also be created by theTrajectory
class using#getTankTrajectory()
.
-
-
Field Summary
-
Fields inherited from class frc.robot.util.hyperdrive.emulation.Trajectory
controller, distance, motorUnitsPerUnit, parameters, turn, velocity
-
-
Constructor Summary
Constructors Constructor Description TankTrajectory(Trajectory trajectory, double wheelBaseWidth)
Creates a newTankTrajectory
using the data found in the given Trajectory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TankTrajectory
convertTime(Units.TIME desired)
Converts the velocities to a specified unit of time.double
getLeftPercentOutput(double currentLeftVelocity)
Calculates percent output of the left wheels needed to continue driving the path at this point.double
getLeftVelocity()
Returns the target velocity of the left drive wheels needed to stay on course with the path currently being driven.double
getRawLeftVelocity()
Returns the value of the left velocity in its original distance units per second.double
getRawRightVelocity()
Returns the value of the right velocity in its original distance units per second.double
getRightPercentOutput(double currentRightVelocity)
Calculates the percent output of the right wheels needed to continue driving the path at this point.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 toconvertTime(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.TankTrajectory
invertDirection()
Inverts the direction of the robot as it drives through a path.TankTrajectory
invertTurn()
Inverts the turn that the robot takes during the Path.-
Methods inherited from class frc.robot.util.hyperdrive.emulation.Trajectory
getController, getDistance, getMotorUnitsPerUnit, getParameters, getTankTrajectory, getTurn, getVelocity
-
-
-
-
Constructor Detail
-
TankTrajectory
public TankTrajectory(Trajectory trajectory, double wheelBaseWidth)
Creates a newTankTrajectory
using the data found in the given Trajectory.- Parameters:
trajectory
- TheTrajectory
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 toconvertTime(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 toconvertTime(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.
-
-