34 from __future__
import print_function
43 from threading
import Thread
48 unittest.TestCase.__init__(self, *args)
50 rospy.init_node(
'test_rospy_timer_online')
63 self.assert_(abs(dur - 0.1) < 0.03, dur)
66 rospy.sleep(rospy.Duration.from_sec(0.1))
69 self.assert_(abs(dur - 0.1) < 0.03, dur)
73 rospy.sleep(rospy.Duration.from_sec(-10.))
76 self.assert_(abs(dur) < 0.1, dur)
88 self.assert_(abs(dur - 1.0) < 0.5, dur)
95 print(
'last_expected: ', event.last_expected)
96 print(
'last_real: ', event.last_real)
97 print(
'current_expected: ', event.current_expected)
98 print(
'current_real: ', event.current_real)
99 print(
'current_error: ', (event.current_real - event.current_expected).to_sec())
100 print(
'profile.last_duration:', event.last_duration)
102 print(
'last_error: ', (event.last_real - event.last_expected).to_sec(),
'secs')
115 self.assert_(ev
is not None)
116 self.assert_(abs((ev.current_real - ev.current_expected).to_sec()) < 2.)
118 if __name__ ==
'__main__':
119 rosunit.unitrun(
'test_rospy', sys.argv[0], TestRospyTimerOnline, coverage_packages=[
'rospy.timer'])
def _Timer_callback(self, event)