Exemplo n.º 1
0
        // Update is called once per frame
        void Update()
        {
            //get 2d head orientation
            rotation = headSet.centerEyeAnchor.rotation;
            //get euler angles from quaternion
            Vector3 eulerRotation = rotation.eulerAngles;

            if (eulerRotation.y < 270.0f && eulerRotation.y > 180.0f)
            {
                eulerRotation.y = 271.0f;
            }
            if (eulerRotation.y < 180.0f && eulerRotation.y > 90.0f)
            {
                eulerRotation.y = 89.0f;
            }
            if (eulerRotation.x < 270.0f && eulerRotation.x > 180.0f)
            {
                eulerRotation.x = 271.0f;
            }
            if (eulerRotation.x < 180.0f && eulerRotation.x > 900.0f)
            {
                eulerRotation.x = 89.0f;
            }
            if (OVRInput.Get(OVRInput.RawButton.B))
            {
                if (eulerRotation.y <= 90.0f && eulerRotation.x <= 90.0f)
                {
                    XAngle = eulerRotation.x * Mathf.Deg2Rad;
                    YAngle = -eulerRotation.y * Mathf.Deg2Rad;
                    float[] new_joint_angles = { YAngle, XAngle };
                    ExecuteAngle(joint_names, new_joint_angles);
                }
                if (eulerRotation.y >= 270.0f && eulerRotation.x >= 270.0f)
                {
                    XAngle = -(360.0f - eulerRotation.x) * Mathf.Deg2Rad;
                    YAngle = (360.0f - eulerRotation.y) * Mathf.Deg2Rad;
                    float[] new_joint_angles = { YAngle, XAngle };
                    ExecuteAngle(joint_names, new_joint_angles);
                }
                if (eulerRotation.y <= 90.0f && eulerRotation.x >= 270.0f)
                {
                    XAngle = -(360.0f - eulerRotation.x) * Mathf.Deg2Rad;
                    YAngle = -eulerRotation.y * Mathf.Deg2Rad;
                    float[] new_joint_angles = { YAngle, XAngle };
                    ExecuteAngle(joint_names, new_joint_angles);
                }
                if (eulerRotation.y >= 270.0f && eulerRotation.x <= 90.0f)
                {
                    XAngle = eulerRotation.x * Mathf.Deg2Rad;
                    YAngle = (360.0f - eulerRotation.y) * Mathf.Deg2Rad;
                    float[] new_joint_angles = { YAngle, XAngle };
                    ExecuteAngle(joint_names, new_joint_angles);
                }
                else
                {
                    print("ENTERED IN ELSE, THE ANGLES ARE X: " + XAngle + " EULER X: " + eulerRotation.x + " Y: " + YAngle + " EULER Y: " + eulerRotation.y + "\n");
                }
            }
            status   = jointAnglesWithSpeedActionClient.GetStatusString();
            feedback = jointAnglesWithSpeedActionClient.GetFeedbackString();
            result   = jointAnglesWithSpeedActionClient.GetResultString();
        }
Exemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     status   = jointAnglesWithSpeedActionClient.GetStatusString();
     feedback = jointAnglesWithSpeedActionClient.GetFeedbackString();
     result   = jointAnglesWithSpeedActionClient.GetResultString();
 }