000000000000000000000
000000000000000000000

Reputation: 1467

Project Tango won't relocalize

I am trying out Area Recognition using Area Learning with predefined ADF files using Project Tango in Unity3d. I use the script from this tutorial as the basis, but for some reason it won't relocalize.

using UnityEngine;
using System.Collections;
using Tango;

public class TestADFFile : MonoBehaviour, ITangoLifecycle
{
    private TangoApplication m_tangoApplication;
    public UnityEngine.UI.Text statusText;
    public string adfName;

    public void Start()
    {
        m_tangoApplication = FindObjectOfType<TangoApplication>();
        if (m_tangoApplication != null)
        {
            m_tangoApplication.Register(this);
            m_tangoApplication.RequestPermissions();
        }
    }

    public void OnTangoPermissions(bool permissionsGranted)
    {
        if (permissionsGranted)
        {
            if(AreaDescription.ImportFromFile(System.IO.Path.Combine(Application.streamingAssetsPath, "adfs/" + adfName))){
                 statusText.text = "success!";
            }
            else{
                statusText.text = "fail!";
            }
            AreaDescription[] list = AreaDescription.GetList();
            AreaDescription mostRecent = null;
            AreaDescription.Metadata mostRecentMetadata = null;
            if (list.Length > 0)
            {
                // Find and load the most recent Area Description
                mostRecent = list[0];
                mostRecentMetadata = mostRecent.GetMetadata();
                foreach (AreaDescription areaDescription in list)
                {
                    AreaDescription.Metadata metadata = areaDescription.GetMetadata();
                    if (metadata.m_dateTime > mostRecentMetadata.m_dateTime)
                    {
                        mostRecent = areaDescription;
                        mostRecentMetadata = metadata;
                    }
                }

                m_tangoApplication.Startup(mostRecent);
            }
            else
            {
                // No Area Descriptions available.
                Debug.Log("No area descriptions available.");
            }
        }
    }

    public void OnTangoServiceConnected()
    {
    }

    public void OnTangoServiceDisconnected()
    {
    }
}

The statusText is set to "success" so apparently the ADF is successfully loaded, right?

Upvotes: 1

Views: 321

Answers (2)

Konsti
Konsti

Reputation: 83

You're doing it right. Relocalization with area learning mode off works very quick. But relocalization with area learning mode on takes quite a while. You have to walk around up to 3-5 minutes until the relocalization works. Don't give up. I had the same problem. But in the end, it works!

Upvotes: 1

To&#241;o Gonzalez
To&#241;o Gonzalez

Reputation: 3

Is not an answer I think, but just a checklist of things I would check.

  1. Check that the ADF to relocalize is the right one, you may be loading an ADF from a different area.
  2. On the TangoManager component check if Enable Area Descriptions is set to true.
  3. Also check if the scene is set up correctly with all tango components required like: RelocalizingOverlay.cs, TangoApplication.cs

Also as a personal note I have noticed that ADF sometimes take quite a while to relocalized and sometimes they don't relocalize at all. I think the reasons are that the room has change in someway or the lighting is very different, by different I mean maybe the day you recorded that ADF was a very sunny day and the day you are trying to relocalize is cloudy.(Again this are just theories of mine, I got from my testing)

Upvotes: 0

Related Questions