Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Minor update.
  • Loading branch information
trc492 committed Jul 29, 2023
1 parent 8da8479 commit a48aa2e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The Framework Library provides numerous features. We will list some of them here
- FtcOpMode: Our own opmode that extends LinearOpMode but providing interface similar to OpMode where you put your code in some sort of loop method. FtcOpMode is a cooperative multi-tasking scheduler. As an advanced feature, our Framework Library also supports multi-threaded true multi-tasking. But for rookie teams who don't want to tackle the gotchas of true multi-tasking, cooperative multi-tasking is the way to go. This allows your autonomous to operate multiple subsystems at the same time instead of doing things sequentially. This is especially important since FTC autonomous period lasts only 30 seconds. In order to perform the maximum number of tasks in the autonomous period, your code would want to perform multiple tasks that have no dependencies on each other and perform them simultaneously. The Framework Library enables that in a trivial manor.
- State machine: The state machine infrastructure is the core of multi-tasking. Each task should use a state machine to keep track of their states. This allows FtcOpMode to switch between tasks and be able to maintain the state of each task when they are resumed from suspended state.
- Task syncrhonization: Some tasks have dependencies on each other. For example, autonomous may want to finish driving the robot to the specified location before dumping the game element to the proper spot. This requires task synchronization. The Framework Library provides a number of task synchronization features such as Events (TrcEvent) and Callbacks (TrcNotifier). Event allows an operation to signal it when the operation is completed so that the task waiting for it can resume. Callback allows the task to be called to perform additional work without the use of a state machine after the operation is completed, for example.
- Timers: The Timer Manager (TrcTimerMgr) manages multiple simultaneous timers. When a timer expires, you have the option of signaling an event or do a notification callback. For example, if you want to spin a motor for 3 seconds and turn it off afterwards, you can arm a timer that expires in 3 seconds and do a notification callback to turn the motor off. This type of operation is sometimes called "fire and forget".
- Timers: The Timer Manager (TrcTimer) manages multiple simultaneous timers. When a timer expires, you have the option of signaling an event or do a notification callback. For example, if you want to spin a motor for 3 seconds and turn it off afterwards, you can arm a timer that expires in 3 seconds and do a notification callback to turn the motor off. This type of operation is sometimes called "fire and forget".
- Advanced multi-tasking: In addition to cooperative multi-task, our Framework Library also supports multi-threaded tasks. The Library provides a number of standard threads (i.e. main robot thread, input thread and output thread). The main robot thread runs the FtcOpMode where the scheduler is performing cooperative multi-tasking on the main robot thread. The input thread handles all input tasks such as reading sensors and odometry. The output thread handles all output tasks such as motor and actuator tasks including PID control and pathing. If there is a special need that either requires high frequency processing and cannot afford any latency or a task that takes extra long time to run and thus blocking the thread unnecessarily long, the Library enables you to create STANDALONE tasks that have their own thread. All these tasks/threads are mananged by the Task Manager (TrcTaskMgr). Although everything provided and maintained by the Library are thread-safe, user must still be cautious when writing multi-threading code. Care must be taken to ensure you don't fall into the trap of two common multi-threaded programming woes: shared resource contention and task synchronization. If you don't understand these, it's better not to do multi-threaded multi-tasking and stick only with cooperative multi-tasking. Even with cooperative multi-tasking, you still need to apply some simple disciplines: do not block the main robot thread (i.e. no busy wait loop and sleep statements in your task code). Just start an operation and get out. Do not wait for it to complete. Most of the operations supported by the Framework Library are asynchronous. Calling them will start the operation and the control is returned back to your code immediately. Your state machine should take care waiting for an operation to complete. That's why it's called "cooperative multi-tasking". You must be good citizens for it to work properly.
- Inputs: The Framework Library supports many different input devices such as gamepad controllers, sensors and driver station dashboard.
- Gamepad controller: The Framework Library monitor all buttons on the gamepad for state changes. Any button presses or releases will result in a notification callback to your button event handler. This simplifies your TeleOp code tremendously.
Expand Down

0 comments on commit a48aa2e

Please sign in to comment.