![]() |
Wait/Pause function?
While working out some of the kinks in our code, i stumbled upon a problem. That problem being that I could not have the robot wait for a certain period of time before continuing with its code. So now my question is this: Is there any function that can be used to pause the robot for a certain amount of time?
Thanks. |
Re: Wait/Pause function?
Quote:
|
Re: Wait/Pause function?
I tried to do it with a simple for loop:
for (int x= 0; x< 500; x++) this was made in autonomous periodic, which I believed would count up one every 20 miliseconds, which should equal around 5 seconds. But this did not work and did not delay the robot at all. |
Re: Wait/Pause function?
You can try Wait(double) in Timer.h
And that's just a simple two instruction loop. It won't occupy the processor for long (though it will waste computing power when compared to a yield AFAIK), it won't be reliable (timing could change very easily based on process scheduling), and it may be optimized out by the compiler. |
Re: Wait/Pause function?
Quote:
|
Re: Wait/Pause function?
Something like this maybe useful for pausing. This example is directed towards auton, but can be applied in any instance of pausing
Code:
m_autoPeriodicLoops++;By using this method you can have other things in the background running in your loops but you are not "stopping" the cRio completely by using a Wait function. |
Re: Wait/Pause function?
We use a timer to implement delays. Here is our bread and butter 2-ball front of key autonomous code - this is called from AutonomousPeriodic:
Code:
void XM15::AutoThree1(void) |
Re: Wait/Pause function?
I use a state system and a Timer object inside of an 'iterable' function. The function returns false until the operation is complete. This works well if you use the 'Iterable' robot template that comes with WindRiver.
The state variable 'state_' must be set to kPhase1 before the function is called the first time (make sure you don't keep setting the state to kPhase1 each time through the control loop). The timer will have a resolution equal to the duration of the calling control loop. Code:
bool TechnoJays::SomeFunction() { |
Re: Wait/Pause function?
Quote:
|
| All times are GMT -5. The time now is 13:24. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi