gen_numbers.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 from __future__ import print_function
00003 
00004 import rospy
00005 
00006 import random
00007 
00008 from std_msgs.msg import Float32
00009 
00010 
00011 def gen_number():
00012     rospy.init_node('random_number_generator')
00013 
00014     pub = rospy.Publisher('random_number', Float32)
00015 
00016     rospy.loginfo("Generating random numbers")
00017     rate = rospy.Rate(20)
00018     while not rospy.is_shutdown():
00019         pub.publish(Float32(random.normalvariate(5, 1)))
00020         rate.sleep()
00021 
00022 if __name__ == '__main__':
00023     try:
00024         gen_number()
00025     except KeyboardInterrupt:
00026         print("done")


actionlib_tutorials
Author(s): Melonee Wise
autogenerated on Thu Aug 27 2015 12:52:05