ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

smach: advice on conditional logic

asked 2017-09-10 09:36:40 -0600

knxa gravatar image

I have a smach tree with "SimpleActionState"s as the leaf states. I am trying to create a good concept for conditional logic in the SMACH level. A state should check a condition and only progress to its children states, if the condition is met. It the condition is not met, the state completes as "skipped" which would translate to "succeeded", so the execution continues with other states.

The data that the condition would refer to might be stuff like

  • Is motor X busy?
  • Is motor X initialized?
  • Is motor Y position in range [P1:P2]

Should I create ROS services where these answers can be provided, and create my own version of ConditionState that would call this service and act on the response appropriately? Or should I ensure the status data for motors are posted on the ROS parameter server, so I can test these data in a state? Or should involve the userdata in a collaboration between several states?

I can see that some of this logic is involved in ConditionState and MonitorState but not sure how far these states can take me. Also I am building the SMACH hierarchy from an xml description so I need a very generic way of describing a condition to be tested. I cannot depend on per-case customized callbacks.

edit retag flag offensive close merge delete


This is not an answer, but I've seen you post a lot of questions about SMACH recently and wanted to make sure you are/were aware of flexbe.

gvdhoorn gravatar image gvdhoorn  ( 2017-09-10 11:12:49 -0600 )edit

Thanks, and no, I was not aware of flexbe. I have briefly looked through the flexbe introduction and I am in two minds. I am somewhat hesitant to pull in a large framework if it may be overkill. Maybe I should ask a separate question on the how flexbe will meet my requirements better than SMACH.

knxa gravatar image knxa  ( 2017-09-10 13:52:40 -0600 )edit

FlexBE essentially is SMACH, but with a GUI and a lot of convenience.

gvdhoorn gravatar image gvdhoorn  ( 2017-09-10 14:29:14 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-11-16 01:41:54 -0600

knxa gravatar image

updated 2017-11-16 01:42:15 -0600

I ended up using a combination of Monitorstate and some homegrown states that can query nodes for data through a service.

edit flag offensive delete link more


Thanks for updating your own question!

I'm curious if you ended up messing with FlexBE (and if so what you thought of it versus your Answer). Thanks!

josephcoombe gravatar image josephcoombe  ( 2017-11-16 10:40:43 -0600 )edit

I have spend a day or two with FlexBE. It is well designed. Seems quite flexible. Examples are good. Many nice features. I like that it takes a different approach to concurrency and preemption than plain SMACH. SMACH has some problems here. The greatest strength is the graphical overview

knxa gravatar image knxa  ( 2017-11-23 10:27:29 -0600 )edit

... which involves both creation, editing, debugging, monitoring state machines. The graphical approach is also its weakness: I found it a bit cumbersome to create behaviors, to drill down the hierarchy of behaviors. A lot of work with the mouse. The benefits comes with a cost of complexity, ...

knxa gravatar image knxa  ( 2018-04-05 02:54:48 -0600 )edit

... and I found my xml based setup easier to overview and hack. In the long run I might benefit from the design and framework that comes with FlexBe, but right now I am hesitant...

knxa gravatar image knxa  ( 2018-04-05 02:59:45 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2017-09-10 09:36:40 -0600

Seen: 252 times

Last updated: Nov 16 '17