Search code examples
androidgoogle-project-tangotango

Plane fitting with data from previous Tango session


I'm facing the following problem while developing Tango app and not sure whether I'm on the right track or not.

What I'm trying to achieve:

  1. User takes a picture. In the background the app saves to persistent the current point cloud and pose.
  2. The server is getting that image and doing some magic processing behind the scene and sends (x,y) coordinate back to the app(Async and unrelated to current Tango session).
  3. Restart the app, start a new tango session and show a 3d object at (x,y) using the persist copy of the point cloud and pose.

I expect that I'll be able to use these parameters - (x,y), point cloud and Pose in the following algorithm and get a Pose, which is a Rajawali object that RajawaliRenderer knows how to render.

tango initialization is accoring to the following coordinate frame:

TANGO_WORLD_BASE_COORDINATE_FRAME = new TangoCoordinateFramePair(
                TangoPoseData.COORDINATE_FRAME_AREA_DESCRIPTION,
                TangoPoseData.COORDINATE_FRAME_DEVICE
        );
  • Plan Fit using intersection point -

      private void convertByIntersectionPoint(float x, float y,
      TangoPointCloudData tangoPointCloudData, TangoPoseData devicePose,
      TangoPoseData colorTdepthPose) {
        if (tangoPointCloudData != null) {
    
            TangoSupport.IntersectionPointPlaneModelPair intersectionPointPlaneModelPair =
                    TangoSupport.fitPlaneModelNearPoint(tangoPointCloudData,
                            colorTdepthPose, x, y);
    
            if (devicePose.statusCode == TangoPoseData.POSE_VALID) {
                mRenderer.updateObjectPose(
                        intersectionPointPlaneModelPair.intersectionPoint,
                        intersectionPointPlaneModelPair.planeModel,
                        devicePose);
                } 
        } 
    }
    

It throws TangoErrorException on TangoSupport.fitPlaneModelNearPoint.

To my understanding the fitPlaneModelNearPoint method should do pure algorithm that doesn't rely on current Tango session but I cannot be sure because I don't have its implementation.

Any help'd be much appreciated.


Solution

  • Okay it was totally my mistake.

    There was a bug in serializing the point cloud. Gson library do not know how to deserialize into subclass and always construct into a parent class - which in this case creates corrupted data