Go to the documentation of this file.00001
00002
00003
00004 from flexbe_core import EventState, Logger
00005 from flexbe_core.proxy import ProxyPublisher
00006 from std_msgs.msg import String
00007
00008 '''
00009 Created on 9.11.2017
00010
00011 @author: Alireza Hosseini
00012 '''
00013
00014
00015 class PublisherStringState(EventState):
00016 '''
00017 Publishes a string (std_msgs/String) message on a given topic name.
00018
00019 -- topic string The topic on which should be published.
00020
00021 >= value Value of string.
00022
00023 <= done Done publishing.
00024
00025 '''
00026
00027 def __init__(self, topic):
00028 '''
00029 Constructor
00030 '''
00031 super(PublisherStringState, self).__init__(outcomes=['done'], input_keys=['value'])
00032
00033 self._topic = topic
00034 self._pub = ProxyPublisher({self._topic: String})
00035
00036 def execute(self, userdata):
00037 return 'done'
00038
00039 def on_enter(self, userdata):
00040 val = String()
00041 val.data = userdata.value
00042 self._pub.publish(self._topic, val)