SmartDashboard

class wpilib.SmartDashboard[source]

Bases: object

The bridge between robot programs and the SmartDashboard on the laptop

When a value is put into the SmartDashboard, it pops up on the SmartDashboard on the remote host. Users can put values into and get values from the SmartDashboard.

These values can also be accessed by a NetworkTables client via the ‘SmartDashboard’ table:

from networktables import NetworkTable
sd = NetworkTable.getTable('SmartDashboard')

# sd.putXXX and sd.getXXX work as expected here
classmethod clearFlags(key, flags)[source]

Clears flags on the specified key in this table. The key can not be null.

Parameters:
  • key – the key name
  • flags – the flags to clear (bitmask)
classmethod clearPersistent(key)[source]

Stop making a key’s value persistent through program restarts. The key cannot be null.

Parameters:key – the key name
classmethod containsKey(key)[source]

Checks the table and tells if it contains the specified key.

Parameters:key – key the key to search for
Returns:true if the table as a value assigned to the given key
classmethod delete(key)[source]

Deletes the specified key in this table. The key can not be null.

Parameters:key – the key name
classmethod getBoolean(key, defaultValue=<class 'wpilib.smartdashboard.SmartDashboard._defaultValueSentry'>)[source]

Returns the boolean the key maps to. If the key does not exist or is of different type, it will return the default value; if that is not provided, it will throw a KeyError.

Calling this method without passing defaultValue is deprecated.

Parameters:
  • key (str) – the key to look up
  • defaultValue – returned if the key doesn’t exist
Returns:

the value associated with the given key or the given default value if there is no value associated with the key

Raises:

KeyError if the key doesn’t exist and defaultValue is not provided.

classmethod getBooleanArray(key, defaultValue=<class 'wpilib.smartdashboard.SmartDashboard._defaultValueSentry'>)[source]

Returns the boolean array the key maps to. If the key does not exist or is of different type, it will return the default value; if that is not provided, it will throw a KeyError.

Calling this method without passing defaultValue is deprecated.

Parameters:
  • key (str) – the key to look up
  • defaultValue – returned if the key doesn’t exist
Returns:

the value associated with the given key or the given default value if there is no value associated with the key

Raises:

KeyError if the key doesn’t exist and defaultValue is not provided.

classmethod getData(key)[source]

Returns the value at the specified key.

Parameters:key (str) – the key
Returns:the value
Raises:KeyError if the key doesn’t exist
classmethod getDouble(key, defaultValue=<class 'wpilib.smartdashboard.SmartDashboard._defaultValueSentry'>)

Returns the number the key maps to. If the key does not exist or is of different type, it will return the default value; if that is not provided, it will throw a KeyError.

Calling this method without passing defaultValue is deprecated.

Parameters:
  • key (str) – the key to look up
  • defaultValue – returned if the key doesn’t exist
Returns:

the value associated with the given key or the given default value if there is no value associated with the key

Raises:

KeyError if the key doesn’t exist and defaultValue is not provided.

classmethod getFlags(key)[source]

Returns the flags for the specified key.

Parameters:key – the key name
Returns:the flags, or 0 if the key is not defined
classmethod getInt(key, defaultValue=<class 'wpilib.smartdashboard.SmartDashboard._defaultValueSentry'>)

Returns the number the key maps to. If the key does not exist or is of different type, it will return the default value; if that is not provided, it will throw a KeyError.

Calling this method without passing defaultValue is deprecated.

Parameters:
  • key (str) – the key to look up
  • defaultValue – returned if the key doesn’t exist
Returns:

the value associated with the given key or the given default value if there is no value associated with the key

Raises:

KeyError if the key doesn’t exist and defaultValue is not provided.

classmethod getKeys(types=0)[source]

Get array of keys in the table.

Parameters:types – bitmask of types; 0 is treated as a “don’t care”.
Returns:keys currently in the table
classmethod getNumber(key, defaultValue=<class 'wpilib.smartdashboard.SmartDashboard._defaultValueSentry'>)[source]

Returns the number the key maps to. If the key does not exist or is of different type, it will return the default value; if that is not provided, it will throw a KeyError.

Calling this method without passing defaultValue is deprecated.

Parameters:
  • key (str) – the key to look up
  • defaultValue – returned if the key doesn’t exist
Returns:

the value associated with the given key or the given default value if there is no value associated with the key

Raises:

KeyError if the key doesn’t exist and defaultValue is not provided.

classmethod getNumberArray(key, defaultValue=<class 'wpilib.smartdashboard.SmartDashboard._defaultValueSentry'>)[source]

Returns the number array the key maps to. If the key does not exist or is of different type, it will return the default value; if that is not provided, it will throw a KeyError.

Calling this method without passing defaultValue is deprecated.

Parameters:
  • key (str) – the key to look up
  • defaultValue – returned if the key doesn’t exist
Returns:

the value associated with the given key or the given default value if there is no value associated with the key

Raises:

KeyError if the key doesn’t exist and defaultValue is not provided.

