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:
Let's look at the code in detail. The complete code is available in this book's GitHub repository: https://github.com/PacktPublishing/ROS-Robotics-Projects-SecondEdition/blob/master/chapter_4_ws/src/smach_example/simple_fsm.py.
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 ...