Shuffleboard - frc-7603/VespaRobotics2024-25 GitHub Wiki
About
Shuffleboard is essentially a dashboard for FRC Robots which can be customized through code. It allows you to see all the properties of a robot, which is very useful for debugging (basically similar to System.out.println()). It supports all platforms that WPILib runs on. It consists of just a grid which widgets containing data which can be output, and it even supports button events to run code.
This wiki page is a WIP! (but it is not experimental, rather mainly untested)
Running
To run Shuffleboard, go into the FRC VS Code and open the command pallet by clicking on the WPILib icon or pressing Ctrl+Shift+P (or Cmd+Shift+P for Darwin/macOS systems). Search for "Start Tool", click on it, and then click Shuffleboard.
Alternatively, you can go into the wpilib/2024/tools folder and run Shuffleboard.py (on Unix systems like Linux or macOS) or Shuffleboard.vbs (for Windows NT Systems).
General usage (not programming, rather things such as settings, display mode of widgets, etc.)
See the documentation: https://docs.wpilib.org/en/stable/docs/software/dashboards/shuffleboard/getting-started/index.html
Programming
Defining
Import the Shuffleboard, ShuffleboardTab, ShuffleboardLayout, and the SmartDashboard classes:
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardLayout;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
Adding a widget (to SmartDashboard tab)
To add a widget to the SmartDashboard tab, use the SmartDashboard.putNumber("title", number) / SmartDashboard.putBoolean("title", boolean) / SmartDashboard.putString("title", string) methods (depending on which type of data you want to put):
// Add a number
SmartDashboard.putNumber("This is a number", mynumber);
// Add a boolean
SmartDashboard.putBoolean("This is a boolean", myboolean);
// Add a string
SmartDashboard.putString("This is a string, mystring);
This is very useful for something like displaying the current speed, or axis of a joystick.
Adding a method (With a button)
You can also run certain tasks using Shuffleboard via a button.
You must first create a class, which looks like this (taken from Brave Search AI, but slightly modified):
class MyMethod implements Command {
// Define variables needed (they are the arguments)
private String arg1;
private int arg2;
// Constructor which takes proper arguments
public MyMethod(String arg1, int arg2) {
this.arg1 = arg1;
this.arg2 = arg2;
}
@Override
public void initialize() {
// Initialize the method
// Other code could be run here (think only once after the object has been instantiated), and use the arguments as the variables.
}
@Override
public void execute() {
// Execute the method with the arguments
// This code would use the arguments
}
@Override
public void end() {
// End the method
// Other code could be run here (perhaps when the execute() method has finished execution)
}
@Override
public boolean isFinished() {
// Return true, other code could also run here (this is perhaps if the execute() method finished successfully).
return true;
}
}
You can put this in the same file as Robot.java (just make sure to NOT make the class public).
After doing so, you can then use the SmartDashboard.putData() method with the title and the instantation of the class as the second argument.
SmartDashboard.putData("Run Method", new MyMethod(arg1, arg2));
This could also be useful for debugging.
Custom tabs
To use custom tabs, you must use the Shuffleboard.getTab() method to create one:
Tab myTab = Shuffleboard.getTab("tabname");
The argument is the tab name. If the tab does not already exist, it is created.
Selecting a tab programmably
You can use the .selectTab() method, which is an overloaded method which accepts either the title as a string, or the index number (meaning it goes from 0 to (number of tabs - 1).
Shuffleboard.selectTab(int or string);
It is unsure whether or not this will also include the SmartDashboard tab as this is completely untested.
Adding data to a tab
To add data to a tab, use the .add() method on the tab. It has the exact same format as the SmartDashboard put methods. You can put anything on there, potentially even the button "command classes".
myTab.add(title, data);
Layouts
To add a layout, use the .getLayout() method on the tab. It returns a layout.
ShuffleboardLayout myLayout = myTab.getLayout("tabtitle", type);
The type of layout includes list (like a list) or grid (like a grid).
You can also get a layout using just a title (but it cannot create one)
ShuffleboardLayout myLayout = myTab.getLayout("tabtitle");
For more info
General documentation
https://docs.wpilib.org/en/stable/docs/software/dashboards/shuffleboard/index.html