![]() |
Best Way(s) to Implement a Delay in Command Groups
Today, my former team asked me what the best way to implement a delay in a command group is. They are well aware of the built in delays in the adding of the commands.
Code:
addSequential(new DriveForward(), DELAY_TIME);Code:
Timer.delay(DELAY_TIME); |
Re: Best Way(s) to Implement a Delay in Command Groups
AddSequential(new WaitCommand(1)); //Wait 1 second.
|
Re: Best Way(s) to Implement a Delay in Command Groups
I discovered that it is best to not use Timer.delay() because that will pause your entire robot (Every other command and every other subsystem). My solution was to create a Wait command that accepts a timeout as an argument. It then sets its timeout (this.setTimeout(arg)) to the argument. Then isFinished() returns this.isTimedout(). This will effectively put a delay in the command group because they command won't finish until the timeout has elapsed.
|
Re: Best Way(s) to Implement a Delay in Command Groups
1 Attachment(s)
Our team uses the same approach mentioned by Joey1939. I've attached the .java file for the command we use. (You might want to just copy/paste the important bits - there's a lot of unnecessary RobotBuilder crap in here that we never cleaned out.)
We call it in command groups like so: Code:
addSequential(new Delay(1.25)); |
Re: Best Way(s) to Implement a Delay in Command Groups
We use:
Code:
addSequential(new WaitCommand(WAIT_TIME));Also, it is possible to have a command that does not require a subsystem, as we have done this before, but probably is not recommended. |
Re: Best Way(s) to Implement a Delay in Command Groups
Quote:
|
Re: Best Way(s) to Implement a Delay in Command Groups
Quote:
|
Re: Best Way(s) to Implement a Delay in Command Groups
Our team uses States to determine what to do. Drive has a State Machine that is independent of the Shooter. Delays are implemented using timers. Set a timer, and check the time each loop.
Note: Having everything doing "nothing" requires a little thought. Do you disable the compressor so it does not run too? If you are moving, do you stop moving (and if so, how? Drop power abruptly, or gradually)? etc. |
| All times are GMT -5. The time now is 03:52. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi