I cannot select my autonomous code in the driverstation/smart control panel. The drop down menu appear, but it does not open to show me all of my different autonomous codes.
I have it programmed in Java, and I followed the WPILIB Iteritive robot example for the autonomous.
/*
Initialization code that allows code to be selected in the driver station.
*/
private static final String CENTER_LEFT = "Robot Center Switch Left";
private static final String LEFT_LEFT = "Robot Left Switch Left";
private static final String RIGHT_LEFT = "Robot Right Switch Left";
private static final String CENTER_RIGHT = "Robot Center Switch Right";
private static final String LEFT_RIGHT = "Robot Left Switch Right";
private static final String RIGHT_RIGHT = "Robot Right Switch Right";
private String autoSelected;
private SendableChooser<String> chooser = new SendableChooser<>();
/*
Declares variables for motors and defines each side of the drivetrain.
*/
private Joystick controller = new Joystick(0); // Declares controller.
private Spark leftFront = new Spark(0); // Declares left front drive motor.
private Spark leftRear = new Spark(1); // Declares left rear drive motor.
private Spark rightFront = new Spark(2); // Declares right front drive motor.
private Spark rightRear = new Spark(3); // Declares right rear drive motor.
private SpeedControllerGroup driveLeft = new SpeedControllerGroup(leftFront, leftRear); // Declares left side of robot
private SpeedControllerGroup driveRight = new SpeedControllerGroup(rightFront, rightRear); // Declares right side of robot
private DifferentialDrive driveTrain = new DifferentialDrive(driveRight, driveLeft);
private Timer timer = new Timer();
/*
Declares variables for the other functions.
*/
private Talon lift = new Talon(4); // Declares motor that lifts cube mechanism.
private Talon grab = new Talon(5); // Declares motor that grabs the cube.
private Talon climbA = new Talon(6); // Declares motor that climbs.
private Talon climbB = new Talon(7); // Declares motor that climbs.
private SpeedControllerGroup climbGroup = new SpeedControllerGroup(climbA, climbB);
/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
@Override
public void robotInit()
{
chooser.addObject("Robot Center Switch Left", CENTER_LEFT);
chooser.addDefault("Robot Left Switch Left", LEFT_LEFT);
chooser.addObject("Robot Right Switch Left", RIGHT_LEFT);
chooser.addObject("Robot Center Switch Right", CENTER_RIGHT);
chooser.addObject("Robot Left Switch Right", LEFT_RIGHT);
chooser.addObject("Robot Right Switch Right", RIGHT_RIGHT);
SmartDashboard.putData("Auto choices", chooser);
}
/**
* This autonomous (along with the chooser code above) shows how to select
* between different autonomous modes using the dashboard. The sendable
* chooser code works with the Java SmartDashboard. If you prefer the
* LabVIEW Dashboard, remove all of the chooser code and uncomment the
* getString line to get the auto name from the text box below the Gyro
*
* <p>You can add additional auto modes by adding additional comparisons to
* the switch structure below with additional strings. If using the
* SendableChooser make sure to add them to the chooser code above as well.
*/
@Override
public void autonomousInit()
{
autoSelected = chooser.getSelected();
// autoSelected = SmartDashboard.getString("Auto Selector",
// defaultAuto);
System.out.println("Auto selected: " + autoSelected);
}
/**
* This function is called periodically during autonomous.
*/
@Override
public void autonomousPeriodic()
{
switch (autoSelected)
{
case LEFT_LEFT: // Drives 168" forward and 55.56" right
driveTrain.arcadeDrive(1,0);
timer.delay(5);
driveTrain.arcadeDrive(0.5, 1);
timer.delay(2);
break;
case CENTER_LEFT:
driveTrain.arcadeDrive(1, -.5);
break;
case RIGHT_LEFT:
// Put auto code here
break;
case LEFT_RIGHT:
// Put auto code here
break;
case CENTER_RIGHT:
// Put auto code here
break;
case RIGHT_RIGHT:
// Put auto code here
break;
}
}
/**
* This function is called periodically during operator control.
*/
@Override
I didn’t noticed really see any error in your code, you should be able to select your option in the dashboard. which one are you using the SmartDashboard or the ShuffleBoard ?
A problem that affected our team, and others, is that selection labels more than 16 characters in length are not handled properly. I note yours look a lot like our initial, too long, labels.