Beispiel #1
0
        /// <summary>
        /// Saves an area description to device based on the UUID object contained in the adfID object holder.
        /// </summary>
        /// <returns><c>Common.ErrorType.TANGO_SUCCESS</c> if saving was successfull.</returns>
        /// <param name="adfID">The UUIDUnityHolder object that contains the desired UUID object.</param>
        public static int SaveAreaDescription(UUIDUnityHolder adfUnityHolder)
        {
            // is learning mode on
            // are we localized?

            if (adfUnityHolder == null)
            {
                Debug.Log(CLASS_NAME + ".SaveAreaDescription() Could not save area description. UUID Holder object specified is not initialized");
                return(Common.ErrorType.TANGO_ERROR);
            }
            IntPtr idData      = Marshal.AllocHGlobal(Common.UUID_LENGTH);
            int    returnValue = PoseProviderAPI.TangoService_saveAreaDescription(idData);

            if (returnValue != Common.ErrorType.TANGO_SUCCESS)
            {
                Debug.Log(CLASS_NAME + ".SaveAreaDescripton() Could not save area description with ID: " + adfUnityHolder.GetStringDataUUID());
            }
            else
            {
                byte[] tempDataBuffer = new byte[Common.UUID_LENGTH];
                Marshal.Copy(idData, tempDataBuffer, 0, Common.UUID_LENGTH);
                adfUnityHolder.SetDataUUID(tempDataBuffer);
            }
            return(returnValue);
        }
Beispiel #2
0
        /// <summary>
        /// Takes care of importing a adf file from the specified path. Important: make sure that the filepath
        /// does not contain ADF files already present on device, otherwise it will return an error, as duplicates
        /// can't be imported.
        /// </summary>
        /// <returns><c>Common.ErrorType.TANGO_SUCCESS</c> if the UUID was imported successfully.</returns>
        /// <param name="adfID">The <c>UUIDUnityHolder</c> object that will contain information about the retrieved ADF.</param>
        /// <param name="filePath">File path containing the ADF we want to export.</param>
        public static int ImportAreaDescriptionFromFile(UUIDUnityHolder adfID, string filePath)
        {
            if (adfID == null)
            {
                DebugLogger.GetInstance.WriteToLog(DebugLogger.EDebugLevel.DEBUG_ERROR,
                                                   CLASS_NAME +
                                                   ".ImportAreaDescription() Could not  import area description. UUID Holder object specified is not initialized");
                return(Common.ErrorType.TANGO_ERROR);
            }
            IntPtr uuidHolder  = Marshal.AllocHGlobal(Common.UUID_LENGTH);
            int    returnValue = PoseProviderAPI.TangoService_importAreaDescription(filePath, uuidHolder);

            if (returnValue != Common.ErrorType.TANGO_SUCCESS)
            {
                DebugLogger.GetInstance.WriteToLog(DebugLogger.EDebugLevel.DEBUG_ERROR,
                                                   CLASS_NAME + ".ImportAreaDescription() Could not import area description at path: " + filePath);
            }
            else
            {
                byte[] tempDataBuffer = new byte[Common.UUID_LENGTH];
                Marshal.Copy(uuidHolder, tempDataBuffer, 0, Common.UUID_LENGTH);
                adfID.SetDataUUID(tempDataBuffer);
            }
            return(returnValue);
        }
 /// DEPRECATED: Use the AreaDescription class to work with area descriptions.
 /// <summary>
 /// Import an area description from a file path to the default area storage location. 
 /// 
 /// Please call ImportAreaDescriptionFromFile(string filePath) instead.
 /// The new area description will get a new ID, which will be stored in adfID.
 /// </summary>
 /// <returns><c>Common.ErrorType.TANGO_SUCCESS</c> if the UUID was imported successfully.</returns>
 /// <param name="adfID">Upon successful return, this will have the new ID.</param>
 /// <param name="filePath">File path of the area descrption to be imported.</param>
 public static int ImportAreaDescriptionFromFile(UUIDUnityHolder adfID, string filePath)
 {
     if (adfID == null)
     {
         Debug.Log(CLASS_NAME + ".ImportAreaDescription() Could not  import area description. UUID Holder object specified is not initialized");
         return Common.ErrorType.TANGO_ERROR;
     }
     IntPtr uuidHolder = Marshal.AllocHGlobal(Common.UUID_LENGTH);
     int returnValue = PoseProviderAPI.TangoService_importAreaDescription(filePath, uuidHolder);
     if (returnValue != Common.ErrorType.TANGO_SUCCESS)
     {
         Debug.Log(CLASS_NAME + ".ImportAreaDescription() Could not import area description at path: " + filePath);
     }
     else
     {
         byte[] tempDataBuffer = new byte[Common.UUID_LENGTH];
         Marshal.Copy(uuidHolder, tempDataBuffer, 0, Common.UUID_LENGTH);
         adfID.SetDataUUID(tempDataBuffer);
     }
     return returnValue;
 }
 /// DEPRECATED: Use the AreaDescription class to work with area descriptions.
 /// <summary>
 /// Saves the area description, returning the unique ID associated with the saved map.
 /// 
 /// You can only save an area description while connected to the Tango Service and if you have enabled Area
 /// Learning mode. If you loaded an ADF before connecting, then calling this method appends any new learned
 /// areas to that ADF and returns the same UUID. If you did not load an ADF, this method creates a new ADF and
 /// a new UUID for that ADF.
 /// </summary>
 /// <returns>
 /// Returns TANGO_SUCCESS on success, and TANGO_ERROR if a failure occurred when saving, or if the service
 /// needs to be initialized, or TANGO_INVALID if uuid is NULL, or of incorrect length, or if Area Learning Mode
 /// was not set (see logcat for details).
 /// </returns>
 /// <param name="adfUnityHolder">Upon saving, the TangoUUID to refer to this ADF is returned here.</param>
 public static int SaveAreaDescription(UUIDUnityHolder adfUnityHolder)
 {
     if (adfUnityHolder == null)
     {
         Debug.Log(CLASS_NAME + ".SaveAreaDescription() Could not save area description. UUID Holder object specified is not initialized");
         return Common.ErrorType.TANGO_ERROR;
     }
     IntPtr idData = Marshal.AllocHGlobal(Common.UUID_LENGTH);
     int returnValue = PoseProviderAPI.TangoService_saveAreaDescription(idData);
     if (returnValue != Common.ErrorType.TANGO_SUCCESS)
     {
         Debug.Log(CLASS_NAME + ".SaveAreaDescripton() Could not save area description with ID: " + adfUnityHolder.GetStringDataUUID());
     }
     else
     {
         byte[] tempDataBuffer = new byte[Common.UUID_LENGTH];
         Marshal.Copy(idData, tempDataBuffer, 0, Common.UUID_LENGTH);
         adfUnityHolder.SetDataUUID(tempDataBuffer);
     }
     return returnValue;
 }