Go to the documentation of this file.00001
00002 from __future__ import absolute_import
00003
00004 import sys
00005
00006 """
00007 A very simple echo ROS node, with delay.
00008 - echo from topic to echo_topic
00009 - echo service
00010 """
00011 import functools
00012
00013 import common
00014 import rospy
00015 import std_msgs.msg as std_msgs
00016 import std_srvs.srv as std_srvs
00017
00018
00019 from pyros_test.srv import StringEchoService
00020
00021 def service_callback(data):
00022
00023 print "==> sleeping {delay} seconds ".format(delay=30)
00024 rospy.rostime.wallsleep(30)
00025 print "==> finally replying to {d} ".format(d=data)
00026 return "response"
00027
00028
00029 if __name__ == '__main__':
00030 try:
00031 args = rospy.myargv(argv=sys.argv)
00032 node_name = args[1] if len(args) > 1 else 'string_slow_node'
00033
00034 rospy.init_node(node_name)
00035 rospy.loginfo('String Slow node started. [' + rospy.get_name() + ']')
00036
00037 slow_service_name = rospy.get_param("~slow_service_name", "slow_service")
00038 print 'Parameter {0!s} has value {1!s}'.format(rospy.resolve_name('~slow_service_name'), slow_service_name)
00039 if slow_service_name == "":
00040 print "{0} parameter not found".format(rospy.resolve_name('~slow_service_name'))
00041 raise common.TestArgumentNotFound
00042
00043 srv = rospy.Service(slow_service_name, StringEchoService, service_callback)
00044
00045 rospy.spin()
00046
00047 except rospy.ROSInterruptException:
00048 pass
00049
00050
00051
00052