string_sub_node.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 """ A dummy ROS node """
4 from __future__ import absolute_import
5 
6 import common
7 import sys
8 
9 import rospy
10 import std_msgs
11 
12 # TODO : implement service to check if sub
13 
14 
15 # a callback that just echoes the message ( if it doesnt come from me )
16 def topic_callback(self, data):
17  pass
18 
19 
20 if __name__ == '__main__':
21  try:
22  args = rospy.myargv(argv=sys.argv)
23  node_name = args[1] if len(args) > 1 else 'string_pub_node'
24 
25  rospy.init_node(node_name)
26  rospy.loginfo('String Pub node started. [' + rospy.get_name() + ']')
27 
28  topic_name = rospy.get_param("~topic_name", "")
29  print 'Parameter {0!s} has value {1!s}'.format(rospy.resolve_name('~topic_name'), topic_name)
30  if topic_name == "":
31  print "{0} parameter not found".format(rospy.resolve_name('~topic_name'))
33  test_message = rospy.get_param("~test_message", "")
34  print 'Parameter {0!s} has value {1!s}'.format(rospy.resolve_name('~test_message'), test_message)
35  if test_message == "":
36  print "{0} parameter not found".format(rospy.resolve_name('~test_message'))
38 
39  sub = rospy.Subscriber(topic_name, std_msgs.msg.String, topic_callback)
40 
41  rospy.spin()
42 
43  except rospy.ROSInterruptException:
44  pass
def topic_callback(self, data)


pyros_test
Author(s): AlexV
autogenerated on Mon Jun 10 2019 14:20:23