Package edu.wpi.first.wpilibj2.command
Class CommandBase
- java.lang.Object
-
- edu.wpi.first.wpilibj2.command.CommandBase
-
- Direct Known Subclasses:
CommandGroupBase,ConditionalCommand,FunctionalCommand,InstantCommand,MecanumControllerCommand,NotifierCommand,PerpetualCommand,PIDCommand,ProfiledPIDCommand,ProxyScheduleCommand,RamseteCommand,RunCommand,ScheduleCommand,SelectCommand,StartEndCommand,SwerveControllerCommand,TrapezoidProfileCommand,WaitCommand,WaitUntilCommand
public abstract class CommandBase extends Object implements Sendable, Command
-
-
Field Summary
Fields Modifier and Type Field Description protected Set<Subsystem>m_requirements
-
Constructor Summary
Constructors Modifier Constructor Description protectedCommandBase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddRequirements(Subsystem... requirements)Adds the specified requirements to the command.StringgetName()Gets the name of thisSendableobject.Set<Subsystem>getRequirements()Specifies the set of subsystems used by this command.StringgetSubsystem()Gets the subsystem name of this Command.voidinitSendable(SendableBuilder builder)Initializes this sendable.voidsetName(String name)Sets the name of this Command.voidsetSubsystem(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, cancel, deadlineWith, end, execute, hasRequirement, initialize, isFinished, isScheduled, perpetually, raceWith, runsWhenDisabled, schedule, schedule, withInterrupt, withTimeout
-
-
-
-
Method Detail
-
addRequirements
public final void addRequirements(Subsystem... requirements)
Adds the specified requirements to the command.- Parameters:
requirements- the requirements to add
-
getRequirements
public Set<Subsystem> getRequirements()
Description copied from interface:CommandSpecifies the set of subsystems used by this command. Two commands cannot use the same subsystem at the same time. If the command is scheduled as interruptible and another command is scheduled that shares a requirement, the command will be interrupted. Else, the command will not be scheduled. 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:
getRequirementsin interfaceCommand- Returns:
- the set of subsystems that are required
-
getName
public String getName()
Description copied from interface:SendableGets the name of thisSendableobject.
-
setName
public void setName(String name)
Sets the name of this Command.
-
getSubsystem
public String getSubsystem()
Gets the subsystem name of this Command.- Specified by:
getSubsystemin interfaceSendable- Returns:
- Subsystem name
-
setSubsystem
public void setSubsystem(String subsystem)
Sets the subsystem name of this Command.- Specified by:
setSubsystemin interfaceSendable- Parameters:
subsystem- subsystem name
-
initSendable
public void initSendable(SendableBuilder builder)
Initializes this sendable. Useful for allowing implementations to easily extend SendableBase.- Specified by:
initSendablein interfaceSendable- Parameters:
builder- the builder used to construct this sendable
-
-