WPILibC++ 2024.3.2
frc::SmartDashboard Class Reference

#include <frc/smartdashboard/SmartDashboard.h>

Public Member Functions

 SmartDashboard ()=delete
 

Static Public Member Functions

static void init ()
 
static bool ContainsKey (std::string_view key)
 Determines whether the given key is in this table. More...
 
static std::vector< std::string > GetKeys (int types=0)
 
static void SetPersistent (std::string_view key)
 Makes a key's value persistent through program restarts. More...
 
static void ClearPersistent (std::string_view key)
 Stop making a key's value persistent through program restarts. More...
 
static bool IsPersistent (std::string_view key)
 Returns whether the value is persistent through program restarts. More...
 
static nt::NetworkTableEntry GetEntry (std::string_view key)
 Returns an NT Entry mapping to the specified key. More...
 
static void PutData (std::string_view key, wpi::Sendable *data)
 Maps the specified key to the specified value in this table. More...
 
static void PutData (wpi::Sendable *value)
 Maps the specified key (where the key is the name of the Sendable) to the specified value in this table. More...
 
static wpi::SendableGetData (std::string_view keyName)
 Returns the value at the specified key. More...
 
static bool PutBoolean (std::string_view keyName, bool value)
 Maps the specified key to the specified value in this table. More...
 
static bool SetDefaultBoolean (std::string_view key, bool defaultValue)
 Gets the current value in the table, setting it if it does not exist. More...
 
static bool GetBoolean (std::string_view keyName, bool defaultValue)
 Returns the value at the specified key. More...
 
static bool PutNumber (std::string_view keyName, double value)
 Maps the specified key to the specified value in this table. More...
 
static bool SetDefaultNumber (std::string_view key, double defaultValue)
 Gets the current value in the table, setting it if it does not exist. More...
 
static double GetNumber (std::string_view keyName, double defaultValue)
 Returns the value at the specified key. More...
 
static bool PutString (std::string_view keyName, std::string_view value)
 Maps the specified key to the specified value in this table. More...
 
static bool SetDefaultString (std::string_view key, std::string_view defaultValue)
 Gets the current value in the table, setting it if it does not exist. More...
 
static std::string GetString (std::string_view keyName, std::string_view defaultValue)
 Returns the value at the specified key. More...
 
static bool PutBooleanArray (std::string_view key, std::span< const int > value)
 Put a boolean array in the table. More...
 
static bool SetDefaultBooleanArray (std::string_view key, std::span< const int > defaultValue)
 Gets the current value in the table, setting it if it does not exist. More...
 
static std::vector< int > GetBooleanArray (std::string_view key, std::span< const int > defaultValue)
 Returns the boolean array the key maps to. More...
 
static bool PutNumberArray (std::string_view key, std::span< const double > value)
 Put a number array in the table. More...
 
static bool SetDefaultNumberArray (std::string_view key, std::span< const double > defaultValue)
 Gets the current value in the table, setting it if it does not exist. More...
 
static std::vector< double > GetNumberArray (std::string_view key, std::span< const double > defaultValue)
 Returns the number array the key maps to. More...
 
static bool PutStringArray (std::string_view key, std::span< const std::string > value)
 Put a string array in the table. More...
 
static bool SetDefaultStringArray (std::string_view key, std::span< const std::string > defaultValue)
 Gets the current value in the table, setting it if it does not exist. More...
 
static std::vector< std::string > GetStringArray (std::string_view key, std::span< const std::string > defaultValue)
 Returns the string array the key maps to. More...
 
static bool PutRaw (std::string_view key, std::span< const uint8_t > value)
 Put a raw value (byte array) in the table. More...
 
static bool SetDefaultRaw (std::string_view key, std::span< const uint8_t > defaultValue)
 Gets the current value in the table, setting it if it does not exist. More...
 
static std::vector< uint8_t > GetRaw (std::string_view key, std::span< const uint8_t > defaultValue)
 Returns the raw value (byte array) the key maps to. More...
 
static bool PutValue (std::string_view keyName, const nt::Value &value)
 Maps the specified key to the specified complex value (such as an array) in this table. More...
 
static bool SetDefaultValue (std::string_view key, const nt::Value &defaultValue)
 Gets the current value in the table, setting it if it does not exist. More...
 
static nt::Value GetValue (std::string_view keyName)
 Retrieves the complex value (such as an array) in this table into the complex data object. More...
 
static void PostListenerTask (std::function< void()> task)
 Posts a task from a listener to the ListenerExecutor, so that it can be run synchronously from the main loop on the next call to updateValues(). More...
 
static void UpdateValues ()
 Puts all sendable data to the dashboard. More...
 

Constructor & Destructor Documentation

◆ SmartDashboard()

frc::SmartDashboard::SmartDashboard ( )
delete

Member Function Documentation

◆ ClearPersistent()

static void frc::SmartDashboard::ClearPersistent ( std::string_view  key)
static

Stop making a key's value persistent through program restarts.

The key cannot be null.

Parameters
keythe key name

◆ ContainsKey()

