![]() |
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 Now comes the trouble I'm trying to resolve. Our AutonomousChooser selects a command group that looks like Code:
addSequential(new drive());Code:
protected void initialize() {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? |
Re: Run a command with conditions
Code:
new ShootBall()Code:
Command* c = new ShootBall()Code:
m_defenseChooser = new SendableChooser();Code:
void AutonomousInit()Code:
class GeneratedAutoCommandGroup: public CommandGroup |
Re: Run a command with conditions
If you don't want to modify shoot, then copy it to create auto_shoot, and modify that to remove checking the button. What is your reluctance? It may not be elegant, but you have more than enough code space for it.
|
Re: Run a command with conditions
Quote:
Thanks for the direction. |
Re: Run a command with conditions
Quote:
Code:
void AutonomousInit()Code:
autonomousCommand->Start() |
Re: Run a command with conditions
In an effort to continue down this rabbit hole here is where I sit.
I have continued with one of the original ideas before I attempt to try the build the autonomousCommand just before running it. To better discusse the code here is a link to the Github repo https://github.com/GraniteCiyGearhea...ntsABot_Talahi If we drill to Code:
FIRSTStronghold2016/Copy of SirAntsABot_Talahi/src/org/usfirst/frc3244/SirAntsABot/commands/Auto_22_Demo_03_Drive_N_ScoreCode:
addSequential(new Auto_Score_Ball_In_Goal());Now the trouble I'm having is getting the next sequence to continue when Code:
Auto_Score_Ball_In_Goal()Maybe someone can point me to or explain to me the life cycle of a command and what is needed to move onto the next sequence in a command group. |
Re: Run a command with conditions
Calling end() doesn't cause a command to end. Making isFinished() return true does.
I think the problem is that the commands you are starting are canceling Auto_22_Demo_03_Drive_N_Score because they require the same subsystems. |
| All times are GMT -5. The time now is 10:18. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi