Quote:
Originally Posted by Tom Line
I've never understood the difficulty understanding state machines. Perhaps it is conceptualizing the fact that the loop runs constantly but only increments your state machine when a condition is met?
I've always understood that you COULD run parallel threads, but I have a question regarding that.
We put a timer in front of our teleop code that passes it's time value into each loop. We use that to run any time-sensitive loops. I have yet to find anything in FRC that requires anything faster than the (approximately) 50ms loop. Can you tell me what type of things you might want to run faster than that?
|
I can tell you something that wants to run
slower than that. A kicker for example. Say the kicker needs to wait 1000ms to re-arm before it will accept another kick command. You could code the kicker as a state machine and run it in teleop, or you could run the kicker in a separate thread and just block waiting for 1000ms. But what you
can't do is block waiting for 1000ms in teleop. It will screw up the rest of the teleop code.
~