Beispiel #1
0
        /// <summary>
        /// Init VIO service.
        /// </summary>
        /// <param name="operationMode">Operation Mode.</param>
        /// <param name="sparseMapPath">Sparse map path.
        /// If it's null, the application will run in loop closure mode.</param>
        public static void Init(Mode operationMode, string sparseMapPath)
        {
            int withSparseMapping =
                (operationMode == Mode.VisualIntertialNavigationAndMapping) ? 1 : 0;

            Common.RetCodes retCode = (Common.RetCodes)TangoVIOAPI.VIOInitialize(TangoApplication.Instance.Handle,
                                                                                 withSparseMapping,
                                                                                 sparseMapPath);
            if (retCode != Common.RetCodes.kCAPISuccess)
            {
                Debug.Log("VIO initialization failed: " + retCode);
            }
            else
            {
                m_isInit = true;
            }
        }
Beispiel #2
0
        void Start()
        {
                        #if (UNITY_EDITOR)
            DebugLogger.WriteToLog(DebugLogger.EDebugLevel.DEBUG_INFO, typeof(Camera).Name + " : Adding input controls to run in editor.");
            gameObject.AddComponent <TangoFlyCam>();
                        #elif (UNITY_STANDALONE_OSX || UNITY_IPHONE || UNITY_ANDROID)
                        #else
                        #error platform is not supported
                        #endif

            Synchronizer sync = gameObject.GetComponent <Synchronizer>();
            int          withSparseMapping = (operationMode == Mode.VisualIntertialNavigaitionAndMapping)?1:0;
            mVIOHandler = TangoVIOAPI.VIOInitialize(sync.handler, withSparseMapping, sparseMapPath);
            if (mVIOHandler == System.IntPtr.Zero)
            {
                ErrorHandler.instance.presentErrorMessage("VIO initialization failed");
            }
        }
Beispiel #3
0
        /// <summary>
        /// Save current recorded sparse map to file.
        /// </summary>
        /// <param name="sparseMapPath">Absolute location on phone.</param>
        /// <returns>If the function call succeed.</returns>
        public static bool SaveSparseMap(string sparseMapPath)
        {
            if (!m_isInit)
            {
                DebugLogger.GetInstance.WriteToLog(DebugLogger.EDebugLevel.DEBUG_WARN,
                                                   "VIOProvider.SaveSparseMap : Not Initialized!");
                return(false);
            }

            Common.RetCodes ret_code =
                (Common.RetCodes)TangoVIOAPI.VIOSaveSparseMap(
                    TangoApplication.Instance.Handle, sparseMapPath);
            if (ret_code != Common.RetCodes.kCAPISuccess)
            {
                ErrorHandler.instance.presentErrorMessage(
                    "Application initialization failed" + ret_code);
                return(false);
            }
            return(true);
        }
Beispiel #4
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);
        }
Beispiel #5
0
        void Update()
        {
            Quaternion rotation = Quaternion.identity;
            Vector3    position = Vector3.zero;

            #if (UNITY_EDITOR)
            DebugLogger.WriteToLog(DebugLogger.EDebugLevel.DEBUG_ERROR, "Navigator.Update() : Updating TangoFlyCam");
            gameObject.GetComponent <TangoFlyCam>().GetRawTransformData(ref position, ref rotation);
                        #elif (UNITY_STANDALONE_OSX || UNITY_IPHONE || UNITY_ANDROID)
            if (mVIOHandler == System.IntPtr.Zero)
            {
                DebugLogger.WriteToLog(DebugLogger.EDebugLevel.DEBUG_ERROR, "Navigator.Update() : VIO Handler is not initialized");
                return;
            }

            float [] unityFormatRotation = new float [4];
            float [] unityFormatPosition = new float [3];
            if ((Common.RetCodes)TangoVIOAPI.VIOGetCameraPoseUnity(mVIOHandler, unityFormatRotation, unityFormatPosition) == Common.RetCodes.kCAPISuccess)
            {
                //we don't have IMU to narrow field of view camera calibration, so lets + 10cm to camera position to compencate that
                //until we have calibrarion.
                position = new Vector3((float)unityFormatPosition [0], (float)unityFormatPosition [1], (float)unityFormatPosition [2]);
                //position = new Vector3(0f, 0f, 0f) ;
                rotation = new Quaternion((float)unityFormatRotation [0], (float)unityFormatRotation [1], (float)unityFormatRotation [2], (float)unityFormatRotation [3]);
            }
            else
            {
                //DebugLogger.WriteToLog(DebugLogger.EDebugLevel.DEBUG_INFO, typeof(Camera).Name + " :Pose is not available");
            }
            #else
            #error platform is not supported
            #endif


            gameObject.transform.position = position;
            gameObject.transform.rotation = rotation;
        }
Beispiel #6
0
 /// <summary>
 /// Shut down VIO service.
 /// </summary>
 public static void ShutDown()
 {
     m_isInit = false;
     TangoVIOAPI.VIOShutdown(TangoApplication.Instance.Handle);
 }
Beispiel #7
0
 /// <summary>
 /// Reset VIO tracking.
 /// </summary>
 public static void Reset()
 {
     TangoVIOAPI.VIOReset(TangoApplication.Instance.Handle);
 }
Beispiel #8
0
 /// <summary>
 /// Set VIO Auto reset flag. If true, VIO will start to recover from a
 /// fatal tracking failure immediately.
 /// </summary>
 /// <param name="autoReset">Enable auto reset.</param>
 public static void SetAutoReset(bool autoReset)
 {
     TangoVIOAPI.VIOSetAutoReset(autoReset ? 1 : 0);
 }
Beispiel #9
0
 public bool SaveSparseMap(string sparseMapPath)
 {
     return((Common.RetCodes)TangoVIOAPI.VIOSaveSparseMap(mVIOHandler, sparseMapPath) == Common.RetCodes.kCAPISuccess);
 }