static bool frc::SmartDashboard::ContainsKey ( std::string_view  key)
static

Determines whether the given key is in this table.

Parameters
keythe key to search for
Returns
true if the table as a value assigned to the given key

◆ GetBoolean()

static bool frc::SmartDashboard::GetBoolean ( std::string_view  keyName,
bool  defaultValue 
)
static

Returns the value at the specified key.

If the key is not found, returns the default value.

Parameters
keyNamethe key
defaultValuethe default value to set if key doesn't exist
Returns
the value

◆ GetBooleanArray()

static std::vector< int > frc::SmartDashboard::GetBooleanArray ( std::string_view  key,
std::span< const int >  defaultValue 
)
static

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.

Parameters
keyThe key to look up.
defaultValueThe value to be returned if no value is found.
Returns
the value associated with the given key or the given default value if there is no value associated with the key
Note
This makes a copy of the array. If the overhead of this is a concern, use GetValue() instead.
The returned array is std::vector<int> instead of std::vector<bool> because std::vector<bool> is special-cased in C++. 0 is false, any non-zero value is true.

◆ GetData()

static wpi::Sendable * frc::SmartDashboard::GetData ( std::string_view  keyName)
static

Returns the value at the specified key.

Parameters
keyNamethe key
Returns
the value

◆ GetEntry()

static nt::NetworkTableEntry frc::SmartDashboard::GetEntry ( std::string_view  key)
static

Returns an NT Entry mapping to the specified key.

This is useful if an entry is used often, or is read and then modified.

Parameters
keythe key
Returns
the entry for the key

◆ GetKeys()

static std::vector< std::string > frc::SmartDashboard::GetKeys ( int  types = 0)
static
Parameters
typesbitmask of types; 0 is treated as a "don't care".
Returns
keys currently in the table

◆ GetNumber()

static double frc::SmartDashboard::GetNumber ( std::string_view  keyName,
double  defaultValue 
)
static

Returns the value at the specified key.

If the key is not found, returns the default value.

Parameters
keyNamethe key
defaultValuethe default value to set if the key doesn't exist
Returns
the value

◆ GetNumberArray()

static std::vector< double > frc::SmartDashboard::GetNumberArray ( std::string_view  key,
std::span< const double >  defaultValue 
)
static

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.

Parameters
keyThe key to look up.
defaultValueThe value to be returned if no value is found.
Returns
the value associated with the given key or the given default value if there is no value associated with the key
Note
This makes a copy of the array. If the overhead of this is a concern, use GetValue() instead.

◆ GetRaw()

static std::vector< uint8_t > frc::SmartDashboard::GetRaw ( std::string_view  key,
std::span< const uint8_t >  defaultValue 
)
static

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.

Parameters
keyThe key to look up.
defaultValueThe value to be returned if no value is found.
Returns
the value associated with the given key or the given default value if there is no value associated with the key
Note
This makes a copy of the raw contents. If the overhead of this is a concern, use GetValue() instead.

◆ GetString()

static std::string frc::SmartDashboard::GetString ( std::string_view  keyName,
std::string_view  defaultValue 
)
static

Returns the value at the specified key.

If the key is not found, returns the default value.

Parameters
keyNamethe key
defaultValuethe default value to set if the key doesn't exist
Returns
the value

◆ GetStringArray()

static std::vector< std::string > frc::SmartDashboard::GetStringArray ( std::string_view  key,
std::span< const std::string >  defaultValue 
)
static

Returns the string array the key maps to.

If the key does not exist or is of different type, it will return the default value.

Parameters
keyThe key to look up.
defaultValueThe value to be returned if no value is found.
Returns
the value associated with the given key or the given default value if there is no value associated with the key
Note
This makes a copy of the array. If the overhead of this is a concern, use GetValue() instead.

◆ GetValue()

static nt::Value frc::SmartDashboard::GetValue ( std::string_view  keyName)
static

Retrieves the complex value (such as an array) in this table into the complex data object.

Parameters
keyNamethe key

◆ init()

static void frc::SmartDashboard::init ( )
static

◆ IsPersistent()

static bool frc::SmartDashboard::IsPersistent ( std::string_view  key)
static

Returns whether the value is persistent through program restarts.

The key cannot be null.

Parameters
keythe key name

◆ PostListenerTask()

static void frc::SmartDashboard::PostListenerTask ( std::function< void()>  task)
static

Posts a task from a listener to the ListenerExecutor, so that it can be run synchronously from the main loop on the next call to updateValues().

Parameters
taskThe task to run synchronously from the main thread.

◆ PutBoolean()

static bool frc::SmartDashboard::PutBoolean ( std::string_view  keyName,
bool  value 
)
static

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.

Parameters
keyNamethe key
valuethe value
Returns
False if the table key already exists with a different type

◆ PutBooleanArray()

static bool frc::SmartDashboard::PutBooleanArray ( std::string_view  key,
std::span< const int >  value 
)
static

Put a boolean array in the table.

Parameters
keythe key to be assigned to
valuethe value that will be assigned
Returns
False if the table key already exists with a different type
Note
The array must be of int's rather than of bool's because std::vector<bool> is special-cased in C++. 0 is false, any non-zero value is true.

