2 from __future__
import absolute_import
7 A very simple echo ROS node class. 8 - echo from topic to echo_topic 14 import std_msgs.msg
as std_msgs
18 from pyros_test.srv
import StringEchoService
27 rospy.loginfo(
'String Echo node started. [' + rospy.get_name() +
']')
29 topic_name = rospy.get_param(
"~topic_name",
"topic")
30 print 'Parameter {0!s} has value {1!s}'.format(rospy.resolve_name(
'~topic_name'), topic_name)
34 echo_topic_name = rospy.get_param(
"~echo_topic_name",
"echo_topic")
35 print 'Parameter {0!s} has value {1!s}'.format(rospy.resolve_name(
'~echo_topic_name'), echo_topic_name)
36 if echo_topic_name ==
"":
39 echo_service_name = rospy.get_param(
"~echo_service_name",
"echo_service")
40 print 'Parameter {0!s} has value {1!s}'.format(rospy.resolve_name(
'~echo_service_name'), echo_service_name)
41 if echo_service_name ==
"":
46 pub = rospy.Publisher(echo_topic_name, std_msgs.String, queue_size=1)
49 echo = functools.partial(self.
topic_callback, data_type=std_msgs.String, pub=pub)
50 sub = rospy.Subscriber(topic_name, std_msgs.String, echo)
52 srv = rospy.Service(echo_service_name, StringEchoService, self.
service_callback)
58 print "==> echoing {d} ".format(d=data)
59 pub.publish(data=data.data)
67 print "==> echoing {d} ".format(d=data)
def service_callback(self, data)
def topic_callback(self, data, data_type, pub)