File-By-File
MutableLinearTrajectory

MutableLinearTrajectory

A variation of LinearTrajectory that has mutable values. This allows you to dynamically adjust the values of a trajectory. Additionally, you can set on-finish callbacks, as well as manually setting the state of whether the trajectory is done or not.

Key Concepts

  • Target: The trajectory's target point: this is where the robot will continually try to move to. If this point is changed, Pathfinder's movement will change as well.
  • Speed: The speed at which the robot should move. This value should be between 0 and 1.
  • Tolerance: The tolerance used in deciding if the robot is at the target point, meaning the trajectory is finished.
  • Angle tolerance: The angle tolerance used in deciding if the robot is at the target point, meaning the trajectory is finished.
  • isFinished and canFinish: isFinished will automatically be set to true whenever the robot is at the correct location. In order for the isDone(PointXYZ) method to return true, the canFinish flag must be true, which can be changed via setCanFinish(boolean). By default, this value is true, but it can be set to false to manually override the trajectory's finish.

Methods

MutableLinearTrajectory()

Creates a new MutableLinearTrajectory with default values:

  • Target point: (0, 0, 0 deg)
  • Speed: 0
  • Tolerance: 0
  • Angle tolerance: 0 deg

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

Constructs a new MutableLinearTrajectory with specified target, speed, and tolerances.

setSpeed(double speed)

Sets the speed of the trajectory.

setTolerance(double tolerance)

Sets the distance tolerance for the trajectory.

setAngleTolerance(Angle angleTolerance)

Sets the angle tolerance for the trajectory.

setIsFinished(boolean isFinished)

Manually sets the isFinished state of the trajectory.

setCanFinish(boolean canFinish)

Sets whether the trajectory is allowed to finish automatically. If false, isDone() will always return false even if the robot is at the target.

getTarget()

Returns the trajectory's target point.

setTarget(PointXYZ target)

Sets the trajectory's target point.

nextMarker(PointXYZ current)

Determines the next marker point for the robot. If 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, and canFinish is true.

speed(PointXYZ current)

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

toLinearTrajectory()

Converts this MutableLinearTrajectory into an immutable LinearTrajectory.

hashCode()

Returns a hash code for the MutableLinearTrajectory.

equals(Object obj)

Compares this MutableLinearTrajectory to another object for equality. Note that this implementation always returns false.