publisher_string_state.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 from flexbe_core import EventState
3 from flexbe_core.proxy import ProxyPublisher
4 from std_msgs.msg import String
5 
6 
7 class PublisherStringState(EventState):
8  '''
9  Publishes a string (std_msgs/String) message on a given topic name.
10 
11  -- topic string The topic on which should be published.
12 
13  >= value Value of string.
14 
15  <= done Done publishing.
16  '''
17 
18  def __init__(self, topic):
19  super(PublisherStringState, self).__init__(outcomes=['done'], input_keys=['value'])
20  self._topic = topic
21  self._pub = ProxyPublisher({self._topic: String})
22 
23  def execute(self, userdata):
24  return 'done'
25 
26  def on_enter(self, userdata):
27  val = String()
28  val.data = userdata.value
29  self._pub.publish(self._topic, val)
flexbe_states.publisher_string_state.PublisherStringState
Definition: publisher_string_state.py:7
flexbe_states.publisher_string_state.PublisherStringState.__init__
def __init__(self, topic)
Definition: publisher_string_state.py:18
flexbe_states.publisher_string_state.PublisherStringState._pub
_pub
Definition: publisher_string_state.py:21
flexbe_states.publisher_string_state.PublisherStringState.on_enter
def on_enter(self, userdata)
Definition: publisher_string_state.py:26
flexbe_states.publisher_string_state.PublisherStringState.execute
def execute(self, userdata)
Definition: publisher_string_state.py:23
flexbe_core::proxy
flexbe_states.publisher_string_state.PublisherStringState._topic
_topic
Definition: publisher_string_state.py:20


flexbe_states
Author(s): Philipp Schillinger
autogenerated on Fri Jul 21 2023 02:26:17