smach_viewer returns incorrect states for smach concurrency

asked 2019-04-14 14:10:24 -0500

Neeharika gravatar image

I am using ros_kinetic and learning the state machine implementations in ROS. I am trying to run two states in parallel, following the code provided here However, I am unable to visualize the states FOO and BAR. The diagram has SM_PATH, BAS, CON and the corresponding outcomes (outcome 3,4,5 and 6).

Main function definition

# Create the top level SMACH state machine
sm_top = smach.StateMachine(outcomes=['outcome6'])

sis = smach_ros.IntrospectionServer('introspection_server', sm_top, '/SM_ROOT')

# Open the container
with sm_top:

    smach.StateMachine.add('BAS', Bas(),

    sm_con = smach.Concurrence(outcomes=['outcome4','outcome5'],
                                   { 'FOO':'outcome2',

    with sm_con:
        smach.Concurrence.add('FOO', Foo())
        smach.Concurrence.add('BAR', Bar())

    smach.StateMachine.add('CON', sm_con,

outcome = sm_top.execute()

There is an edge 'outcome4' from CON to itself and another edge 'outcome5' to 'outcome6' but FOO and BAR are missing in the graph view.

edit retag flag offensive close merge delete


and learning the state machine implementations in ROS

small correction: SMACH (as nice as it is/was) is just one of the implementations of the state machine pattern with ROS compatibility / integration.

It is by no means "the state machine implementation in ROS", as that would imply that it is either the only one, or the best/recommended one.

gvdhoorn gravatar image gvdhoorn  ( 2019-04-15 02:30:11 -0500 )edit

I too have been having trouble with smach viewer crashing claiming "tail inside head". It seems as the graph loop closure algorithm can not handle something in my code despite the code being good.

I suspect it has something to do with the dict inside dict of the outcome_map declaration. I had no trouble until I started working with the concurrent state.I haven't had time to experiment with this to know for sure. It is really annoying, every time I change the view depth smach viewer crashes.

yelkcub gravatar image yelkcub  ( 2020-10-02 08:38:06 -0500 )edit