3 ms·
Maybe I'm missing something but why doesn't the Java section right before the Lua section not work? It looks like normal procedural code that can just keep runn
by erdaniels 3y ago
Maybe I'm missing something but why doesn't the Java section right before the Lua section not work? It looks like normal procedural code that can just keep running. The lua version is just one coroutine and it's not yielding to anything else. Is it just a matter of some kind of timing constraint/controller from FRC in the background that need to keep calling myAuto?
- dwohnitmok 3y agoThe robots operate on N ticks per second. You only get one set of robot inputs per tick and can only make one command. The Java code is tickless. During a single tick none of the while conditions will change. Therefore the while loop will run forever and never allow the tick to finish. The Lua code yields at the end of any loop iteration allowing the tick to complete. Then whatever is orchestrating the robot on the next tick calls resume on the coroutine allowing the another iteration to continue, this time with new inputs.
- bvisness 3y agoautonomousPeriodic is a tick function; we need to keep ticking. If we spent more than our allotted 20ms in a single autonomousPeriodic then the robot framework’s safety systems kick in and disable all the motors.
- erdaniels 3y agoAh okay that makes sense, thanks! It may help to make that note near the final java example.