string_pubnot_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 pub
13 
14 if __name__ == '__main__':
15  try:
16  args = rospy.myargv(argv=sys.argv)
17  node_name = args[1] if len(args) > 1 else 'string_pubnot_node'
18 
19  rospy.init_node(node_name)
20  rospy.loginfo('String Pub node started. [' + rospy.get_name() + ']')
21 
22  topic_name = rospy.get_param("~topic_name", "")
23  print 'Parameter {0!s} has value {1!s}'.format(rospy.resolve_name('~topic_name'), topic_name)
24  if topic_name == "":
25  print "{0} parameter not found".format(rospy.resolve_name('~topic_name'))
27  test_message = rospy.get_param("~test_message", "")
28  print 'Parameter {0!s} has value {1!s}'.format(rospy.resolve_name('~test_message'), test_message)
29  if test_message == "":
30  print "{0} parameter not found".format(rospy.resolve_name('~test_message'))
32 
33  pub = rospy.Publisher(topic_name, std_msgs.msg.String, queue_size=1)
34 
35  rate = rospy.Rate(10) # 10hz
36  while not rospy.is_shutdown():
37  # this node is not publishing anything, despite declaring a publisher
38  #pub.publish(test_message)
39  rate.sleep()
40 
41  except rospy.ROSInterruptException:
42  pass


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