Our team wants to use the shuffleboard to select auto modes, ideally with the ComboBoxChooser. Currently, I am getting the error message:
Error at java.net.URLClassLoader.findClass(URLClassLoader.java:381): Unhandled exception instantiating robot org.usfirst.frc.team20.robot.Robot java.lang.ClassNotFoundException: javafx.beans.property.StringProperty
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.usfirst.frc.team20.robot.Robot.<init>(Robot.java:72)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at edu.wpi.first.wpilibj.RobotBase.main(RobotBase.java:216)
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();
combobox.setData(chooser)
}
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;
RobotInit{
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<>();
@Override
public void robotInit() {
autoChooser.addDefault("Auto1", 1);
autoChooser.addObject("Auto2", 2);
// etc.
SmartDashboard.putData("Autonomous routine", autoChooser);
}
@Override
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: https://imgur.com/a/tqmtO
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.