OpModeLazyCells in OpModes.
OpMode templating is an alternative to writing a RobotHardware class / file,
that scales better through your usage of Dairy than using one would, because it
supports the reuse of Features that are enabled via annotation.
What is a RobotHardware file?
I can no-longer find the article that I once read on gm0, as such, it is
not linked here.
RobotHardware or Robot class, even when they have more powerful and flexible
tools already in use in their code! and it lead me down a path of trying (and
failing) several different ways to write reusable robot code in FTC.
The RobotHardware class serves the purpose of collecting all of your common
robot setup code into one place, which is then reused across all OpModes.
Advantages:
- Much better than duplicating code across OpModes.
- Allows for complex reusable methods and functions to allow for common complex control to be reused as well.
- With some work, allows for automatic management of systems that require frequent updates, like control loops.
- Inflexible, you can’t pick and choose parts you want.
- Requires some boiler plate for each OpMode, but this could be avoided using
Dairy
Features. - Gets bloated with needing to handle a whole bunch of logic for a whole bunch of systems.
Features, and adds some tools for using them with
Mercurial, so its easy to create your own).
However, there is a great deal of merit in the reason that teams using
subsystems were still using one. They didn’t want to repeat that boilerplate of
setting up their subsystems! So lets take a look at OpMode templating, an
alternate approach that supports reducing the boilerplate of Dairy annotations,
and supports the reducing the boilerplate of hardware.
A template: