ExecutorManager
A manager responsible for orchestrating the execution of FollowerExecutor instances. This manager operates on a first-in, first-out (FIFO) basis, processing one executor at a time until it's complete before moving to the next in the queue.
Key Concepts
- FIFO Execution: Executors are processed in the order they are added to the queue.
- Limited Interaction: The primary ways to interact with the manager are adding new executors or clearing the entire queue.
- Autonomous Movement: Designed to simplify the management of autonomous robot movements by abstracting the underlying execution logic.
Methods
ExecutorManager(Robot robot)
Constructs a new ExecutorManager instance. It requires a Robot object to access its Odometry and Drive components.
addExecutor(List<Follower> followers)
Adds a new FollowerExecutor to the queue. This executor is created from the provided list of Follower objects and will be executed after any currently active or queued executors are finished.
addExecutor(Follower follower)
Adds a single Follower to the manager's queue by wrapping it in a new FollowerExecutor.
clearExecutors()
Clears all FollowerExecutor instances from the queue. This effectively stops any ongoing autonomous movement. It's important to tick() Pathfinder after calling this to ensure the robot stops moving.
isActive()
Returns true if there is at least one executor in the queue, indicating that the manager is actively processing or has executors waiting. Returns false otherwise.
isInactive()
Returns true if there are no executors in the queue, indicating that the manager is inactive. This is the opposite of isActive().
tick()
Processes the next step of the current FollowerExecutor in the queue. If the current executor finishes, it is removed, and the manager moves to the next one. Returns true if all executors have finished (the queue is empty), and false otherwise.
howManyExecutors()
Returns the number of FollowerExecutor instances currently in the queue.
howManyFollowers()
Returns the total number of individual Follower objects across all FollowerExecutor instances in the queue.
getExecutionTime()
Returns the elapsed time (in milliseconds) for the currently executing follower. If no followers have executed, it returns 0. If no followers are currently active but some have executed in the past, it returns the execution time of the last follower.
getCurrentExecutor()
Returns the FollowerExecutor that is currently being processed (the first one in the queue). Throws an exception if the queue is empty.