I have 2 sendableChoosers for our Autonomous. One picks the obstacle we are going to attempt. (works well) The other picks the wrist angle of our shooter for High goal or low goal. We came up with the idea after milling over the code shared in the thread
More than 1 Sendablechooser where we can run a line of code in a command like
Code:
/* The goalChooser construction
*goalChooser.addDefault("0: No Shoot",0);
*goalChooser.addOption("1: Low goal",1);
*goalChooser.addOption("2: High Goal",2);
*/
protected void initialize() {
Integer goalChoice = (Integer) Robot.goalChooser.getSelected();
angle = findAngle(goalChoice);
Robot.wristSubsystem.setAngle(angle);
}
private double findAngle(integer Choice){
if(Choice == 1){
return 15;
}else if(Choice == 2{
return 75;
}else{
return 90;
}
}
The syntax may be off here but the real code worked every time. If goalChooser was 1 wrist set to 15deg, 2 then 75deg.
Now comes the trouble I'm trying to resolve. Our AutonomousChooser selects a command group that looks like
Code:
addSequential(new drive());
addSequential(new setWristAngle()); //Above code
//************* Code Focus ************
addSequential(new Auto_ShootDecide()); //New shoot or Not
//addSequential(new shootBall()); //Old always shoots ball
//***********************************
In Auto_ShootDecide I have
Code:
protected void initialize() {
Integer goalChoice = (Integer) Robot.goalChooser.getSelected();
if (goalChoice == 0){//don't shoot
end();
}else{
new shootBall(); This is where the code does not run
}
}
new shootBall(); This is where the code does not run.
We use shootBall() tied to a button and the code is proven and I don't think I what to add conditions to it to check the goalChoice like "Auto_ShootDecide()".
Maybe Auto_ShootDecide() needs to be a mirror of shootBall but with the conditions. I just thought why recreate a chunk of code. What do you think?