ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A

State Machine Visualization


I’m working on a state machine visualization for robotic development. The goal is to improve the actual visualization giving more power and feedback to developers to see and even modify certain aspects of their programs.
So far I developed a live programming language for robotics called LRP ( In this language we developed a live visualization that interact with the source code in real time.
Now I’m working on a visualization for SMACH ( I know the existence of the visualization for smach, but I want to improve it with our research on LRP and more.

To do this I want your help:
Do you have any real example of a robotic program using state machines (with any API) that I could analyse?
Do you have any experience using state machines to write programs?
How do you use the standard visualization of a state machine API when there is a visualization?
Any experience of debugging a program using state machines?

If you feel more confident talking in private, you can email me:

I’m planning to make a form, but first I want some impressions to start working with it and then make a better form for more people.

Thanks in advance for your help,

1 Like

Hey @mcamp,

We (Team ViGIR) developed FlexBE (Flexible Behavior Engine) for our entry in the 2015 DARPA Robotics Challenge finals. It’s an extension of SMACH and was the high-level executive running onboard our Atlas humanoid robot. One of the operators monitored and interacted with the executive via a GUI.


This looks absolutely amazing @spmaniato!

Good luck @mcamp for your project!

Do you have any experience using state machines to write programs?

I used state machines at my first job doing industrial automation. We used PLC programming and PackML structure for our state mahine. It was easy to setup and understand.

Now I’m a mobile robotisist and I am finding SMACH hard to setup and hard to understard :confused: so its good to hear someone is trying to improve it.

How do you use the standard visualization of a state machine API when there is a visualization?

After starting my code I run rosrun smach_viewer as quick as possible to view my first few transitions. Then I got to the state I’m testing out, something doesn’t work so I shut down my code and the SMACH viewer (it would be really nice if I could leave the SMACH viewer open and have it reconnect).

Any experience of debugging a program using state machines?

I control my state transitions with an xbox controller which I find convenient.

Thank you guys,

@spmaniato I’m going to take a look at it, specially the examples :slight_smile:

SMACH does not do that? I think it does

how do you do that?

Hmm tried this again and it does work :slight_smile: I think I’ve run into scenarios where it doesn’t, either that or I’m crazy. Who knows. But thank you, think will help with my debugging.

I use wireless Xbox controller with a wireless dongle. The ROS package for this is called joy. I then wrote a small python node to publish a string like “stop” or “go_to_kitchen” to the /controller_command topic.

Then I use a SMACH monitor state to listen to the /controller_cmd topic and transition to a state according to what message it sees.

I was re-reading your answer and I notice this (I do not know how I miss this before). Why do you think SMACH is hard to setup and understand?

Relative to PLC state machines I find SMACH very difficult to setup and understand. But compared to the spaghetti code that would result with a complex project and no state machine, SMACH is a vast improvement.

In the PLC world there is a very common state machine structure called PackML. Almost all automated manufacturing lines can use this same state machine, modified only slightly. Where I worked there was a file that contained the state transitions and at the top was written DO NOT EDIT THIS CODE! In your own code you set flags which were then used to change the state. You get the hang of it in about a day and then it’s very easy to program with. (BTW there is no parallel processing done in PLC’s)

Now with SMACH and robotics there is no such common state machine, and its very temping to mix your functional code with the state machine code, making it more difficult to understand. These are two of the major reasons I think I find it confusing, but I do appreciate the fact that SMACH is a much more powerful tool than something like PackML, so it makes sense that its harder to setup and understand.

I think that one day there could be a very common state machine setup using SMACH that does serve as a jumping off place for any robot. For example there may be a ‘teleop’ state, a ‘autonomous’ state, a ‘pause’ state, and a ‘recharge’ concurrence state would make up a pretty basic state machine that would apply to a lot of robots. I may try to create something like that and post it to github if I have the time. But right now I’m trying to learn FlexBe.

For those of you not familiar there’s already some interest in integrating with PackML in the ROS-I community.

I found ROS packages here:

As well as a SMACH - PackML integration here:


Just a heads up.

I am currently working on an implementation of Behavior Trees as an alternative of classical FSMs.

This will also include an editor and a real time visualization of the current state.

This is an early screenshot of the editor:

It is not ready for prime time but it will be in a couple of months.




Hi all,

For those who do not know it, and I don’t know why, this package is very well written with a very nice and pro rqt plugin:

IMHO supersedes SMACH, already by the fact that is C++ and not python, but also because it implements FSM, HFSM, BT, and TAOs.

It was available in hydro, but I think the maintainers lost interest in releasing into further distros, although I’m on 16.04/Kinetic and it works like a charm.


I don’t really agree with / care for the “it’s not Python” remark, but other than that, +1 for this package.

1 Like

Haha my apologies, I’m a bit anti-python :wink:

1 Like

Will be announcing a behaviour trees implementation in a few days - be interesting to see where our implementations meet.

The core demos and ROS tutorials pages are where you can do a quick dive to see what it is up to.

No editor (yours looks nice), but we found scripting a tree in python flexible and quick enough. More important for us were an rqt monitor, bagging and replaying capabilities.

1 Like