Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rostest] Check /clock publication neatly in publishtest #973

Merged
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions tools/rostest/nodes/publishtest
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Author: Kentaro Wada <www.kentaro.wada@gmail.com>
"""

import sys
import time
import unittest

from nose.tools import assert_true
Expand Down Expand Up @@ -107,10 +108,15 @@ class PublishTest(unittest.TestCase):
def test_publish(self):
"""Test topics are published and messages come"""
use_sim_time = rospy.get_param('/use_sim_time', False)
while use_sim_time and (rospy.Time.now() == rospy.Time(0)):
t_start = time.time()
while not rospy.is_shutdown() and \
use_sim_time and (rospy.Time.now() == rospy.Time(0)):
rospy.logwarn('/use_sim_time is specified and rostime is 0, '
'/clock is published?')
rospy.sleep(0.1)
if time.time() - t_start > 10:
self.fail('Timed out (10s) of /clock publication.')
# must use time.sleep because /clock isn't yet published, so rospy.sleep hangs.
time.sleep(1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it sleep for 1s now and not for 0.1s as before? I think it is valuable to continue quickly once the clock is available.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, the warning should only be printed once to avoid flooding the console unnecessarily.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either once or using the throttled logging functions to print it only every N seconds.

# subscribe topics
checkers = []
for topic in self.topics:
Expand Down