Ejemplo n.º 1
0
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()
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
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()
Ejemplo n.º 4
0
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()
Ejemplo n.º 5
0
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()
Ejemplo n.º 6
0
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()