-
Notifications
You must be signed in to change notification settings - Fork 0
Robot Scheduling System
The Robot Scheduling System acts like a small operating system and allows easy control of multiple systems at the same time. It provides the comfort and organization of not having to worry about execution of tasks for the robot and the easy ability to execute and monitor several activities on the robot at the same time.
The scheduling system bases its operation on dividing the robot into different systems, each represented in a different class and provides logic for actuator control and sensor input:
Each system can have one action running on it at any given time. That action is responsible for executing programmed control algorithms for that system. The actions are executed by the scheduler:
A system on a robot can be the drive system which controls the drive motors, or a simple arm controlled by a single motor. In either case, each system is represented by the Subsystem
class. To create a system, your class must extend Subsystem
but there is no need to implement any method, the base is simply logic for control.
A Subsystem
can have only one action running on it at any given time. This allows us to avoid control complications with that systems.
In addition, each system can have a default action: an action which will start running on the system if no other action is running at the moment.
An action is represented by the class Action
. To create an Action
, simply extend the class and implement necessary methods. An action can be executed multiple times and can depend on multiple systems (the requirements). Once started, the execution process of an action is as following:
- A check is performed to insure no other action is running on any of the required systems. If there are actions, they are canceled and their execution is stopped.
- The action then starts and
initialize
is called. - While still executing:
-
execute
is called -
isFinished
is called. If it returnstrue
the action stops execution, otherwise execution continues.
-
- When execution is done, if
isFinished
returnedtrue
thenend
is called, otherwiseinterrupted
is called.
There are 2 instances where interrupted
can be called:
- Someone called the
cancel
method to manually stop the action. - The scheduler canceled the action because another started running with an overlapping system requirement.
The scheduler is responsible for execution of Action
s and is represented by the class Scheduler
. The scheduler can execute both Runnable
objects and Action
objects. It is a singleton class (Has only one instance). The scheduler is also responsible for start default actions for systems and for avoiding execution of several actions on one system.
To run the scheduler cycle, which is responsible for execution and monitoring, call the run
method. It should be called periodically to allow for continuous execution.
To add a Runnable
object for execution, call addTask
, and to remove it, call remove
. But when working with Action
objects, use the start
and cancel
methods in Action
instead.
When creating a Subsystem
it will be automatically registered into the scheduler so that it could be monitored for default action execution.