◆ PutData() [1/2]

static void frc::SmartDashboard::PutData ( std::string_view  key,
wpi::Sendable data 
)
static

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.

In order for the value to appear in the dashboard, it must be registered with SendableRegistry. WPILib components do this automatically.

Parameters
keythe key
datathe value

◆ PutData() [2/2]

static void frc::SmartDashboard::PutData ( wpi::Sendable value)
static

Maps the specified key (where the key is the name of the Sendable) 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.

In order for the value to appear in the dashboard, it must be registered with SendableRegistry. WPILib components do this automatically.

Parameters
valuethe value

◆ PutNumber()

static bool frc::SmartDashboard::PutNumber ( std::string_view  keyName,
double  value 
)
static

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.

Parameters
keyNamethe key
valuethe value
Returns
False if the table key already exists with a different type

◆ PutNumberArray()

static bool frc::SmartDashboard::PutNumberArray ( std::string_view  key,
std::span< const double >  value 
)
static

Put a number array in the table.

Parameters
keyThe key to be assigned to.
valueThe value that will be assigned.
Returns
False if the table key already exists with a different type

◆ PutRaw()

static bool frc::SmartDashboard::PutRaw ( std::string_view  key,
std::span< const uint8_t >  value 
)
static

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

Parameters
keyThe key to be assigned to.
valueThe value that will be assigned.
Returns
False if the table key already exists with a different type

◆ PutString()

static bool frc::SmartDashboard::PutString ( std::string_view  keyName,
std::string_view  value 
)
static

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.

Parameters
keyNamethe key
valuethe value
Returns
False if the table key already exists with a different type

◆ PutStringArray()

static bool frc::SmartDashboard::PutStringArray ( std::string_view  key,
std::span< const std::string >  value 
)
static

Put a string array in the table.

Parameters
keyThe key to be assigned to.
valueThe value that will be assigned.
Returns
False if the table key already exists with a different type

◆ PutValue()

static bool frc::SmartDashboard::PutValue ( std::string_view  keyName,
const nt::Value value 
)
static

Maps the specified key to the specified complex value (such as an array) in this table.

The value can be retrieved by calling the RetrieveValue method with a key that is equal to the original key.

Parameters
keyNamethe key
valuethe value
Returns
False if the table key already exists with a different type

◆ SetDefaultBoolean()

static bool frc::SmartDashboard::SetDefaultBoolean ( std::string_view  key,
bool  defaultValue 
)
static

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

Parameters
keythe key
defaultValuethe default value to set if key doesn't exist.
Returns
False if the table key exists with a different type

◆ SetDefaultBooleanArray()

static bool frc::SmartDashboard::SetDefaultBooleanArray ( std::string_view  key,
std::span< const int >  defaultValue 
)
static

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

Parameters
keythe key
defaultValuethe default value to set if key doesn't exist.
Returns
False if the table key exists with a different type

◆ SetDefaultNumber()

static bool frc::SmartDashboard::SetDefaultNumber ( std::string_view  key,
double  defaultValue 
)
static

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

Parameters
keyThe key.
defaultValueThe default value to set if key doesn't exist.
Returns
False if the table key exists with a different type

◆ SetDefaultNumberArray()

static bool frc::SmartDashboard::SetDefaultNumberArray ( std::string_view  key,
std::span< const double >  defaultValue 
)
static

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

Parameters
keyThe key.
defaultValueThe default value to set if key doesn't exist.
Returns
False if the table key exists with a different type

◆ SetDefaultRaw()

static bool frc::SmartDashboard::SetDefaultRaw ( std::string_view  key,
std::span< const uint8_t >  defaultValue 
)
static

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

Parameters
keyThe key.
defaultValueThe default value to set if key doesn't exist.
Returns
False if the table key exists with a different type

◆ SetDefaultString()

static bool frc::SmartDashboard::SetDefaultString ( std::string_view  key,
std::string_view  defaultValue 
)
static

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

Parameters
keythe key
defaultValuethe default value to set if key doesn't exist.
Returns
False if the table key exists with a different type

◆ SetDefaultStringArray()

static bool frc::SmartDashboard::SetDefaultStringArray ( std::string_view  key,
std::span< const std::string >  defaultValue 
)
static

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

Parameters
keyThe key.
defaultValueThe default value to set if key doesn't exist.
Returns
False if the table key exists with a different type

◆ SetDefaultValue()

static bool frc::SmartDashboard::SetDefaultValue ( std::string_view  key,
const nt::Value defaultValue 
)
static

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

Parameters
keythe key
defaultValueThe default value to set if key doesn't exist.
Returns
False if the table key exists with a different type

◆ SetPersistent()

static void frc::SmartDashboard::SetPersistent ( std::string_view  key)
static

Makes a key's value persistent through program restarts.

Parameters
keythe key to make persistent

◆ UpdateValues()

static void frc::SmartDashboard::UpdateValues ( )
static

Puts all sendable data to the dashboard.


The documentation for this class was generated from the following file: