Base Class (Step 1)
Code Organization Part 1
When structuring your FTC code, we recommend using a central class that acts as a hub for all of your hardware initializations, global variables, module classes, and utility functions. You can then create your opModes such that it is an extension of this base class so you can use all the methods within it.
The benefit of having a base class is that you only need to declare your hardware and create utility functions once, rather than in every opMode. This keeps your code clean and easy to read which can save a lot of time especially as your codebase becomes more complex.
Implementation
Here are some notes on the following code:
We make use of the LinearOpModes, however, you can modify the class such that it supports typical opModes as well.
If you are using
MANUAL
mode in yourLynxModule
make sure to add a function to clear the LynxModule hubs as well.
Here is the function you should have to clear your cache if your LynxModule mode is manual.
In the next module, you will learn how to make use of the base class in your opModes.
Last updated