FastTrajectory
Another rather simple type of trajectory. Like the LinearTrajectory, the FastTrajectory operates in a linear manner - it'll continue driving towards the target point in a straight line until it reaches the point.
Unlike the LinearTrajectory, however, the FastTrajectory does two things differently:
- It doesn't require the headings to match for the trajectory to count as being completed.
- The only condition that determines whether a
FastTrajectoryhas finished is whether or not the elapsed X and Y distances of the robot are greater than the difference between the X and Y values of the start and end points, respectively.
In other words, whenever you create a new FastTrajectory, two values will be generated - minDistanceX and minDistanceY. Whenever the isDone(PointXYZ) method is called, two more values will be generated - we'll call them elapsedX and elapsedY. If both the elapsed X and elapsed Y values are greater than the minimum X and minimum Y values, the trajectory has been completed.
This significantly decreases accuracy, as the robot will not automatically correct its position if it overshoots the target. However, this makes the trajectory require significantly less time in situations where high degrees of accuracy aren't really needed.
Methods
FastTrajectory(PointXYZ start, PointXYZ end, double speed)
Constructs a new FastTrajectory.
start: The trajectory's starting point. This should usually be the robot's current position when the trajectory is created.end: The trajectory's ending point.speed: The speed at which the trajectory should operate.
nextMarker(PointXYZ current)
Returns the end point as the next marker, indicating that the robot should always aim directly for the target.
isDone(PointXYZ current)
Determines if the trajectory is considered complete. This is true if the absolute elapsed X and Y distances from the start point to the current point are greater than or equal to the minDistanceX and minDistanceY respectively.
speed(PointXYZ current)
Returns the constant speed defined for this trajectory.
toString()
Returns a string representation of the FastTrajectory, including its start point, end point, and speed.