|
Re: Modular Autonomous?
We do something very similar to the above (but in Java).
We defined a custom "scripting format" that lets you describe high level robot behaviors in a plain text format. The "autonomous mode text file" can be created on a laptop (either with Notepad or, hopefully next year, in a full-featured GUI) and FTP'd down to the cRIO. Upon autonomous mode starting, our system searches the file system for the autonomous.txt file and executes the commands sequentially.
The actual bit of code that executes each command (or Action, as we call them) is highly object oriented. An "AutonomousThread" instance receives an array of Action objects. Actions each have "execute()" and "cancel()" methods that are implemented to provide the desired robot behavior. Because of the beauty of polymorphism, you just need to loop through each Action and call "execute()" for each step of the recipe.
If you have the time (and interest), a system like this is fun to create and can lead to more maintainable code. Of course, it takes a lot of boilerplate to get it up and running, and you need to be absolutely sure it is bug free or you will be doing yourself no favors.
|