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 (pleiad.cl/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 (http://wiki.ros.org/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?
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.
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 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.
Hmm tried this again and it does work 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.
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 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.
Best,
Carlos
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.