def test_servicetest2_types(): if sys.version_info < (3, 0): return node = RR.RobotRaconteurNode() node.Init() try: node.RegisterServiceTypesFromFiles([ "com.robotraconteur.testing.TestService2", "com.robotraconteur.testing.TestService1", "com.robotraconteur.testing.TestService3", "com.robotraconteur.testing.TestService5" ]) s1 = ServiceTest2_fill_teststruct3(node, 1000, None) s1_m = PackMessageElement( s1, 'com.robotraconteur.testing.TestService3.teststruct3', node=node) s1_m.UpdateData() s1_1 = UnpackMessageElement( s1_m, 'com.robotraconteur.testing.TestService3.teststruct3', node=node) ServiceTest2_verify_teststruct3(s1_1, 1000) finally: node.Shutdown()
def _do_array_test(to_rr, from_rr, shape, rr_type, node, f=None): if f is None: f = lambda a: a arr = f(np.random.rand(*shape)) rr_val = to_rr(arr) rr_msg = PackMessageElement(rr_val, f"com.robotraconteur.geometry.{rr_type}", node=node) rr_msg.UpdateData() rr_val2 = UnpackMessageElement(rr_msg, node=node) arr2 = from_rr(rr_val2) np.testing.assert_almost_equal(arr, arr2)
def _do_transform_test_xyz_rpy(to_rr, from_rr, rr_type, node): xyz = np.random.rand(3) rpy = np.random.rand(3) rr_val = to_rr(xyz, rpy) rr_msg = PackMessageElement(rr_val, f"com.robotraconteur.geometry.{rr_type}", node=node) rr_msg.UpdateData() rr_val2 = UnpackMessageElement(rr_msg, node=node) xyz2, rpy2 = from_rr(rr_val2) np.testing.assert_almost_equal(xyz, xyz2) np.testing.assert_almost_equal(rpy, rpy2)
def _do_transform_test(to_rr, from_rr, rr_type, node): rox_transform = rox.Transform(rox.rpy2R(np.random.rand(3)), np.random.rand(3)) rr_val = to_rr(rox_transform) rr_msg = PackMessageElement(rr_val, f"com.robotraconteur.geometry.{rr_type}", node=node) rr_msg.UpdateData() rr_val2 = UnpackMessageElement(rr_msg, node=node) rox_transform2 = from_rr(rr_val2) np.testing.assert_almost_equal(rox_transform.R, rox_transform2.R) np.testing.assert_almost_equal(rox_transform.p, rox_transform2.p)
def _do_named_transform_test_xyz_rpy(to_rr, from_rr, rr_type, node): xyz = np.random.rand(3) rpy = np.random.rand(3) rr_val = to_rr(xyz, rpy, "parent_frame_id", "child_frame_id") rr_msg = PackMessageElement(rr_val, f"com.robotraconteur.geometry.{rr_type}", node=node) rr_msg.UpdateData() rr_val2 = UnpackMessageElement(rr_msg, node=node) xyz2, rpy2, parent_frame_id2, child_frame_id2 = from_rr(rr_val2) np.testing.assert_almost_equal(xyz, xyz2) np.testing.assert_almost_equal(rpy, rpy2) assert "parent_frame_id" == parent_frame_id2 assert "child_frame_id" == child_frame_id2
def _rr_varvalue_from_bytes(b, node): m = MessageElementFromBytes(b) return UnpackMessageElement(m, "varvalue", node=node)