How do I detect that localisation has occured?

与世无争的帅哥 提交于 2019-12-25 03:07:40

问题


When utilising a Tango what would I use, callbacks or otherwise to detect when the devise has localised to a previously loaded ADF?

This is mainly for UI purposes in conjunction with Tango UX, telling a user to walk around an environment.


回答1:


Localization may be detected when your TangoPoseData with a frame of ADF comes back valid.

Look at the Tango Java examples of AreaLearningActivity with this simplified logic:

//tell tango to provide pose for ADF
ArrayList<TangoCoordinateFramePair> framePairs = new ArrayList<TangoCoordinateFramePair>();
framePairs.add(new TangoCoordinateFramePair(
        TangoPoseData.COORDINATE_FRAME_AREA_DESCRIPTION,
        TangoPoseData.COORDINATE_FRAME_DEVICE));

//register a listener for the frames chosen
mTango.connectListener(framePairs, new OnTangoUpdateListener() {

  //listens for updates from tango pose
  public void onPoseAvailable(TangoPoseData pose) {

    //base frame of ADF provides coordinates relative to the origin of the ADF
    if (pose.baseFrame == TangoPoseData.COORDINATE_FRAME_AREA_DESCRIPTION
        && pose.targetFrame == TangoPoseData.COORDINATE_FRAME_DEVICE)

      //if the status is valid then localization has succeeded
      if(pose.statusCode == TangoPoseData.POSE_VALID){
        Log.i(TAG,"Successfully localized with ADF");
      }
    }
  }

Your config must indicate which ADF is of interest:

 config.putString(TangoConfig.KEY_STRING_AREADESCRIPTION,adfId);

This process is not easily observed from the code, but I discovered it debugging the AreaLearningActivity example. The Java API would benefit from a higher level of abstraction making the common scenario you requested more obvious and easier to use:

TangoLocalizer.builder().register(myListener).adfId(myAdfId).build();



回答2:


In Unity3D, you can use pose.status_code inside OnTangoPoseAvailable(TangoPoseData) for checking the checking the status (VALID/INVALID) of pose w.r.t. the coordinate frame pair defined. For Device Localization you need to set targetFrame as TANGO_COORDINATE_FRAME_DEVICE AND baseFrame as TANGO_COORDINATE_FRAME_AREA_DESCRIPTION

public void OnTangoPoseAvailable(TangoPoseData pose)
{
    // Define the frame-pair 
    if (pose.framePair.baseFrame == TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_AREA_DESCRIPTION
        && pose.framePair.targetFrame == TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_DEVICE)
    {

    // Check if the pose is VALID or INVALID
        if (pose.status_code == TangoEnums.TangoPoseStatusType.TANGO_POSE_VALID)
        {
            ////......if pose is VALID
        }
        else 
        {
            ////......if pose is INVALID
        }
    }
}

You also need to load the ADF using m_tangoApplication.Startup (m_selectedADF); as well.



来源:https://stackoverflow.com/questions/32403034/how-do-i-detect-that-localisation-has-occured

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!