Subsystem

class wpilib.command.Subsystem(name=None)[source]

Bases: wpilib.Sendable

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

Creates a subsystem.

Parameters:name – the name of the subsystem; if None, it will be set to the name to the name of the class.
confirmCommand()[source]

Call this to alert Subsystem that the current command is actually the command. Sometimes, the Subsystem is told that it has no command while the Scheduler is going through the loop, only to be soon after given a new one. This will avoid that situation.

getCurrentCommand()[source]

Returns the command which currently claims this subsystem.

Returns:the command which currently claims this subsystem
getDefaultCommand()[source]

Returns the default command (or None if there is none).

Returns:the default command
getName()[source]

Returns the name of this subsystem, which is by default the class name.

Returns:the name of this subsystem
initDefaultCommand()[source]

Initialize the default command for a subsystem By default subsystems have no default command, but if they do, the default command is set with this method. It is called on all Subsystems by CommandBase in the users program after all the Subsystems are created.

setCurrentCommand(command)[source]

Sets the current command

Parameters:command – the new current command
setDefaultCommand(command)[source]

Sets the default command. If this is not called or is called with None, then there will be no default command for the subsystem.

Parameters:command – the default command (or None if there should be none)

Warning

This should NOT be called in a constructor if the subsystem is a singleton.