Periodic long pauses between rospy.Timer callback calls [closed]
I have a Python node that contains a class similar to this:
class Test(object):
def __init__(self):
rospy.init_node("test")
self._timer = rospy.Timer(1 / 30.0, self._timer_cb)
def do_stuff(self):
while not rospy.is_shutdown():
do_other_stuff()
def _timer_cb(self, not_used):
rospy.loginfo("_timer_cb()")
At the end of the node, I do this:
test = Test()
test.do_stuff()
I would expect _timer_cb() to print "_timer_cb()" roughly 30 times per second, while do_other_stuff() (which takes a few seconds to return) would run concurrently. My understanding is that each rospy.Timer object has its own thread. However, what's happening is that _timer_cb() is not called for a period of several seconds (roughly the length of time do_other_stuff() takes to execute), then it is called at a high frequency (as expected), then there is another multi-second pause. This behavior then repeats. Why is this happening? I am running ROS Hydro on Ubuntu 12.04 LTS. Gazebo 1.9.5 is generating the simulation time.