[Documentation] [TitleIndex] [WordIndex

SMACH Tutorials

Learning SMACH

If you just want to look at code, try out the learning by example. If you rather follow a step-by-step guide, choose the step-by-step tutorials.

Learning Step-by-Step

Learning by Example

  1. Getting Started with smach

    This tutorial guides you through the very first steps of using smach.

  2. Passing User Data between States

    This tutorial teaches you how to pass data from one state(machine) to the next state(machine).

  3. Create a Hierarchical State Machine

    This tutorial teaches you how to nest different state machines, creating a hierarchical state machine.

  4. Calling Actions from a State Machine (ROS)

    This tutorial teaches you how to call action servers from within a SMACH state machine.

  5. Viewing State Machines (ROS)

    This tutorial shows you how to use the smach viewer, a simple tool to monitor state machines and get introspection into the data flow between states.

  1. Simple State Machine

    This tutorial shows how to put together a simple state machine with two states.

  2. User Data Passing

    This tutorial gives an example of two states passing user data to each other.

  3. Nesting State Machines

    This tutorial gives an example of nesting a state machine in another state machine, creating a hierarchical state machine.

  4. Concurrent State Machine

    This tutorial shows an example of running two states in parallel.

  5. Simple Action State (ROS)

    This tutorial shows an example of states that call directly into the actionlib interface.

SMACH Containers

  1. StateMachine container

    This tutorial teaches you how to use the StateMachine container.

  2. Concurrence container

    This tutorial teaches you how to use the Concurrence container.

  3. Sequence container

    This tutorial teaches you how to use the Sequence container.

  4. Iterator container

    This tutorial teaches you how to use the Iterator container.

  5. Wrapping a Container With actionlib

    This tutorial explains how to serve out a SMACH plan as an action over actionlib.

SMACH States

  1. Generic State

    This tutorial show how to implement a generic SMACH State

  2. CBState

    This tutorial gives an example of how to use CBState, a state that simply executes a callback when it is active.

  3. SimpleActionState (ROS)

    This tutorial show how to use the SimpleActionState to directly call an action interface using SMACH

  4. ServiceState (ROS)

    This tutorial shows how to represent the execution of a service as a SMACH state.

  5. MonitorState (ROS)

    Monitor a state!

Advanced SMACH

  1. Writing Custom Container Classes

    Most tasks can be performed without writing new types of container classes, but this tutorial explains how to write a new one.

  2. State Preemption Implementation

    This tutorial shows how to implement simple flag-based preemption in SMACH states.

  3. StateMachinePreemption

    Example of a state machine that implements preemption, using a concurrence container and monitor state.

  4. Writing Custom State Classes with User-defined Callbacks

    Sometimes you want to create a state class like smach.SimpleActionState which receives user callbacks as arguments. If these callbacks change the SMACH interface of a state (outcomes, userdata keys), then the callbacks need to be annotated with this information.

  5. State Preemption Implementation

    This tutorial shows how to implement simple flag-based preemption in SMACH states.

  6. Writing Custom Container Classes

    Most tasks can be performed without writing new types of container classes, but this tutorial explains how to write a new one.

  7. Writing Custom State Classes with User-defined Callbacks

    Sometimes you want to create a state class like smach.SimpleActionState which receives user callbacks as arguments. If these callbacks change the SMACH interface of a state (outcomes, userdata keys), then the callbacks need to be annotated with this information.

  8. StateMachinePreemption

    Example of a state machine that implements preemption, using a concurrence container and monitor state.

Create a new tutorial:

Test your SMACH knowledge

If you're interested in testing your SMACH knowledge, this page has a step-by-step test/example to test your knowledge of different states and containers.


2024-11-09 17:39