Follower
Every rose has its thorns. And every trajectory has its follower. That doesn't sound as catchy, but I'm sure you get the idea.
Each trajectory that you'd like the robot to follow needs to have a follower responsible for... well, actually following the trajectory.
A follower is responsible for manipulating the robot's motors in a manner that allows the robot to follow some sort of predetermined path. Each Follower should be responsible for a single action.
For almost all use cases, the GenericFollower is the best implementation of the Follower interface.
Methods
getAbsoluteTranslation(PointXYZ current, PointXYZ target, double speed, double turn)
Static method. Calculates an absolute Translation based on the robot's current position, target point, speed, and turn value. The translation's X and Y components will be within (-1.0, 1.0).
getRelativeTranslation(PointXYZ current, PointXYZ target, double speed, double turn)
Static method. Calculates a relative Translation by first generating an absolute translation and then converting it to be relative to the robot's current heading.
getTrajectory()
Returns the Trajectory that this follower is responsible for following.
tick(PointXYZ current, Consumer<Translation> consumer)
"Ticks" the follower once. This method generates a new Translation based on the robot's current position and passes it to the provided consumer. The consumer is responsible for applying this translation to the robot's drive train. Returns true if the follower has completed its task, false otherwise.
tickFollower(Follower follower, Supplier<PointXYZ> getPosition, Consumer<Translation> setTranslation)
Static method. A convenience method to tick a follower by supplying functions to get the robot's position and set its translation.