Showing Data on the LabVIEW Dashboard with C++ Code

https://wpilib.screenstepslive.com/s/currentCS/m/driver_station/l/272692-using-the-labview-dashboard-with-c-java-code

The default LabVIEW Dashboard utilizes Network Tables to pass values and is therefore compatible with C++ and Java robot programs. This article covers the keys and value ranges to use to work with the Dashboard.

Drive Tab

https://s3.amazonaws.com/screensteps_live/images/Wpilib/272692/1/rendered/ce2c43d1-26a5-4140-b634-8fd8f2821298.png?AWSAccessKeyId=AKIAJRW37ULKKSXWY73Q&Expires=1512093584&Signature=dJaV4hh6DyVkqlMt%2Bb1p35dtQaQ%3D

Most of the indicators on the Drive tab utilize arrays. The c++ and Java SmartDashboard classes do not currently support sending arrays.

Basic Tab

https://s3.amazonaws.com/screensteps_live/images/Wpilib/272692/1/rendered/1ff2b15c-b70f-41b1-adf5-1a42310ba38b.png?AWSAccessKeyId=AKIAJRW37ULKKSXWY73Q&Expires=1512093617&Signature=Y7tr4FH87VwC8eAu%2FP8A6wIHOpk%3D

The Basic tab uses a number of keys in the a “DB” sub-table to send/recieve Dashboard data. The LED’s are output only, the other fields are all bi-directional (send or recieve).

Labels

The labels are currently sent as an array. C++ and Java SmartDashboard classes do not currently support sending arrays.

Strings

https://s3.amazonaws.com/screensteps_live/images/Wpilib/272692/1/rendered/cc7f8f88-1fab-4abc-be77-74b0560d6bbd.png?AWSAccessKeyId=AKIAJRW37ULKKSXWY73Q&Expires=1512093632&Signature=mlGY9oPyMC6HmUijaGguV12XgDk%3D

The strings are labeled top-to-bottom, left-to-right from “DB/String 0” to “DB/String 9”. Each String field can display at least 21 characters (exact number depends on what characters). To write to these strings:

Java: SmartDashboard.putString(“DB/String 0”, “My 21 Char TestString”);

C++: SmartDashboard::PutString(“DB/String 0”, “My 21 Char TestString”);

 

To read string data entered on the Dashboard:

Java: String dashData = SmartDashboard.getString(“DB/String 0”, “myDefaultData”);

C++: std::string dashData = SmartDashboard::GetString(“DB/String 0”, “myDefaultData”);

Buttons and LEDs

https://s3.amazonaws.com/screensteps_live/images/Wpilib/272692/1/rendered/5118759a-3fbb-4201-af9c-2bdaeacc7cd2.png?AWSAccessKeyId=AKIAJRW37ULKKSXWY73Q&Expires=1512093649&Signature=eOYpm9EYlQUZqSEDwTUpLQCZkuQ%3D

The Buttons and LEDs are boolean values and are labeled top-to-bottom from “DB/Button 0” to “DB/Button 3” and “DB/LED 0” to “DB/LED 3”. The Buttons are bi-directional, the LEDs are only able to be written from the Robot and read on the Dashboard. To write to the Buttons or LEDs:

Java: SmartDashboard.putBoolean(“DB/Button 0”, true);

C++: SmartDashboard::PutBoolean(“DB/Button 0”, true);

 

To read from the Buttons:

Java (default value of false): boolean buttonValue = SmartDashboard.getBoolean(“DB/Button 0”, false);

C++ (default value of false): bool buttonValue = SmartDashboard::GetBoolean(“DB/Button 0”, false);

Sliders

https://s3.amazonaws.com/screensteps_live/images/Wpilib/272692/1/rendered/e440aca4-14e8-42cc-acd7-a5bf667962a2.png?AWSAccessKeyId=AKIAJRW37ULKKSXWY73Q&Expires=1512093661&Signature=dDWVDYRqxo1Aky1ncXJyZxzCTAM%3D

The Sliders are bi-directional analog (double) controls/indicators with a range from 0 to 5. To write to these indicators:

Java: SmartDashboard.putNumber(“DB/Slider 0”, 2.58);

C++: SmartDashboard::PutNumber(“DB/Slider 0”, 2.58);

 

To read values from the Dashboard into the robot program:

Java (default value of 0.0): double dashData = SmartDashboard.getNumber(“DB/Slider 0”, 0.0);

C++ (default value of 0.0): double dashData = SmartDashboard::GetNumber(“DB/Slider 0”, 0.0);

Comments are closed.