def generator(): pub = rospy.Publisher('/numbers', TwoInt, queue_size=10) rospy.init_node('generator', anonymous=True) Frequency = rospy.Rate(10) while not rospy.is_shutdown(): num = TwoInt() num.num1 = randint(1, 100) num.num2 = randint(1, 100) rospy.loginfo(num) pub.publish(num) Frequency.sleep()
def main(): pub = rospy.Publisher('/numbers', TwoInt, queue_size=10) rospy.init_node('generator') rate = rospy.Rate(0.1) msg=TwoInt() while not rospy.is_shutdown(): msg.num1 = randint(0,100) msg.num2 = randint(0,100) rospy.loginfo(msg) pub.publish(msg) rate.sleep
def talker(): pub = rospy.Publisher('numbers', TwoInt, queue_size=10) rospy.init_node('talker', anonymous=True) rate = rospy.Rate(10) # 10hz while not rospy.is_shutdown(): number = TwoInt() number.num1 = random.randint(0, 100) number.num2 = random.randint(0, 100) rospy.loginfo(number) pub.publish(number) rate.sleep()
def generator(): pub = rospy.Publisher('/numbers', TwoInt, queue_size=10) rospy.init_node('generator', anonymous=True) rate = rospy.Rate(10) msg = TwoInt() while not rospy.is_shutdown(): msg.num1 = random.randint(1, 100) msg.num2 = random.randint(1, 100) rospy.loginfo(msg) pub.publish(msg) rate.sleep()
def generator(): pub = rospy.Publisher('numbers', TwoInt, queue_size=10) #publish to topic "numbers" rospy.init_node('generator', anonymous=True) #"generator" is published rate = rospy.Rate(10) #20Hz while not rospy.is_shutdown(): msg = TwoInt() msg.num1 = random.randint(0, 100) msg.num2 = random.randint(0, 100) # print(msg) rospy.loginfo(msg) pub.publish(msg) rate.sleep()
def talker(): pub = rospy.Publisher('numbers', TwoInt, queue_size=1) rospy.init_node('generator', anonymous=True) rate = rospy.Rate(10) # 10hz msg = TwoInt() while not rospy.is_shutdown(): # hello_str = "hello world" # rospy.loginfo(hello_str) # pub.publish(hello_str) msg.num1 = random.randrange(0, 100, 1) msg.num2 = random.randrange(0, 100, 1) # a = [num1, num2] # rospy.loginfo(hello_str) pub.publish(msg) rate.sleep()
def generate(): pub = rospy.Publisher('/num', TwoInt, queue_size=10) rospy.init_node('TwoInt', anonymous=True) rate = rospy.Rate(10) # 10hz num = TwoInt() while not rospy.is_shutdown(): TwoInt.num1 = [randint(0, 100) for p in range(0, 100)] TwoInt.num2 = [randint(0, 100) for p in range(0, 100)] rospy.loginfo(num) pub.publish(num) rate.sleep()
def adder(): num = TwoInt() rospy.init_node('adder', anonymous=True) rospy.Subscriber("/numbers", TwoInt, callback) rospy.spin()