LongMetal-Robotics / ShowBot

The code for LongMetal's upcoming Show Bot
MIT License
0 stars 0 forks source link

Add Preferences to enable/disable certain subsystems #10

Closed i-am-gizm0 closed 4 years ago

i-am-gizm0 commented 4 years ago

WPILib includes a class called Preferences, which allows for certain settings to be stored across reboots. We can use that to only enable certain subsystems when we want to (include code before the physical part is ready). For example, if the preference is false, it doesn't even create the object or we can use it to change values without changing the code for testing. Preferences documentation

jon-pun commented 4 years ago

I imported the Preferences class, and then threw preferences for if the Shooter and Manipulator are enabled under robotInit() in Robot.java.

Now, you should be able to change what booleans get stored in Preferences in View >> Add >> Robot Preferences. These will be stored when the robot gets shut down, and will be saved in the RoboRIO.

Note: Although the booleans for if the Shooter and Manipulator are enabled exist and can be used, I haven't done anything with them. You can (I think?) just put some "if/else" statements on whether to actually run the elements of the code based on these booleans later.

i-am-gizm0 commented 4 years ago

In the WPILib simulation, this works