SMACH (State MACHine) is an open source Python library for building hierarchical and concurrent state machines. SMACH is useful for handling structured tasks, task-level execution and coordination, and it allows for easy building, maintenance, and debugging of complex state machines.

At its core, SMACH is independent of ROS, the executive-smach stack provides a ROS integration, including integration of the actionlib package described in 2.4.1, and Smach Viewer. Smach Viewer is a GUI for SMACH, it can visualize transitions between states, current active states, and values of data passed around, enabling easy introspection of SMACH state machines. The state classes provided by the library, support ROS protocols, means for passing user data between states is also provided. Upon building a SMACH state machine, consistency check of state transitions is provided by the library.

The SMACH core library provides two main interfaces, State and Container. State represents a state of execution, with potential outcomes defined prior to execution. A SMACH Container is a collection of one or more states, implementing some execution policy. Containers also define behavior for dealing with preemption requests, this entails functionality for dealing with termination signals, and lets the system be canceled in a controlled fashion.

SMACH is in essence a library for creating state machines, and provides the StateMachine container. But SMACH also goes a little beyond this, providing other containers as well, StateMachine being the simplest one, while Concurrence container provides means for executing more than one state at the same time.

  • No labels