Quote:
Originally Posted by nathanww
A "periodic" function is one that is run only at a certain interal--if you look in the c++ reference, you'll see there's actually a function to set how often it runs.
A "continuous" function is called as fast as the robot is able to--there's no way to explicity specify when it should be called.
As for how they interact---the system considers them two functions of the same class. This means they can both use global variables in your file, call each other, etc.
|
So--if I have code in autonomous and periodic, what happens? Does continuous loop as fast as it can, but is interrupted by periodic every time the time interval specified has past?
And so, should I put my sensor refresh code in the periodic loop, depending on how fast it refreshes, and the rest of my code in continuous? Or could I set the periodic time interval to 0, and then just stick the sensor refreshes in the
if ((m_telePeriodicLoops % n) == 0)statements that run enclosed code only on every nth iteration?
Finally, in all cases does the code wait for data to return (ie, for the ultrasonic ping to come back) before moving on? Because in that case, whether I ran it every nth loop or every loop, technically it would still hold up my robot's reaction rate? (Say then that my robot just sets drive speed and turn depending on data, and the calculations are simple, it would act the same in the following situations: 1) if it were stuck waiting on sensor data to return and the motors were still running on info from the old command, and 2) if it were looping through the code and making new drive commands based on old data. Right? I may have very probably confused myself by now.)