Package edu.wpi.first.wpilibj2.command
Class CommandBase
java.lang.Object
edu.wpi.first.wpilibj2.command.CommandBase
- Direct Known Subclasses:
CommandGroupBase
,ConditionalCommand
,FunctionalCommand
,MecanumControllerCommand
,NotifierCommand
,PerpetualCommand
,PIDCommand
,ProfiledPIDCommand
,ProxyCommand
,ProxyScheduleCommand
,RamseteCommand
,RepeatCommand
,ScheduleCommand
,SelectCommand
,SwerveControllerCommand
,TrapezoidProfileCommand
,WaitCommand
,WaitUntilCommand
,WrapperCommand
public abstract class CommandBase extends Object implements Sendable, Command
-
Nested Class Summary
Nested classes/interfaces inherited from interface edu.wpi.first.wpilibj2.command.Command
Command.InterruptionBehavior
-
Field Summary
Fields Modifier and Type Field Description protected Set<Subsystem>
m_requirements
-
Constructor Summary
Constructors Modifier Constructor Description protected
CommandBase()
-
Method Summary
Modifier and Type Method Description void
addRequirements(Subsystem... requirements)
Adds the specified requirements to the command.String
getName()
Gets the name of this Command.Set<Subsystem>
getRequirements()
Specifies the set of subsystems used by this command.String
getSubsystem()
Gets the subsystem name of this Command.void
initSendable(SendableBuilder builder)
Initializes this sendable.void
setName(String name)
Sets the name of this Command.void
setSubsystem(String subsystem)
Sets the subsystem name of this Command.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface edu.wpi.first.wpilibj2.command.Command
alongWith, andThen, andThen, asProxy, beforeStarting, beforeStarting, cancel, deadlineWith, end, execute, finallyDo, getInterruptionBehavior, handleInterrupt, hasRequirement, ignoringDisable, initialize, isFinished, isScheduled, perpetually, raceWith, repeatedly, runsWhenDisabled, schedule, unless, until, withInterrupt, withInterruptBehavior, withName, withTimeout
-
Field Details
-
Constructor Details
-
CommandBase
protected CommandBase()
-
-
Method Details
-
addRequirements
Adds the specified requirements to the command.- Parameters:
requirements
- the requirements to add
-
getRequirements
Description copied from interface:Command
Specifies the set of subsystems used by this command. Two commands cannot use the same subsystem at the same time. If another command is scheduled that shares a requirement,Command.getInterruptionBehavior()
will be checked and followed. If no subsystems are required, return an empty set.Note: it is recommended that user implementations contain the requirements as a field, and return that field here, rather than allocating a new set every time this is called.
- Specified by:
getRequirements
in interfaceCommand
- Returns:
- the set of subsystems that are required
- See Also:
Command.InterruptionBehavior
-
getName
Description copied from interface:Command
Gets the name of this Command. Defaults to the simple class name if not overridden. -
setName
Sets the name of this Command. -
getSubsystem
Gets the subsystem name of this Command.- Returns:
- Subsystem name
-
setSubsystem
Sets the subsystem name of this Command.- Parameters:
subsystem
- subsystem name
-
initSendable
Initializes this sendable. Useful for allowing implementations to easily extend SendableBase.- Specified by:
initSendable
in interfaceSendable
- Parameters:
builder
- the builder used to construct this sendable
-