This behavior FSM (Finite State Machine) is a type of a state machine that returns no outputs, it merely changes state based on input and the current state. Each activity that the FSM engages is a state, unique in operation and distinct from all other states by its definition. If this is difficult to understand, let’s use a sort of real world application to explain FSMs, the soda machine. In order to keep our soda machine simple, we will create a machine with these abilities:
- takes only quarters
- needs two quarters to get a soda
- will not give you your money back
- does not give change, nor return money that isn’t a quarter
- has Coke, Barq’s Root Beer and Fanta Orange soda
- has an infinite amount of soda and never runs out
As you can see, we have eliminated all of the error conditions or exceptions that a normal soda machine could see in order to simplify this explanation, it’s artificial for a reason; we’re not designing soda machines. The label is the result of the transition function and defines the condition required for that change of state. An unlabeled line is a transition that will always occur as soon as the function of that state is completed.
The lines that loop back upon a state show iteration, or that the FSM remain s in this state doing something until a terminal condition is reached, at which time a defined transition, that is labeled will occur. Here we see that our soda machine FSM will remain in state 0 until two quarters have been given, at which point our FSM will transition to state 1. Here we will look, wait at buttons until a selection is made. When a selection is made, our FSM will then transition to state 2, 3 or 4 depending on the selection made. From these terminal states, our FSM will immediately transition back to state 0 after completing. This is the general process of definition and representation for the FSMs that we will be using to define our BoE-Bot behaviors.
No comments:
Post a Comment