File-By-File
LinearTrajectory

LinearTrajectory

The most simple type of trajectory. A linear trajectory does nothing other than go to a point at a linear speed. Such, there's not much you can customize here. But it's simple, and it works. Hopefully, that is.

A linear trajectory will move to a target point at a predetermined speed. If the robot's position is unintentionally altered - say, for example, another robot collides with your robot - a LinearTrajectory should compensate automatically.

Linear trajectories are the easiest trajectories to work with, but don't maximize movement efficiency. There are several issues (not specific to linear trajectories) that make them, at times, slow: overcorrection, for example, can cause your robot to circle around the point. This can be fixed by increasing the tolerance value, but doing so will decrease the accuracy of the trajectory.

Fields

SHOULD_SHUFFLE

A boolean indicating whether Pathfinder should "dance." This should always be false in any project used in competition; it's purely for fun.

Methods

LinearTrajectory(PointXYZ target, double speed, double tolerance, Angle angleTolerance)

Constructs a new LinearTrajectory.

  • target: The trajectory's target point. The trajectory will execute until it is interrupted, or it reaches the target point.
  • speed: The speed at which the robot should move to the target point. This value should be between 0 and 1.
  • tolerance: The tolerance used in determining whether the robot's X and Y coordinates match up with those of the target point. A higher tolerance means your robot can more quickly complete paths while sacrificing accuracy, while a lower tolerance does exactly the opposite: it makes your robot more accurate, at the price of speed.
  • angleTolerance: The tolerance used in determining whether the robot's heading matches up with whatever heading the robot is supposed to be facing. A higher angle tolerance means the robot will complete the trajectory more quickly, as it won't have to compensate for any over or under adjustments. A lower angle tolerance makes your robot more precise.

LinearTrajectory(LinearTrajectory trajectory)

Constructs a new LinearTrajectory by copying an existing trajectory.

getTarget()

Returns the trajectory's target point.

nextMarker(PointXYZ current)

Determines the next marker point for the robot. If SHOULD_SHUFFLE is false and the robot has reached the target X and Y coordinates, it returns the current position with the target heading to prevent overcorrection. Otherwise, it returns the actual target point.

isDoneXY(PointXYZ current)

Private helper method. Checks if the robot's X and Y coordinates are within the specified tolerance of the target point's X and Y coordinates.

isDoneHeading(PointXYZ current)

Private helper method. Checks if the robot's current heading is within the specified angleTolerance of the target point's heading.

isDone(PointXYZ current)

Determines if the trajectory is complete. This is true if both isDoneXY(current) and isDoneHeading(current) return true.

speed(PointXYZ current)

Returns the speed at which the robot should move. If isDoneXY(current) is true, it returns Core.linearTrajectoryIsDoneSpeedMultiplier * speed (which is typically 0), otherwise it returns the constant speed.

toMutableLinearTrajectory()

Converts this LinearTrajectory into a MutableLinearTrajectory.

hashCode()

Returns a hash code for the LinearTrajectory.

equals(Object obj)

Compares this LinearTrajectory to another object for equality. Two LinearTrajectory objects are considered equal if their target points, speeds, tolerances, and angle tolerances are all equal (within a small margin for doubles).

clone()

Creates and returns a copy of this LinearTrajectory.

toString()

Returns a string representation of the LinearTrajectory, including its target, speed, tolerance, and angle tolerance.