string_sub_node.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 """ A dummy ROS node """
00004 from __future__ import absolute_import
00005 
00006 import common
00007 import sys
00008 
00009 import rospy
00010 import std_msgs
00011 
00012 # TODO : implement service to check if sub
00013 
00014 
00015 # a callback that just echoes the message ( if it doesnt come from me )
00016 def topic_callback(self, data):
00017     pass
00018 
00019 
00020 if __name__ == '__main__':
00021     try:
00022         args = rospy.myargv(argv=sys.argv)
00023         node_name = args[1] if len(args) > 1 else 'string_pub_node'
00024 
00025         rospy.init_node(node_name)
00026         rospy.loginfo('String Pub node started. [' + rospy.get_name() + ']')
00027 
00028         topic_name = rospy.get_param("~topic_name", "")
00029         print 'Parameter {0!s} has value {1!s}'.format(rospy.resolve_name('~topic_name'), topic_name)
00030         if topic_name == "":
00031             print "{0} parameter not found".format(rospy.resolve_name('~topic_name'))
00032             raise common.TestArgumentNotFound
00033         test_message = rospy.get_param("~test_message", "")
00034         print 'Parameter {0!s} has value {1!s}'.format(rospy.resolve_name('~test_message'), test_message)
00035         if test_message == "":
00036             print "{0} parameter not found".format(rospy.resolve_name('~test_message'))
00037             raise common.TestArgumentNotFound
00038 
00039         sub = rospy.Subscriber(topic_name, std_msgs.msg.String, topic_callback)
00040 
00041         rospy.spin()
00042 
00043     except rospy.ROSInterruptException:
00044         pass


pyros_test
Author(s): AlexV
autogenerated on Sat Jun 8 2019 20:51:06