Robotics StackExchange | Archived questions

smach_viewer returns incorrect states for smach concurrency

I am using roskinetic and learning the state machine implementations in ROS. I am trying to run two states in parallel, following the code provided here http://wiki.ros.org/smach/Tutorials/Concurrent%20States However, I am unable to visualize the states FOO and BAR. The diagram has SMPATH, 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')
sis.start()

# Open the container
with sm_top:

    smach.StateMachine.add('BAS', Bas(),
                           transitions={'outcome3':'CON'})

    sm_con = smach.Concurrence(outcomes=['outcome4','outcome5'],
                               default_outcome='outcome4',
                               outcome_map={'outcome5':
                                   { 'FOO':'outcome2',
                                     'BAR':'outcome1'}})

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

    smach.StateMachine.add('CON', sm_con,
                           transitions={'outcome4':'CON',
                                        'outcome5':'outcome6'})

outcome = sm_top.execute()
rospy.spin()
sis.stop()

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.

Asked by Neeharika on 2019-04-14 14:10:24 UTC

Comments

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.

Asked by gvdhoorn on 2019-04-15 02:30:11 UTC

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.

Asked by yelkcub on 2020-10-02 08:38:06 UTC

Answers