I work with the Google Tango right now and so far everything worked fine, but I stumbled upon a few strange things.
There is a class ScenePoseCalculator in the Tango Examples. And there is a method "toOpenGlCameraPose". When using this, the OpenGL camera however is not set up correctly. When I move forward, the camera moves backwards. Left and right are swapped as well.
But the most difficult thing is to transform the PointCloud correctly. I do the following:
Create an Vector3-Array:
Vector3f [] vertices = new Vector3f[mPointCloud.getGeometry().getVertices().capacity()];
for(int i=0; i<mPointCloud.getGeometry().getVertices().capacity(); i++) {
vertices[i] = new Vector3f(
mPointCloud.getGeometry().getVertices().get(i*3),
mPointCloud.getGeometry().getVertices().get(i*3+1),
mPointCloud.getGeometry().getVertices().get(i*3+2));
}
In the PointCloud Callback of the TangoListener I do:
private void updateXYZIJ() {
try {
if(pcm.getLatestXyzIj().xyzCount<10) return;
TangoCoordinateFramePair fp = new TangoCoordinateFramePair(
TangoPoseData.COORDINATE_FRAME_START_OF_SERVICE,
TangoPoseData.COORDINATE_FRAME_DEVICE);
TangoXyzIjData xyzIj = pcm.getLatestXyzIj();
depthArray = new float[xyzIj.xyzCount * 3];
xyzIj.xyz.get(depthArray);
com.projecttango.rajawali.Pose p =
ScenePoseCalculator.toDepthCameraOpenGlPose(
tangoProvider.getTango().getPoseAtTime(
xyzIj.timestamp, fp), this.setupExtrinsics());
Pose cloudPose = this.rajawaliPoseToJMEPoseCLOUD(p);
currentPointCloudData = new PointCloudUpdate(
new Date(),
depthArray,
xyzIj.xyzCount,
xyzIj.ijRows,
xyzIj.ijCols,
0,
cloudPose,
null
);
// inform listeners
for (PointCloudListener listener : this.pointsListeners) {
listener.acceptMessage(tangoProvider, this.currentPointCloudData);
}
} catch (Exception e) {
e.printStackTrace();
}
}
To transform the PointCloud I do:
this.transformation = new Matrix4f();
this.transformation.setRotationQuaternion(
this.referencePose.orientation);
this.transformation.setTranslation(this.referencePose.place);
absVertices = new Vector3f[vertices.length];
for(int i=0; i<vertices.length; i++) {
// Create new Vertex
absVertices[i]=new Vector3f(
vertices[i].x,
vertices[i].y,
vertices[i].z
);
Vector3f v = absVertices[i];
transformation.rotateVect(absVertices[i]);
transformation.translateVect(absVertices[i]);
}
But whatever I do. I've tried everything. But it won't look right. The PointClouds get stapled over each other or look like they where placed without any sense.
Hope someone knows more...