Interactive Widgets on SmartDashboard

one of the things we want to do is to put a graphical slider or checkbox on the SmartDashboard and have the operator interact with it on the driver station. This is something that was pretty easy with LabView, and we used it a lot during testing.

I’ve seen the SendableChooser, we’re looking for something similar that can handle numbers…

This doesn’t seem to be a capability built into the SmartDashboard. Is this something that anyone has done?

If you use SmartDashboard.putNumber in your robot code, a number widget will pop up on SmartDashboard. You can change the widget type to view the data differently (http://wpilib.screenstepslive.com/s/3120/m/7932/l/81108-changing-the-display-widget-type-for-a-value). You can then change that value on the SmartDashboard and read the changed value on the robot with getNumber. You can do something similar with put/getBoolean.

This is entirely possible. The key is that its not part of the smart dashboard, its part of the live window, which you will typically run while your robot is in test mode. Just use the various methods of the LiveWindow class in the same way you would use the smart dashboard.

the “interactive” part is the part I’m not seeing. I want a slider that I can manipulate on the Dashboard and have the change reflected in NetworkTables so I can read the slider value in the robot. I know we can do it by typing in valkues: we’re looking for GUI widgets that we can manipulate…

will look at LiveWindow classes over weekend, perhaps what I am looking for is in there?

Ok, now I am confused about what you are trying to do. Could you please give us a specific example.

LiveWindow only works during testing, you can’t use it during an actual match. And what it is able to do is either give you a slider to change to speed of a motor (-1 to 1) and also work with PID (adjust the P I and D values and tell the motor to go to a setpoint).

I want the same capability we have with LabView. We can add GUI widgets to the LV Dashboard, and the value of the widgets are tied to what’s in the SmartDashboard network tables. If the GUI widget is a LV “indicator”, then it just reflects what’s in the network table, if it’s a LV “control”, then changing what’s on the dashboard will change the corresponding table entry.

The Java SmartDashboard has some of this, but doesn’t seem to have GUi elements; I can’t tie a slider to a number in the NetworkTable, for instance; my only display option is a text box.

We can work around it; Test mode gets us part of the way there, using the “fake” analog and digital inputs on the DS helps more (or building a real console with the Cypress), but I wanted to be sure that I wasn’t missing a capability that was already there.

Writing a Swing application to present a UI and poke/read the network tables is straightforward, but doing and persisting the GUI layout would be a challenge for where I am right now, Swing-wise (I’m a J2EE guy)…

If you call SmartDashboard.putX() on the robot, where X is any of the supported data types, there actually isn’t any magic happening here; it just puts it into a NetworkTable named “SmartDashboard”. On the dashboard, it listens for changes to this table and adds widgets accordingly. The default widgets for basic data types allow you to modify these values; just click in the text box and type a new value. These will be placed back into the NetworkTable, and can be retrieved with SmartDashboard.getX() (you can also use a ITableListener to detect updates). I don’t believe there is a slider option for normal SmartDashboard use, but if you grab the source code it should be possible to take the LiveWindow slider, convert it to a normal widget, and compile it as an extension.

yeah. I finally stumbled on the “writing extensions” part of the wiki, and the scales were lifted from my eyes. A mention of that tutorial in the SmartDashboard ScreenSteps or the video tutorials would be appropriate, hopefully one of the really clever WPI people will see this :slight_smile:

Need to look at the code for the Textbox widget to see how changes get reflected back (looks like they rely on the Swing ChangeEvent). If I can adapt a JSlider or JSpinner as a POC (making the editable property work, which looks straightforward), then we’re home free; once you’ve done it once, the variations are relatively easy. It just looks like a few hours work, need to find the hours.

As a professional Java developer, I gotta say the SmartDashboard is a slick piece of work. I tore into Team 341’s 2012 DaisyCV, and a lot of things are getting very clear.