Now that we have had a glimpse at how state machines work, let's try creating a state machine for our waiter robot analogy. To be more practical, the robot has to carry out the following tasks:
- Power on the robot
- Check for a customer call
- Navigate to the table based on call
- Take the order from the customer
- Go to the delivery area or kitchen if the order has been confirmed or has failed
- Deliver food to the customer
Now, we can go about defining our analogy:
- STATES_MACHINE: The robot needs to be powered ON and initialized, so we need to have a POWER_ON state. Once the robot is powered ON, we need to check whether any customer has placed any orders. We do this via BUTTON_STATE. Once the robot has received a call from ...