#!/usr/bin/env python
import rospy
import time
from std_msgs.msg import Int32
rospy.init_node('teacher')
pub = rospy.Publisher('msg_to_students', Int32, queue_size=0)
def do_job(number):
for i in range(0,number):
i=i+1
pub.publish(i)
rate = rospy.Rate(5)
print('input : ')
number = input()
total = 0
t_from = time.time()
for i in range(5):
do_job(number)
t_to = time.time()
rate.sleep()
gap = t_to-t_from
print(i,'slot : ', gap)
t_from = time.time()
total += gap
print('total slot : ', total)
这是我的代码
我想知道 Sender 节点的 1slot(在这种情况下,速率为 5,因此 1slot 为 0.2 秒)是否有可能超过分配的时间。
当 1 个时隙超过指定时间时,它会终止吗?