Logic Flow - shanaam/VisuomotorExperimentFramework GitHub Wiki
Once the input parameters are read from the JSON. ExperimentController.cs acts as a singleton and handles the construction and destruction of Tasks.
What is a Task: A type of experiment consisting of a series of steps the user is required to complete. Currently, only one task is done for an entire experiment. This task consists of multiple Blocks which each Block containing a certain number of Trials. For context, an example of a task would be reaching to a target object, or placing an object into a receptacle.
How does the controller execute tasks: The logic of a task is housed in a class. This class is a child of the BaseTask class. For all tasks, we must implement the following variables:
Home -> a GameObject that acts as our starting point for the trial
Target -> a GameObject that acts as the destination for the user
Since they are GameObjects, they can arbitrarily be anything.
Each task has a number of steps, as defined by maxSteps.
- Logic to set up the next step of the trial should be done in the task class (By overriding IncrementStep).
- Logic that changes the current step should be done outside of the task class (By calling IncrementStep).
The current task can be referenced by accessing the singleton ExperimentController.Instance()
Execution Order:
- UXF triggers OnTrialBegin which runs BeginTrialSteps in ExperimentController.
- ExperimentController instantiates a component of class BaseTask. The class is dependent on the JSON file.
- ExperimentController runs the setup logic that is implemented by that task
- Once the trial reaches the maximum number of steps, EndAndPrepare is called.
- EndAndPrepare destroys the task component, logs any parameters, then ends the trial.
- UXF triggers OnTrialEnd whichs runs PrepareNextTrial in ExperimentController.
- PrepareNextTrial waits one frame before telling UXF to begin the next trial.
- The process repeats until there is no more trials. The program exits.