4533-phoenix / DeepSpaceRobot

This is the reprository where the code for the 2019 season is located.
1 stars 0 forks source link

Adding the initialize and getInstance Methods in DriveSystem #11

Closed BearsAreAwsome closed 5 years ago

BearsAreAwsome commented 5 years ago

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();

asvaliveti commented 5 years ago

Added initialize and getInstance method.

BearsAreAwsome commented 5 years ago

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.

BearsAreAwsome commented 5 years ago

Done