Subsystem requirements: "Why can't it just be static?" #54
Pinned
GalexY727
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What even is a subsystem?
Subsystems are the mechanical parts of our robot. They contain motors that run certain components, and it's important to be able to handle them throughout your code while also keeping in mind how many subsystems are being told to move at any specific moment. They commonly have
Command
methods inside of them, which give other files easy access to complete tasks using the subsystem, such asintake.getIntakeCommand()
.Requirements:
Here's how WPILib explains it:
Interpretation/translation:
The best to keep track of our currently used subsystems is through requirements, which is an optional additional parameter that can be applied to almost every
Command
, such asCommands.run()
andCommands.runOnce()
. Additionally, since our subsystem extendsSubsystemBase
, we are given the alternative (and cleaner) solution to adding requirements by callingsuper.runOnce()
which can also be written as justrunOnce()
. By removing theCommands.
prefix to ourCommands.runOnce()
s, we automatically add a requirement ofthis
to our command, which means that additional commands requesting access to the subsystem will either be interrupted and stopped (if it is a default command) or ignored since the subsystem in question is already occupied with a task.Beta Was this translation helpful? Give feedback.
All reactions