Interface TrcTaskMgr.Task

Enclosing class:
TrcTaskMgr

public static interface TrcTaskMgr.Task
Any class that is registering a task must implement this interface.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    runTask(TrcTaskMgr.TaskType taskType, TrcRobot.RunMode runMode, boolean slowPeriodicLoop)
    This method is called at the appropriate time this task is registered for.
  • Method Details

    • runTask

      void runTask(TrcTaskMgr.TaskType taskType, TrcRobot.RunMode runMode, boolean slowPeriodicLoop)
      This method is called at the appropriate time this task is registered for.

      StartTask: This contains code that initializes the task before a competition mode is about to start and is run on the main robot thread. Typically, if the task is a robot subsystem, you may put last minute mode specific initialization code here. Most of the time, you don't need to register StartTask because all initialization is done in robotInit(). But sometimes, you may want to delay a certain initialization until right before competition starts. For example, you may want to reset the gyro heading right before competition starts to prevent drifting.

      StopTask: This contains code that cleans up the task before a competition mode is about to end and is run on the main robot thread. Typically, if the task is a robot subsystem, you may put code to stop the robot here. Most of the time, you don't need to register StopTask because the system will cut power to all the motors after a competition mode has ended.

      PrePeriodicTask: This contains code that runs periodically on the main robot thread at PERIODIC_INTERVAL before periodic(). Typically, you will put code that deals with any input sensor readings here that Periodic() may depend on.

      PostPeriodicTask: This contains code that runs periodically on the main robot thread at PERIODIC_INTERVAL after periodic(). Typically, you will put code that deals with actions that requires high frequency processing.

      InputTask: This contains code that runs periodically on the input thread. Typically, you will put code that deals with any input or sensor readings that may otherwise degrade the performance of the main robot thread.

      OutputTask: This contains code that runs periodically on the output thread. Typically, you will put code that deals with actions that may otherwise degrade the performance of the main robot thread.

      StandaloneTask: This contains code that will run on its own thread at the specified task interval. Typically, you will put code that may take a long time to execute and could affect the performance of shared threads such as the main robot thread, input or output threads.

      Parameters:
      taskType - specifies the type of task being run. This may be useful for handling multiple task types.
      runMode - specifies the competition mode (e.g. Autonomous, TeleOp, Test).
      slowPeriodicLoop - specifies true if it is running the slow periodic loop on the main robot thread, false otherwise.