This is my first year programming and at this point the only way I know how to end a command is to use a while statement and a timer with a boolean as shown:
The issue here is that when I run this command, It doesn’t allow me to run anything else in those 2 seconds. Is there any other way for me to end the command without doing this? this is in the AutoIntakeStart.java file
this is the Github if you want to look at the code:
that line was mostly there for me to test out that command. It is supposed to just intake, index, and put down the intake during auto and then put it back up after 2 seconds or so. Is that how you do that there? Before, every time I tried the function in a parallel command group(auto) or just try to drive around(teleop) it just stops everything else until that command finishes.
Do you have an example of where you tried it? You mention a parallel command group, what things were you running in parallel? Generally an Auto starts out at the top level as a sequential command group.
if you check the github, I pushed the auto that I tried before. It would stall after shooting. Im trying to run a swervecontrollercommand and intake at the same time
The reason why this is stalling everything is because this blocks the thread. No other code is getting ran while this while loop is active. You could change the command so the isFinished() returns return time.get() > 2. However, there are better ways of doing it, such as using :
If you really wanted to do it like that (I wouldn’t) you could put a time.get in the execute part that when true it changes the is finished but while loops are generally a bad idea in FRC programming…the vast majority of the time.