ROS 发布者 1 个插槽可以超额分配时间吗?

问题描述

#!/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(在这种情况下,rate 为 5,所以 1slot 为 0.2sec)是否有可能超过分配的时间。

当1个槽超过分配时间时,是否终止?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)