State MachineThe State Machine (or Finite State Machine) module provides an easy way to define a set of states and transitions between those states that is often needed in robotic applications. The module defines a state as a set of variables that contain specific values. As RoboRealm communicates between modules using variables a state can define a specific action (like moving a robot forward). Transitions between those states are defined as conditional statements that check for specific values of other variables (such as the distance to an object from an IR sensor) in order to change the current state of the module. In this way you can define an action and its transition requirements in one interface.
For example, should you want a robot to move forward for 5 seconds, turn for 1 and then stop but also stop if at any time the IR sensor picks up an object close to the robot you can define multiple transitions. The primary transition would be that of time (i.e. transition to the next state after 5 seconds) and another transition would check the value of the IR sensor and skip over to the final step where the robot would stop.
By defining states and transitions you can create rudimentary behaviors for your robots based on its sensors and actuators.
1. Name - A name that best represents the state. This is used for your purposes to help you identify the meaning of each state. For example, state names like "Driving Forward", or "Turning", etc. are useful.
2. State Variables - Define that variables should be set to what values when within this state. These variables would then be used in other modules to define speed or direction of movement or states of other actuators. Note that defining variables within this module will NOT cause any actions to occur unless those same variables are used in other modules that do communicate with specific hardware. Due to this, a state machine can be defined for one robot and then used on another by changing the hardware communication module (i.e. IRobot_Roomba to Sparkfun_Arduino).
3. Set Once - The module will set the state variables on each iteration of the pipeline. If the variable should be allowed to change (as in the case of speech generation) to avoid multiple reads select the "Set Once" checkbox. This will cause the checkbox to be set only once when the state is entered and not each time the processing pipeline iterates.
4. Is Array - Specifies that the value for the variable is an array. Each item is separated by a comma. On assignment this list is read, split into individual elements and assigned as an array.
5. Conditional Transitions - Define how the current state is transitioned into another. Typically this will be in reaction to a sensor value (again stored as a variable from a hardware module) or from a user input selection (as from the Button module).
6. Timed Transition - This defines a timed transition that is based on time instead of a particular variable. Thus it is possible to move from one state to another based on the passage of time.
7. Restart - Press the Restart button to clear the state machine and set the state back to state 1. Note that often a state machine never ends and can cycle through states without termination. In this case the Restart button may not be of value.
Click Here to download an example file that will change a left_motor and right_motor variable to turn right, straight and then stop. Note that NOTHING happens unless additional modules are added to send these variable values to a motor, servo, etc. If you add the Watch Variable module you can see these variables change as time progresses.
Click Here to download an example file that will say hello and ask how you are. Based on a "fine" or "bad" response it will change the response. A speaker and a microphone are needed for this.
FINITE_STATE_MACHINE_STATE - number of active state/tab FINITE_STATE_MACHINE_NAME - name of active state/tab
For more information
|State_Machine Related Forum Posts||Last post||Posts||Views|
Hi, Im unable to solve this type obstacle avoidance; Kindly can you share the idea to make the rob...
Hello Steven, thanks for the great module "State Machine". But it seem little buggy , values of fields and tabs...