Skip to content

Commit

Permalink
Merge pull request #4 from fmessmer/test_noetic
Browse files Browse the repository at this point in the history
test noetic
  • Loading branch information
fmessmer authored Jan 7, 2021
2 parents ea7c46e + 0c2ba90 commit c14cc88
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 75 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# CMake
##############################################################################

cmake_minimum_required(VERSION 2.8.3)
cmake_minimum_required(VERSION 3.0.2)
project(rosjava_core)

##############################################################################
Expand Down
26 changes: 13 additions & 13 deletions rosjava/test/test_composite_passthrough.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,37 +67,37 @@ def cb_from_test(self, msg):
def test_composite_passthrough(self):
# 20 seconds to validate fixture
timeout_t = time.time() + 20.
print "waiting for 20 seconds for fixture to verify"
print("waiting for 20 seconds for fixture to verify")
while self.fixture_curr is None and \
not rospy.is_shutdown() and \
timeout_t > time.time():
time.sleep(0.2)

self.failIf(timeout_t < time.time(), "timeout exceeded")
self.failIf(rospy.is_shutdown(), "node shutdown")
self.failIf(self.fixture_curr is None, "no data from fixture")
self.assertFalse(timeout_t < time.time(), "timeout exceeded")
self.assertFalse(rospy.is_shutdown(), "node shutdown")
self.assertFalse(self.fixture_curr is None, "no data from fixture")
m = self.fixture_curr
self.assertAlmostEquals(m.a.x, m.b.x)
self.assertAlmostEquals(m.a.y, m.b.y)
self.assertAlmostEquals(m.a.z, m.b.z)
self.assertAlmostEqual(m.a.x, m.b.x)
self.assertAlmostEqual(m.a.y, m.b.y)
self.assertAlmostEqual(m.a.z, m.b.z)

# another 20 seconds to validate client
timeout_t = time.time() + 20.
print "waiting for 20 seconds for client to verify"
print("waiting for 20 seconds for client to verify")
while self.test_curr is None and \
not rospy.is_shutdown() and \
timeout_t > time.time():
time.sleep(0.2)

self.failIf(self.test_curr is None, "no data from test")
self.assertFalse(self.test_curr is None, "no data from test")
m = self.test_curr
self.assertAlmostEquals(m.a.x, m.b.x)
self.assertAlmostEquals(m.a.y, m.b.y)
self.assertAlmostEquals(m.a.z, m.b.z)
self.assertAlmostEqual(m.a.x, m.b.x)
self.assertAlmostEqual(m.a.y, m.b.y)
self.assertAlmostEqual(m.a.z, m.b.z)

# a.w = a.x + a.y + a.z. Just make sure we're in the ballpark
a = self.test_curr.a
self.assert_(abs(a.x + a.y + a.z - a.w) < 10.)
self.assertTrue(abs(a.x + a.y + a.z - a.w) < 10.)

if __name__ == '__main__':
import rostest
Expand Down
18 changes: 9 additions & 9 deletions rosjava/test/test_int64_passthrough.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,28 @@ def cb_from_test(self, msg):
def test_int64_passthrough(self):
# 20 seconds to validate fixture
timeout_t = time.time() + 20.
print "waiting for 20 seconds for fixture to verify"
print("waiting for 20 seconds for fixture to verify")
while self.fixture_prev is None and \
not rospy.is_shutdown() and \
timeout_t > time.time():
time.sleep(0.2)

self.failIf(timeout_t < time.time(), "timeout exceeded")
self.failIf(rospy.is_shutdown(), "node shutdown")
self.failIf(self.fixture_prev is None, "no data from fixture")
self.failIf(self.fixture_curr is None, "no data from fixture")
self.assertEquals(self.fixture_prev.data + 1, self.fixture_curr.data, "fixture should incr by one")
self.assertFalse(timeout_t < time.time(), "timeout exceeded")
self.assertFalse(rospy.is_shutdown(), "node shutdown")
self.assertFalse(self.fixture_prev is None, "no data from fixture")
self.assertFalse(self.fixture_curr is None, "no data from fixture")
self.assertEqual(self.fixture_prev.data + 1, self.fixture_curr.data, "fixture should incr by one")

# another 20 seconds to validate client
timeout_t = time.time() + 20.
print "waiting for 20 seconds for client to verify"
print("waiting for 20 seconds for client to verify")
while self.test_prev is None and \
not rospy.is_shutdown() and \
timeout_t > time.time():
time.sleep(0.2)

self.failIf(self.test_prev is None, "no data from test")
self.assertEquals(self.test_prev.data + 1, self.test_curr.data, "test does not appear to match fixture data")
self.assertFalse(self.test_prev is None, "no data from test")
self.assertEqual(self.test_prev.data + 1, self.test_curr.data, "test does not appear to match fixture data")


if __name__ == '__main__':
Expand Down
52 changes: 26 additions & 26 deletions rosjava/test/test_parameter_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def tilde_cb(self, msg):

def test_parameter_client_read(self):
timeout_t = time.time() + 20.
print "waiting for 20 seconds for client to load"
print("waiting for 20 seconds for client to load")

