Go to Post Nutritionally speaking I didn't get enough (MOE) green in my FIRST diet this year! - Mark McLeod [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 30-03-2016, 22:19
cpapplefamily cpapplefamily is offline
Registered User
FRC #3244 (Granite City Gearheads)
Team Role: Mentor
 
Join Date: May 2015
Rookie Year: 2015
Location: Minnesota
Posts: 242
cpapplefamily has a spectacular aura aboutcpapplefamily has a spectacular aura about
Run a command with conditions

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?
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 10:18.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi