edu.wpi.first.wpilibj.command
Class Subsystem

java.lang.Object
  extended by edu.wpi.first.wpilibj.command.Subsystem
All Implemented Interfaces:
SmartDashboardData, SmartDashboardNamedData
Direct Known Subclasses:
PIDSubsystem

public abstract class Subsystem
extends java.lang.Object
implements SmartDashboardNamedData

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.

Author:
Joe Grinstead
See Also:
Command

Constructor Summary
Subsystem()
          Creates a subsystem.
Subsystem(java.lang.String name)
          Creates a subsystem with the given name
 
Method Summary
 Command getCurrentCommand()
          Returns the command which currently claims this subsystem.
protected  Command getDefaultCommand()
          Returns the default command (or null if there is none).
 java.lang.String getName()
          Returns the name of this subsystem, which is by default the class name.
 NetworkTable getTable()
          Returns the NetworkTable associated with the data.
 java.lang.String getType()
          Returns the type of the data.
protected abstract  void initDefaultCommand()
          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.
protected  void setDefaultCommand(Command command)
          Sets the default command.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Subsystem

public Subsystem(java.lang.String name)
Creates a subsystem with the given name

Parameters:
name - the name of the subsystem

Subsystem

public Subsystem()
Creates a subsystem. This will set the name to the name of the class.

Method Detail

initDefaultCommand

protected abstract void initDefaultCommand()
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.


setDefaultCommand

protected void setDefaultCommand(Command command)
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

protected Command getDefaultCommand()
Returns the default command (or null if there is none).

Returns:
the default command

getCurrentCommand

public Command getCurrentCommand()
Returns the command which currently claims this subsystem.

Returns:
the command which currently claims this subsystem

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getName

public java.lang.String getName()
Returns the name of this subsystem, which is by default the class name.

Specified by:
getName in interface SmartDashboardNamedData
Returns:
the name of this subsystem

getType

public java.lang.String getType()
Description copied from interface: SmartDashboardData
Returns the type of the data. This is used by the SmartDashboard on the desktop to determine what to do with the table returned by getTable().

For instance, if the type was "Button", then the SmartDashboard would show the data as a button on the desktop and would know to look at and modify the "pressed" field in the NetworkTable returned by getTable().

Specified by:
getType in interface SmartDashboardData
Returns:
the type of the data

getTable

public NetworkTable getTable()
Description copied from interface: SmartDashboardData
Returns the NetworkTable associated with the data. The table should contain all the information the desktop version of SmartDashboard needs to interact with the object. The data should both keep the table up-to-date and also react to changes that the SmartDashboard might make.

For instance, the SendablePIDController will put its p, i and d values into its table and will change them if the table receives new values.

This method should return the same table between calls

Specified by:
getTable in interface SmartDashboardData
Returns:
the table that represents this data