Package edu.wpi.first.wpilibj.command
Class Subsystem
java.lang.Object
edu.wpi.first.wpilibj.command.Subsystem
- Direct Known Subclasses:
DriveBase
public abstract class Subsystem
extends java.lang.Object
This class defines a major component of the robot.
A good example of a subsystem is the driveline, or a claw if the robot has one.
All motors should be a part of a subsystem. For instance, all the wheel motors should be a part of some kind of "Driveline" subsystem.
Subsystems are used within the command system as requirements for Command
. Only one
command which requires a subsystem can run at a time. Also, subsystems can have default commands
which are started if there is no command running which requires this subsystem.
- See Also:
Command
-
Constructor Summary
Constructors Constructor Description Subsystem()
-
Method Summary
Modifier and Type Method Description Command
getCurrentCommand()
Returns the command which currently claims this subsystem.Command
getDefaultCommand()
Returns the default command (or null if there is none).void
periodic()
When the run method of the scheduler is called this method will be called.void
setDefaultCommand(Command command)
Sets the default command.
-
Constructor Details
-
Subsystem
public Subsystem()
-
-
Method Details
-
periodic
public void periodic()When the run method of the scheduler is called this method will be called. -
setDefaultCommand
Sets the default command. If this is not called or is called with null, then there will be no default command for the subsystem.WARNING: This should NOT be called in a constructor if the subsystem is a singleton.
- Parameters:
command
- the default command (or null if there should be none)- Throws:
IllegalUseOfCommandException
- if the command does not require the subsystem
-
getDefaultCommand
Returns the default command (or null if there is none).- Returns:
- the default command
-
getCurrentCommand
Returns the command which currently claims this subsystem.- Returns:
- the command which currently claims this subsystem
-