tests = self.tests
msgs = [None]
Expand All @@ -95,36 +95,36 @@ def test_parameter_client_read(self):
time.sleep(0.2)
msgs = [getattr(self, t+'_msg') for t in tests]

print "msgs: %s"%(msgs)
print("msgs: %s"%(msgs))

self.failIf(timeout_t < time.time(), "timeout exceeded")
self.failIf(rospy.is_shutdown(), "node shutdown")
self.failIf(any(1 for m in msgs if m is None), "did not receive all expected messages: "+str(msgs))
self.assertFalse(timeout_t < time.time(), "timeout exceeded")
self.assertFalse(rospy.is_shutdown(), "node shutdown")
self.assertFalse(any(1 for m in msgs if m is None), "did not receive all expected messages: "+str(msgs))

ns = rospy.get_param('parameter_namespace')
for t in tests:
p_name = roslib.names.ns_join(ns, t)
value = rospy.get_param(p_name, t)
msg = getattr(self, "%s_msg"%(t))
print "get param: %s"%(p_name)
print "param value: %s"%(value)
print "msg value: %s"%(msg)
print("get param: %s"%(p_name))
print("param value: %s"%(value))
print("msg value: %s"%(msg))
if t == 'composite':
print "value", p_name, value
print("value", p_name, value)
m = Composite(CompositeA(**value['a']), CompositeB(**value['b']))
self.assertAlmostEquals(m.a.x, msg.a.x)
self.assertAlmostEquals(m.a.y, msg.a.y)
self.assertAlmostEquals(m.a.z, msg.a.z)
self.assertAlmostEquals(m.a.w, msg.a.w)
self.assertAlmostEquals(m.b.x, msg.b.x)
self.assertAlmostEquals(m.b.y, msg.b.y)
self.assertAlmostEquals(m.b.z, msg.b.z)
self.assertAlmostEqual(m.a.x, msg.a.x)
self.assertAlmostEqual(m.a.y, msg.a.y)
self.assertAlmostEqual(m.a.z, msg.a.z)
self.assertAlmostEqual(m.a.w, msg.a.w)
self.assertAlmostEqual(m.b.x, msg.b.x)
self.assertAlmostEqual(m.b.y, msg.b.y)
self.assertAlmostEqual(m.b.z, msg.b.z)
elif t == 'list':
self.assertEquals(list(value), list(msg.int32_array))
self.assertEqual(list(value), list(msg.int32_array))
elif t == 'float':
self.assertAlmostEquals(value, msg.data)
self.assertAlmostEqual(value, msg.data)
else:
self.assertEquals(value, msg.data)
self.assertEqual(value, msg.data)

def test_set_parameter(self):
# make sure client copied each parameter correct
Expand All @@ -137,23 +137,23 @@ def test_set_parameter(self):
source_value = rospy.get_param(source_name)
target_value = rospy.get_param(target_name)
if t != 'float':
self.assertEquals(source_value, target_value)
self.assertEqual(source_value, target_value)
else:
self.assertAlmostEquals(source_value, target_value)
self.assertAlmostEqual(source_value, target_value)

def test_tilde_parameter(self):
timeout_t = time.time() + 20.
print "waiting for 20 seconds for client to load"
print("waiting for 20 seconds for client to load")
while self.tilde_msg is None and \
not rospy.is_shutdown() and \
timeout_t > time.time():
time.sleep(0.2)

self.failIf(timeout_t < time.time(), "timeout exceeded")
self.failIf(rospy.is_shutdown(), "node shutdown")
self.failIf(self.tilde_msg is None)
self.assertFalse(timeout_t < time.time(), "timeout exceeded")
self.assertFalse(rospy.is_shutdown(), "node shutdown")
self.assertFalse(self.tilde_msg is None)

self.assertEquals(rospy.get_param('param_client/tilde'), self.tilde_msg.data)
self.assertEqual(rospy.get_param('param_client/tilde'), self.tilde_msg.data)

if __name__ == '__main__':
import rostest
Expand Down
16 changes: 8 additions & 8 deletions rosjava/test/test_string_passthrough.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class TestStringPassthrough(unittest.TestCase):

def setUp(self):
rospy.init_node(NAME)
self.nodes = ['/node%s'%(i) for i in xrange(10)]
self.nodes = ['/node%s'%(i) for i in range(10)]
self.nodes_set = set(self.nodes)

# keep track of nodes that have done callbacks
Expand All @@ -70,31 +70,31 @@ def cb_from_test(self, msg):
def test_string_passthrough(self):
# 20 seconds to validate fixture
timeout_t = time.time() + 20.
print "waiting for 20 seconds for fixture to verify"
print("waiting for 20 seconds for fixture to verify")
while not self.fixture_nodes_cb == self.nodes_set and \
not rospy.is_shutdown() and \
timeout_t > time.time():
time.sleep(0.2)

