Tanoda
GraspingAPITests.cs
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) Ultraleap, Inc. 2011-2020. *
3 * *
4 * Use subject to the terms of the Apache License 2.0 available at *
5 * http://www.apache.org/licenses/LICENSE-2.0, or another agreement *
6 * between Ultraleap and you, your company or other organization. *
7 ******************************************************************************/
8
9#if LEAP_TESTS
10using Leap.Unity.Query;
11using NUnit.Framework;
12using System.Collections;
13using UnityEngine;
14using UnityEngine.TestTools;
15
17
21 public class GraspingAPITests : InteractionEngineTestBase {
22
23 [UnityTest]
24 public IEnumerator CanTryGraspObject() {
25 yield return wait(beginningTestWait);
26
27 InitTest(GRASP_THROW_RIG, DEFAULT_STAGE);
28
29 // Move box0 out of position so it doesn't get grasped by the recording.
30 box0.transform.position += Vector3.forward * 0.50f;
31 box0.transform.localScale = box0.transform.localScale * 1.5f;
32
33 yield return wait(aBit);
34
35 // Play the grasp and throw recording.
36 recording.Play();
37 yield return wait(50);
38
39 recording.Pause();
40 yield return wait(5);
41
42 // Mid-grasp, teleport the box into a reasonable 'grasped' position.
43 Vector3 fingertipAvg = rightHand.leapHand.Fingers
44 .Query()
45 .Select(f => f.TipPosition.ToVector3())
46 .Fold((v0, v1) => v0 + v1)
47 / 5f;
48 box0.transform.position = fingertipAvg;
49 box0.rigidbody.position = fingertipAvg;
50
51 Assert.That(rightHand.TryGrasp(box0) == true);
52
53 yield return wait(endingTestWait);
54 }
55
56 }
57
58}
59#endif // LEAP_TESTS