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 smach_viewer.py 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.
[Discourse.ros.org] [ROS Projects] State Machine Visualization
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](https://en.wikipedia.org/wiki/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.