Subsystem

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

Bases: wpilib.SendableBase

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.
addChild(child, name=None)[source]

Associate a Sendable with this Subsystem. Update the child’s name if provided

Parameters:
  • child – sendable
  • name – name to give child
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
getCurrentCommandName()[source]

Returns the current command name, or empty string if no current command.

Returns:the current command name
getDefaultCommand()[source]

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

Returns:the default command
getDefaultCommandName()[source]

Returns the default command name, or empty string is there is none.

Returns:the default command name
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.

initSendable(builder)[source]
periodic()[source]

When the run method of the scheduler is called this method will be called.

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.