FollowerExecutor
An executor that executes followers. This class is responsible for taking a list of Follower objects and executing them in sequence, one after another, until all followers have completed their tasks.
Key Concepts
- Sequential Execution: Followers are executed in the order they are added to the executor's list.
- Integration with Robot: It uses the robot's
Odometryto get the current position and theDriveto set the robot's translation, effectively controlling the robot's movement based on the active follower.
Methods
FollowerExecutor(Odometry odometry, Drive drive, List<Follower> followers)
Constructs a new FollowerExecutor with a list of Follower objects to execute.
odometry: TheOdometrysystem the executor should use to get the robot's current position.drive: TheDrivesystem the executor should use to move the robot.followers: A list ofFollowerobjects that this executor will manage.
FollowerExecutor(Odometry odometry, Drive drive, Follower follower)
Constructs a new FollowerExecutor with a single Follower object. This is a convenience constructor that wraps the single follower in a list.
tick()
"Ticks" the follower executor once. This method checks the first Follower in the followers list and calls its tick() method. If the tick() method of the current follower returns true (indicating it's done), that follower is removed from the list, and the executor will move to the next follower on the subsequent tick. Returns true if all followers in the list have finished executing, and false otherwise.
getCurrentFollower()
Returns the Follower that is currently being executed (the first one in the list). Throws an exception if there are no followers.
howManyFollowers()
Returns the number of Follower objects currently remaining in the executor's list.