View Single Post
  #15   Spotlight this post!  
Unread 07-03-2010, 21:31
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,065
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Programming Autonomous pneumatic kicker

Quote:
Originally Posted by archwaykitten View Post
I am trying to make a very similar state machine kicker myself.

My problem is this: Say you tell your program to "wait" in a particular state for two seconds while a piston extends... I would expect the rest of your program to "freeze" for two seconds while that state machine code waits to execute. We want to be able to continue driving around and entering comands while our ball kicker state machine does its thing.
The "wait" in a state machine is NOT code that causes the processor to loop there until a desired amount of time has passed. Rather, it is code that tests whether the desired amount of time has passed, and if not, allows execution to continue. On the next iteration, it tests again. It keeps testing every new iteration until the desired time has elapsed, at which point it performs some action and changes state so it is no longer waiting.

You can put such a state machine in teleop along with other state machines and they will all peacefully coexist - i.e. they will all appear to execute "simultaneously", since none of them contain any code that "freezes" the processor waiting for time to elapse.

~
Reply With Quote