self.failIf(timeout_t < time.time(), "timeout exceeded")
self.failIf(rospy.is_shutdown(), "node shutdown")
self.assertEquals(self.nodes_set, self.fixture_nodes_cb, "fixture did not validate: %s vs %s"%(self.nodes_set, self.fixture_nodes_cb))
self.assertFalse(timeout_t < time.time(), "timeout exceeded")
self.assertFalse(rospy.is_shutdown(), "node shutdown")
self.assertEqual(self.nodes_set, self.fixture_nodes_cb, "fixture did not validate: %s vs %s"%(self.nodes_set, self.fixture_nodes_cb))

# another 20 seconds to validate client
timeout_t = time.time() + 20.
print "waiting for 20 seconds for client to verify"
print("waiting for 20 seconds for client to verify")
while not self.test_nodes_cb == self.nodes_set and \
not rospy.is_shutdown() and \
timeout_t > time.time():
time.sleep(0.2)

self.assertEquals(self.nodes_set, self.test_nodes_cb, "passthrough did not pass along all message")
self.assertEqual(self.nodes_set, self.test_nodes_cb, "passthrough did not pass along all message")

# Create a new Publisher here. This will validate publisherUpdate()
pub = rospy.Publisher('string_in', String)
msg = 'test_publisherUpdate'
timeout_t = time.time() + 20.
print "waiting for 20 seconds for client to verify"
print("waiting for 20 seconds for client to verify")
while not msg in self.nodes_set and \
not rospy.is_shutdown() and \
timeout_t > time.time():
Expand Down
22 changes: 11 additions & 11 deletions rosjava/test/test_testheader_passthrough.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,32 +67,32 @@ def cb_from_test(self, msg):
def test_testheader_passthrough(self):
# 20 seconds to validate fixture
timeout_t = time.time() + 20.
print "waiting for 20 seconds for fixture to verify"
print("waiting for 20 seconds for fixture to verify")
while self.fixture_curr is None and \
not rospy.is_shutdown() and \
timeout_t > time.time():
time.sleep(0.2)

self.failIf(timeout_t < time.time(), "timeout exceeded")
self.failIf(rospy.is_shutdown(), "node shutdown")
self.failIf(self.fixture_curr is None, "no data from fixture")
self.assertEquals('/node0', self.fixture_curr.caller_id)
self.assertEquals('', self.fixture_curr.orig_caller_id)
self.assertFalse(timeout_t < time.time(), "timeout exceeded")
self.assertFalse(rospy.is_shutdown(), "node shutdown")
self.assertFalse(self.fixture_curr is None, "no data from fixture")
self.assertEqual('/node0', self.fixture_curr.caller_id)
self.assertEqual('', self.fixture_curr.orig_caller_id)

# another 20 seconds to validate client
timeout_t = time.time() + 20.
print "waiting for 20 seconds for client to verify"
print("waiting for 20 seconds for client to verify")
while self.test_curr is None and \
not rospy.is_shutdown() and \
timeout_t > time.time():
time.sleep(0.2)

self.failIf(self.test_curr is None, "no data from test")
self.assertEquals('/rosjava_node', self.test_curr.caller_id)
self.assertEquals('/node0', self.test_curr.orig_caller_id)
self.assertFalse(self.test_curr is None, "no data from test")
self.assertEqual('/rosjava_node', self.test_curr.caller_id)
self.assertEqual('/node0', self.test_curr.orig_caller_id)
t = self.test_curr.header.stamp.to_sec()
# be really generous here, just need to be in the ballpark.
self.assert_(abs(time.time() - t) < 60.)
self.assertTrue(abs(time.time() - t) < 60.)

if __name__ == '__main__':
import rostest
Expand Down
6 changes: 3 additions & 3 deletions rosjava_benchmarks/scripts/pubsub_benchmark.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python
#
# Copyright (C) 2012 Google Inc.
#
Expand Down Expand Up @@ -32,7 +32,7 @@ def __init__(self):

def callback(self, _):
with self.lock:
self.count.next()
next(self.count)

def run(self):
tf_publisher = rospy.Publisher('tf', tf_msgs.tfMessage)
Expand All @@ -41,7 +41,7 @@ def run(self):
while not rospy.is_shutdown():
tf_publisher.publish(tf_msgs.tfMessage())
if (rospy.Time.now() - self.time) > rospy.Duration(5):
status_publisher.publish(std_msgs.String('%.2f Hz' % (self.count.next() / 5.0)))
status_publisher.publish(std_msgs.String('%.2f Hz' % (next(self.count) / 5.0)))
with self.lock:
self.count = itertools.count()
self.time = rospy.Time.now()
Expand Down
8 changes: 4 additions & 4 deletions rosjava_test/scripts/serialized_message.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python
#
# Copyright (C) 2012 Google Inc.
#
Expand All @@ -23,15 +23,15 @@

__author__ = '[email protected] (Damon Kohler)'

import StringIO
import io

import roslib; roslib.load_manifest('rosjava_test')
import rospy

import nav_msgs.msg as nav_msgs

message = nav_msgs.Odometry()
buf = StringIO.StringIO()
buf = io.StringIO()
message.serialize(buf)
print ''.join('0x%02x,' % ord(c) for c in buf.getvalue())[:-1]
print(''.join('0x%02x,' % ord(c) for c in buf.getvalue())[:-1])

0 comments on commit c14cc88

Please sign in to comment.