gen_numbers.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 from __future__ import print_function
3 
4 import rospy
5 
6 import random
7 
8 from std_msgs.msg import Float32
9 
10 
11 def gen_number():
12  rospy.init_node('random_number_generator')
13 
14  pub = rospy.Publisher('random_number', Float32)
15 
16  rospy.loginfo("Generating random numbers")
17  rate = rospy.Rate(20)
18  while not rospy.is_shutdown():
19  pub.publish(Float32(random.normalvariate(5, 1)))
20  rate.sleep()
21 
22 if __name__ == '__main__':
23  try:
24  gen_number()
25  except KeyboardInterrupt:
26  print("done")
def gen_number()
Definition: gen_numbers.py:11


actionlib_tutorials
Author(s): Melonee Wise
autogenerated on Wed Jun 5 2019 20:54:23