classmethod getRaw(key, defaultValue=<class 'wpilib.smartdashboard.SmartDashboard._defaultValueSentry'>)[source]

Returns the raw value (byte array) the key maps to. If the key does not exist or is of different type, it will return the default value; if that is not provided, it will throw a KeyError.

Calling this method without passing defaultValue is deprecated.

Parameters:
  • key (str) – the key to look up
  • defaultValue – returned if the key doesn’t exist
Returns:

the value associated with the given key or the given default value if there is no value associated with the key

Raises:

KeyError if the key doesn’t exist and defaultValue is not provided.

classmethod getString(key, defaultValue=<class 'wpilib.smartdashboard.SmartDashboard._defaultValueSentry'>)[source]

Returns the string the key maps to. If the key does not exist or is of different type, it will return the default value; if that is not provided, it will throw a KeyError.

Calling this method without passing defaultValue is deprecated.

Parameters:
  • key (str) – the key to look up
  • defaultValue – returned if the key doesn’t exist
Returns:

the value associated with the given key or the given default value if there is no value associated with the key

Raises:

KeyError if the key doesn’t exist and defaultValue is not provided.

classmethod isPersistent(key)[source]

Returns whether the value is persistent through program restarts. The key cannot be null.

Parameters:key – the key name
Returns:True if the value is persistent.
classmethod putBoolean(key, value)[source]

Put a boolean in the table.

Parameters:
  • key – the key to be assigned to
  • value – the value that will be assigned

:return False if the table key already exists with a different type

classmethod putBooleanArray(key, value)[source]

Put a boolean array in the table.

Parameters:
  • key – the key to be assigned to
  • value – the value that will be assigned
Returns:

False if the table key already exists with a different type

classmethod putData(*args, **kwargs)[source]

Maps the specified key to the specified value in this table. The value can be retrieved by calling the get method with a key that is equal to the original key.

Two argument formats are supported: key, data:

Parameters:
  • key (str) – the key (cannot be None)
  • data – the value

Or the single argument “value”:

Parameters:value – the named value (getName is called to retrieve the value)
classmethod putDouble(key, value)

Put a number in the table.

Parameters:
  • key – the key to be assigned to
  • value – the value that will be assigned
Returns:

False if the table key already exists with a different type

classmethod putInt(key, value)

Put a number in the table.

Parameters:
  • key – the key to be assigned to
  • value – the value that will be assigned
Returns:

False if the table key already exists with a different type

classmethod putNumber(key, value)[source]

Put a number in the table.

Parameters:
  • key – the key to be assigned to
  • value – the value that will be assigned
Returns:

False if the table key already exists with a different type

classmethod putNumberArray(key, value)[source]

Put a number array in the table.

Parameters:
  • key – the key to be assigned to
  • value – the value that will be assigned
Returns:

False if the table key already exists with a different type

classmethod putRaw(key, value)[source]

Put a raw value (byte array) in the table.

Parameters:
  • key – the key to be assigned to
  • value – the value that will be assigned
Returns:

False if the table key already exists with a different type

classmethod putString(key, value)[source]

Put a string in the table.

Parameters:
  • key – the key to be assigned to
  • value – the value that will be assigned
Returns:

False if the table key already exists with a different type

classmethod setDefaultBoolean(key, defaultValue)[source]

Gets the current value in the table, setting it if it does not exist.

Parameters:
  • key – the key
  • defaultValue – the default value to set if key doens’t exist.
Returns:

False if the table key exists with a different type

classmethod setDefaultBooleanArray(key, defaultValue)[source]

Gets the current value in the table, setting it if it does not exist.

Parameters:
  • key – the key
  • defaultValue – the default value to set if key doens’t exist.
Returns:

False if the table key exists with a different type

classmethod setDefaultNumber(key, defaultValue)[source]

Gets the current value in the table, setting it if it does not exist.

Parameters:
  • key – the key
  • defaultValue – the default value to set if key doens’t exist.
Returns:

False if the table key exists with a different type

classmethod setDefaultNumberArray(key, defaultValue)[source]

Gets the current value in the table, setting it if it does not exist.

Parameters:
  • key – the key
  • defaultValue – the default value to set if key doens’t exist.
Returns:

False if the table key exists with a different type

classmethod setDefaultRaw(key, defaultValue)[source]

Gets the current value in the table, setting it if it does not exist.

Parameters:
  • key – the key
  • defaultValue – the default value to set if key doens’t exist.
Returns:

False if the table key exists with a different type

classmethod setDefaultString(key, defaultValue)[source]

Gets the current value in the table, setting it if it does not exist.

Parameters:
  • key – the key
  • defaultValue – the default value to set if key doens’t exist.
Returns:

False if the table key exists with a different type

classmethod setFlags(key, flags)[source]

Sets flags on the specified key in this table. The key can not be null.

Parameters:
  • key – the key name
  • flags – the flags to set (bitmask)
classmethod setPersistent(key)[source]

Makes a key’s value persistent through program restarts. The key cannot be null.

Parameters:key – the key name
table = None
tablesToData = {}