We are trying to use a sendable chooser to select our autonomous for the first time this year. When we try to run the selected autonomous, we get a null pointer exception. I read through the documentation and it says that the value is only null when there is no default and when there is nothing selected. I made sure this is not the case.
Here is the relevant code:
SendableChooser <AutonomousRoutine> chooser = new SendableChooser<>();
@Override
public void robotInit(){
chooser.addDefault("Basic Gear", easyGear);
chooser.addObject("RightGear", rightGear);
chooser.addObject("Left Gear", leftGear);
SmartDashboard.putData("Autonomous Chooser", chooser);
}
@Override
public void autonomousInit(){
chooser.getSelected();//No null pointer
chooser.addDefault("Easy gear", easyGear);//Confirm the default
//I tried it without this, and it didn't work.
chooser.getSelected().begin();//null pointer
}
AutonomousRoutine is a class we have made for autonomous, and it works without the sendable chooser. We do not use command based, but the AutonomousRoutine works in a similar way.
Any and all help is appreciated.