title: my Project Tango AR App Object movement with the color camera movement doesn't work properly
body: <p>I want to place a cube somewhere in the room. The cube is static in the room and always at the same point. At the moment I can place a cube in the room but if I move the Tango Tablet it isn't in sync with the movement of the cube and I don't know how to sync my Tango Tablet movement and object movement. </p>
  
  <p>My thoughts were, if I move the Tango Tablet to the right my Cube moves to the left with same same "speed" as my Tango Tablet moves to the right. I tried this for all directions but as said before it is not very synced. </p>
  
  <p>An other issue I have is, how can the cube be static if I point with the camera to an other direction and the device is at same position? </p>
  
  <p>To be honest I started with OpenGL last week and I don't know all its function or if I do it the right way. </p>
  
  <p>I hope you understand my problem and can give me some hints. </p>
  
  <p>Here is the code I think is important to you to understand what I try to do: </p>
  
  <p>GLSurfaceView Renderer Class:</p>
  
  <pre><code>@Override
  public void onDrawFrame(GL10 gl) {
      //gl.glClearColor(0.0f, 0.5f, 0.5f, 1.0f);
      gl.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
  
      gl.glMatrixMode(GL11.GL_MODELVIEW);
      gl.glLoadIdentity();
  
      Quaternion q = new Quaternion(xr,yr,zr,wr);
      Vector3f vr = q.getEulerAngles();
  
  
  
      gl.glTranslatef(x, y, z);
      //gl.glTranslatef(0.0f, 0.0f, 0.0f);
      gl.glRotatef(vr.x, 1.0f, 0.0f, 0.0f);
      gl.glRotatef(vr.y, 0.0f, 1.0f, 0.0f);
      gl.glRotatef(vr.z, 0.0f, 0.0f, z);
      gl.glEnableClientState(GL11.GL_VERTEX_ARRAY);
      gl.glEnableClientState(GL11.GL_COLOR_ARRAY);
  
      mSquare.draw(gl);
  }
  </code></pre>
  
  <p>Here is the code from MainActivity:</p>
  
  <pre><code> private void startCameraPreview() {
      // Connect to color camera
      tangoCameraPreview.connectToTangoCamera(mTango,
              TangoCameraIntrinsics.TANGO_CAMERA_COLOR);
      final ArrayList&lt;TangoCoordinateFramePair&gt; framePairs = new ArrayList&lt;TangoCoordinateFramePair&gt;();
  
      framePairs.add(new TangoCoordinateFramePair(
              TangoPoseData.COORDINATE_FRAME_START_OF_SERVICE,
              TangoPoseData.COORDINATE_FRAME_DEVICE));
      mTango.connectListener(framePairs, new Tango.OnTangoUpdateListener() {
  
  @Override
          public void onPoseAvailable(TangoPoseData pose) {
              // We are not using OnPoseAvailable for this app
              tangoRenderer.getModelMatCalculator().updateModelMatrix(pose.getTranslationAsFloats(),pose.getRotationAsFloats());
              transolationData = pose.getTranslationAsFloats();
              data =  tangoRenderer.getModelMatCalculator().getTranslation();
              //transolationData = tangoRenderer.getModelMatCalculator().getTranslation();
  
              Quaternion q = new Quaternion((float)pose.rotation[0],(float)pose.rotation[1],(float)pose.rotation[2],(float)pose.rotation[3]);
              final Vector3f vr = q.getEulerAngles();
  
  
              runOnUiThread(new Runnable() {
                  @Override
                  public void run() {
                      if (transolationData != null) {
                          pose_text_view.setText("BU X: " + Math.round(transolationData[0] * 100f) / 100f + " Z: " + Math.round(transolationData[1] * 100f) / 100f + " Y: " + Math.round(transolationData[2] * 100f) / 100f + " length from transolationData: " + transolationData.length + "\n");
                          pose_text_winkel.setText("Winkel X: " + decimalFormat.format((vr.x*100)/100) + " Y: " + decimalFormat.format((vr.y*100)/100) + " Z: " +  decimalFormat.format((vr.z*100)/100) + "\n"
                          + "Device Daten X: " + decimalFormat.format(data[0]) + " Y: " + decimalFormat.format(data[1]) + " Z: " + decimalFormat.format(data[2]));
  
                          // + " CameraView X: " + tangoCameraPreview.getTranslationX() + " Y: " + tangoCameraPreview.getTranslationY()  + " Z: " + tangoCameraPreview.getTranslationZ());
                      }
                  }
              });
  
  
              if(isCubeSet){
  
  
  
                /*  neuX = (data[0]+x);
                  neuY = (data[1]+y);
                  neuZ = -(data[2]+z);*/
  
                  neuX = (transolationData[0]+x);
                  neuY = (transolationData[2]+y);
                  neuZ = -(data[2]+z);
  
                  rendererCube.setX(neuX);
                  rendererCube.setY(neuY);
                  rendererCube.setZ(neuZ);
  
                  rendererCube.setXr((float) pose.rotation[0]);
                  rendererCube.setYr((float) pose.rotation[1]);
                  rendererCube.setZr((float) pose.rotation[2]);
                  rendererCube.setWr((float) pose.rotation[3]);
  
              }
          }
  </code></pre>
  
  <p>Here i set my cube with start points:</p>
  
  <pre><code> @Override
  public boolean onTouch(View v, MotionEvent event) {
      if(!isCubeSet){
          if(event.getAction() == MotionEvent.ACTION_UP) {
              x = data[0];
              y = data[1];
              z  = -data[2];
  
              neuX = x;
              neuY = y;
              neuZ = z;
  
              rendererCube.setX(x);
              rendererCube.setY(y);
              rendererCube.setZ(z);
              isCubeSet = true;
              return true;
          }
      }else{
          if(event.getAction() == MotionEvent.ACTION_UP) {
              isCubeSet = false;
          }
      }
      return true;
  }
  </code></pre>