![]() |
Command based code secan
This is my first year helping a team with some robot code. We are focusing on the command base robot model. We would like to do some acceleration control and other timed loops. I'm familiar with Vex and have done similar control using while loop and using a wait instruction at the end to use as the time calculation. With the FRC system do i or can i use a loop and wait code or use the FRC periodic cycle? I may not be using the right term to describe what I'm looking for but I hope you understand and can direct me.
Thanks |
Re: Command based code secan
Quote:
|
Re: Command based code secan
Quote:
This is not what I'm aiming for but simply put every 1 sec i want to add 10 to double myCounter Code:
|
Re: Command based code secan
Quote:
|
Re: Command based code secan
pseudo code
Code:
public class myCounterCommand extends CommandBase {Code:
here what happens the 49 times this execute is called when the wait is not done? or do I Code:
|
Re: Command based code secan
Quote:
Instead use a Date field to store the time and increment your count when the time has exceeded a second. |
Re: Command based code secan
This one is closer:
Quote:
|
Re: Command based code secan
< -- > Yep was quick pseudo code. I didn't put to much though into it. Are there timing charts that show how the different methods in a command react?
So the same is true with wait() and a while(true) loop that may never end that other commands would never be scheduled or executed? |
Re: Command based code secan
Quote:
|
Re: Command based code secan
Quote:
On the second question, the execute() command will be called repeatedly, so you should structure it to do its work in less time (preferably much less time) than the call periodicity. In particular, you should avoid system calls with indeterminate duration, such as object instantiation, and other activities which may trigger garbage collection. IIRC, we usually turn GC off, because as long as the code doesn't constantly declare and release variables, you won't burn through the heap in three minutes. If you could burn through it that quickly, you would almost certainly see it during practice sessions which run many times as long. |
Re: Command based code secan
1 Attachment(s)
All this input is great. When it comes right down to it, attempt to assure the methods completes before the next iteration of the command < 20ms. I maybe beating this to death but it must be predicable what would happen if the method was not complete on the next iteration like item 1 it initialize() was not complete would the execute() simply start in the first positive clock after it completed. Same with item 2 if the execute() was not complete would the isFinshed() still run and a new execute() start only after the previous finished on a positive clock cycle.
These timing charts are what I expect may happen. The last timing chart has not been discussed here but if the command is scheduled to run but has not finished. Would the end() method run and a new initialize() start? In the PLC world I work with professionally if I have a periodic task that does not complete before the next period I get a minor error and that iteration is skipped nothing horrific happens only I loose a scan. |
Re: Command based code secan
Your picture for #1 is correct, for that command only. #2 is not correct, because isFinished will not run while execute is still running. In addition, it will also delay the execution of every other command. You could think of it as there only being a single clock, and any command method can stretch the clock.
|
Re: Command based code secan
1 Attachment(s)
Quote:
|
| All times are GMT -5. The time now is 09:16. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi