Exemplo n.º 1
0
    private void FixedUpdate()
    {
        Frame frame = controller.Frame();

        // Check if hands are detected by the leap motion
        if (frame.Hands.Count >= 1)
        {
            List <Hand> hands     = frame.Hands;
            Hand        firstHand = hands[0];

            // fetch values from leap motion and apply low pass filter
            float mapedLift = MapInterval(firstHand.PalmPosition.y, 60, 260, -20F, 20F);

            // check if the hand is a fist
            IsDropping(firstHand.GrabAngle);

            // apply drone commands
            aircraft.Lift(mapedLift);
            aircraft.Pitch(-firstHand.Direction.Pitch * 0.6F);
            aircraft.Yaw(firstHand.Direction.Yaw * 1.5F);
            aircraft.Roll(-firstHand.PalmNormal.Roll);
        }
        else
        {
            //TODO: display hand symbol after ca. 3 seconds
            //Debug.Log("[!] No hands recognized");
        }
    }