Exemple #1
0
            /// <summary>
            /// Gets the latest pose estimation from VIO. If run in Unity Editor Simulates TangoFlyCam Experience.
            /// </summary>
            /// <param name="vioHandler"> Pointer to application context.</param>
            /// <param name="vioStatus"> Data filled out by Tango API.</param>
            /// <returns> Common.RetCodes.kCAPISuccess if successful.</returns>
            public static int VIOGetLatestPose(System.IntPtr vioHandler, ref VIOStatus vioStatus)
            {
                Vector3    position = vioStatus.translation;
                Quaternion rotation;
                Vector3    directionForward, directionRight, directionUp;
                float      rotationX;
                float      rotationY;

                rotationX = vioStatus.rotation.eulerAngles.x - Input.GetAxis("Mouse Y") * MOUSE_LOOK_SENSITIVITY * Time.deltaTime;
                rotationY = vioStatus.rotation.eulerAngles.y + Input.GetAxis("Mouse X") * MOUSE_LOOK_SENSITIVITY * Time.deltaTime;
                Vector3 eulerAngles = new Vector3(rotationX, rotationY, 0);

                vioStatus.rotation.eulerAngles = eulerAngles;
                rotation = Quaternion.Euler(eulerAngles);

                directionForward = rotation * Vector3.forward;
                directionRight   = rotation * Vector3.right;
                directionUp      = rotation * Vector3.up;
                position         = position + Input.GetAxis("Vertical") * directionForward * TRANSLATION_SPEED * Time.deltaTime;
                position         = position + Input.GetAxis("Horizontal") * directionRight * TRANSLATION_SPEED * Time.deltaTime;
                if (Input.GetKey(KeyCode.R)) // Go Up
                {
                    position += directionUp * TRANSLATION_SPEED * Time.deltaTime;
                }
                if (Input.GetKey(KeyCode.F))  // Go Down
                {
                    position -= directionUp * TRANSLATION_SPEED * Time.deltaTime;
                }
                vioStatus.translation = position;
                return((int)Tango.Common.RetCodes.kCAPISuccess);
            }
Exemple #2
0
 /// <summary>
 /// Gets the pose estimation closest to the timestamp
 /// given to the function.
 /// </summary>
 /// <param name="vioHandle"> Pointer to the application context.</param>
 /// <param name="timestamp"> Time that will be used to recover a pose estimation.</param>
 /// <param name="maxDelta"> Max difference between the given timestamp and returned
 /// pose estimation.</param>
 /// <param name="status"> Data to be filled out by Tango API.</param>
 /// <returns> Common.RetCodes.kCAPISuccess if successful.</returns>
 public static int VIOGetClosestPoseToTime(System.IntPtr vioHandle,
                                           double timestamp,
                                           double maxDelta,
                                           ref VIOStatus status)
 {
     return((int)Tango.Common.RetCodes.kCAPISuccess);
 }
Exemple #3
0
        /// <summary>
        /// Get latest vioStatus.
        /// </summary>
        /// <param name="vioStatus">Reference to vioStatus,
        /// need caller to allocate.</param>
        /// <returns>If the function call succeed.</returns>
        public static bool GetLatestPose(ref VIOStatus vioStatus)
        {
            if (!m_isInit)
            {
                DebugLogger.GetInstance.WriteToLog(DebugLogger.EDebugLevel.DEBUG_WARN, "VIOProvider.GetLatestPose : Not Initialized!");
                return(false);
            }

            Common.RetCodes ret_code =
                (Common.RetCodes)TangoVIOAPI.VIOGetLatestPose(
                    TangoApplication.Instance.Handle, ref vioStatus);
            if (ret_code != Common.RetCodes.kCAPISuccess)
            {
                Debug.Log("get latest vio pose failed:" + ret_code);
                return(false);
            }

            // Convert the estimator format to unity format
            Utilities.TangoUtilAPI.UtilConvertPoseToUnityFormat(
                ref vioStatus.rotation, ref vioStatus.translation,
                ref vioStatus.rotation, ref vioStatus.translation);
            return(true);
        }
Exemple #4
0
 public static extern int VIOGetClosestPoseToTime(
     System.IntPtr vioHandle, double timestamp,
     double maxDelta, ref VIOStatus status);
Exemple #5
0
 public static extern int VIOGetLatestPose(System.IntPtr vioHandle, ref VIOStatus vioStatus);