Simple example

In this example, we have four states: A, B, C, and D. This example aims to transition from one state to another on reception of an output. The end result looks like this:

Simple transition between states

Let's look at the code in detail. The complete code is available in this book's GitHub repository:

Let's look into the code in detail. We will bring in the following import statements, along with the Python shebang file:

#!/usr/bin/env pythonimport rospyfrom smach import State,StateMachinefrom time ...

Get ROS Robotics Projects now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.