ros-visualization / executive_smach_visualization

A ROS-based introspection tool for visualizing the structure and state of SMACH plans.
18 stars 68 forks source link

smach_viewer: Can't view independent SMACH FSMs ("Path not available" at root "path: /") #18

Open josephcoombe opened 6 years ago

josephcoombe commented 6 years ago

In smach_viewer, I get a "Path not available" message and no visualization when the path is set to "/" as shown below: screenshot 2018-04-18 08 43 21


From @jbohren's old rqt_smach.md, I expected to be able to view independent SMACH FSMs on the same canvas, specifically b/c rqt_smach.md has this screenshot: image


Is this a bug in smach_viewer?

Also, is smach_viewer the successor to rqt_smach or do the two have different (but similar) capabilities?

k-okada commented 6 years ago

@josephcoombe can you provide example to reproduce this? And rqt_smach should be newer this this package, but i’m not sure about the current status of that package.

josephcoombe commented 6 years ago

Here's a simple example.

1) Create test_fsm.py

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import print_function

import rospy
from rospy import Subscriber
from smach import StateMachine, State
import smach_ros

from std_msgs.msg import String

class Tic(State):
    def __init__(self):
        State.__init__(self, outcomes=['success'])
        self._active = False
        self._ros_rate = rospy.Rate(100)
        self._tic_received = False
        self._listener = Subscriber('tic', String, callback=self._listener_cb)

    def execute(self, ud):
        self._active = True
        while not rospy.is_shutdown() and not self._tic_received:
            self._ros_rate.sleep()
        self._active = False
        self._tic_received = False
        return 'success'

    def _listener_cb(self, msg):
        if self._active:
            self._tic_received = True

if __name__ == '__main__':
    rospy.init_node('test_fsm', anonymous=True)

    top = StateMachine(outcomes=['success'])
    with top:
        StateMachine.add('TIC_A', Tic(), transitions={'success':'TIC_B'})
        StateMachine.add('TIC_B', Tic(), transitions={'success':'TIC_C'})
        StateMachine.add('TIC_C', Tic(), transitions={'success':'TIC_A'})

    sis = smach_ros.IntrospectionServer(str(rospy.get_name()), top, '/SM_ROOT' + str(rospy.get_name()))
    sis.start()

    top.execute()

    rospy.spin()
    sis.stop()

2) chmod +x test_fsm.py 3) roscore 4) In two separate terminals, python test_fsm.py 5) rosrun smach_viewer smach_viewer.py

You should be able to view both state machines separately im1

and im2

but not together... im3