![]() |
Re: Command Based Programming (Threads?)
Thanks for the response. I hope you don't mind some follow-up questions: Quote:
Quote:
|
Re: Command Based Programming (Threads?)
Quote:
Code:
public class WaitCommand extends Command {As to the second question. Something like this would work for a single command doing multiple things based on time. Code:
public void execute() { |
Re: Command Based Programming (Threads?)
Quote:
- the first time it is executed it notes the system time so that it can compute the value of "timeSinceInitialized" each time it is executed. |
Re: Command Based Programming (Threads?)
Quote:
|
Re: Command Based Programming (Threads?)
Quote:
- "something" will be executed every 20ms as long as "timeSinceInitialized()" is less than "sometime" |
Re: Command Based Programming (Threads?)
Quote:
|
Re: Command Based Programming (Threads?)
So this codeA: Code:
public FiringCommandGroup extends CommandGroup {Code:
public void execute() {whereas codeB executes "something" repeatedly, then waits, then executes "something2" repeatedly. Yes? |
Re: Command Based Programming (Threads?)
Quote:
|
Re: Command Based Programming (Threads?)
Quote:
|
Re: Command Based Programming (Threads?)
Quote:
Code:
public class ShootCommand extends Command {2. Do nothing for 1 second. 3. After 1 second return true in isFinished(). 4. When isFinished() returns true the end() method is called. 5. Run logic for fire2 in end. Keep in mind, the logic for both fire1 and fire2 will need to execute quickly. Meaning no Timer.delays or long running loops. |
Re: Command Based Programming (Threads?)
Quote:
|
Re: Command Based Programming (Threads?)
Quote:
However, the former approach (#15) is the preferred option for modularity sake. Integrating the wait with both executions turn the command, not into a modular command, but rather a defined sequence. If the sequence is regular (e.g. load hopper, wait, shoot) than it would be preferential to use a CommandGroup, for readability sake. If the sequence is irregular (e.g. turn 15 degrees, wait, shoot at low velocity) than the command will only be used once and more commands of similar conditions (e.g. turn 30 degrees, wait, shoot at high velocity) would have to be developed. In this case, it would be easier to make a turn command, a wait command, and a shoot command and plug them in in a similar fashion to post #15. |
Re: Command Based Programming (Threads?)
Quote:
My team and I prefer the method I provided in post #15. It's easier to read, easier to modify, and more modular. Here is an example from our competition code from last season. Notice how easy it is to read exactly what the ShootSeries command does. Code:
public class ShootSeries extends CommandGroup {Code:
public class PickUpDeploy extends CommandBase {Code:
public class SetShooterPosition extends CommandBase {Code:
public class ResetArmCommand extends CommandBase {Code:
public class PickUp extends Subsystem {Code:
public class Shooter extends Subsystem {Also, here is our code from this season so far. |
| All times are GMT -5. The time now is 11:10. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi