Closed BearsAreAwsome closed 5 years ago
Added initialize and getInstance method.
Looks like when I created the issue I forgot to include that you have to include an if statement inside the initialize method so that no more than one INSTANCE is able to be created.
Done
Although I know there is a way around having to create these methods, when we were creating code in the off season, nothing worked without having them. The error when they were not there was either "Watchdog was not fed" or "Robots should not quit but yours did" (I can't remember which one it was as there was a simple logic error once I implemented the methods that took a while to find). We currently have two options when it comes to this which are either to create these methods, which is rather simple, or figure out the other way to get around creating them. I would personally create the two methods as they are rather simple to create, and seem to work reliably.
The first thing do is instantiate (but don't initialize as that is the purpose of having a initialize method) a private static DriveSystem variable named INSTANCE. The initialize method which has a return type of void sets INSTANCE equal to a new DriveSystem. The getInstance method has return type DriveSystem and all it returns is INSTANCE. The final step is to add a statement in Robot's robotInit method which is DriveSystem.getInstance();