Using Shuffleboard Widgets

Our team wants to use the shuffleboard to select auto modes, ideally with the ComboBoxChooser. Currently, I am getting the error message:

Error at Unhandled exception instantiating robot org.usfirst.frc.team20.robot.Robot java.lang.ClassNotFoundException:
	at java.lang.ClassLoader.loadClass(
	at sun.misc.Launcher$AppClassLoader.loadClass(
	at java.lang.ClassLoader.loadClass(
	at org.usfirst.frc.team20.robot.Robot.<init>(
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
	at java.lang.reflect.Constructor.newInstance(
	at java.lang.Class.newInstance(
	at edu.wpi.first.wpilibj.RobotBase.main(

How am I supposed to use the shuffleboard widgets/how can I fix this error?

Could you post your code where you add the SendableChooser?

At school right now, but the gist is

String] tempStr = {"auto1", "auto2", "auto3"};
SendableChooserData chooser;
ComboBoxChooserWidget comboBox;

Robot Init {
    chooser = new SendableChooserData(tempStr, "auto1", "auto1");
    comboBox = new ComboBoxChooserWidget();

Shuffleboard widgets run in the Shuffleboard program (on the DriverStation PC). In your robot code you just use SendableChooser. Then you pick the desired widget on the dashboard.

So it should look something like this?

SendableChooser<int> chooser;
    chooser = new SendableChooser();
    chooser.addDefault("Auto1", 1);
    chooser.addObject("Auto2", 2); //etc
    SmartDashboard.putData("Auto Chooser", chooser);

Pretty much. But you should use better names than “Auto1”, “Auto2”, etc. Otherwise the driver has to keep track of what number does which routine.

Yea, that was just a placeholder name for testing

I just tested the code, shuffleboard had no “show as” option for it. Is there something else I have to do?

Your SendableChooser code should look like this:

SendableChooser<Integer> autoChooser = new SendableChooser<>();

public void robotInit() {
  autoChooser.addDefault("Auto1", 1);
  autoChooser.addObject("Auto2", 2);
  // etc.
  SmartDashboard.putData("Autonomous routine", autoChooser);

public void autonomousInit() {
  int autoMode = autoChooser.getSelected();
  // Run the appropriate command

(I’d like to point out that you can also send the commands themselves, without needing to send an int and then map that to a command to run)

On Shuffleboard, it should look something like this:

The only differences I had in my code was 1: I did the chooser = SendableChooser() in robotInit, and 2: I didn’t put a string name in for the putData(). Would either of these prevented it from working?

Lack of the string name would prevent it.

Andrew, feel free to check out some of our code where we’re doing this. If you want more help offline, feel free to reach out via DM; Carl also knows how to get in touch with me if you’d prefer a video chat or phone call.