Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
ZacSVR's avatar
ZacSVR
Honored Guest
5 years ago

Getting accurate timestamps for rotation data

Hello,

I'm developing an app for Oculus Go using Unity 2019.1.12f1, the Oculus Unity Integration v16.0, and VRTK v3.3.

I want to save the rotation of the headset regularly to plot on a graph later. So, for each rotation value, I need to get the most accurate timestamp possible. In the future, I'll be measuring the position of the headset too (on a better headset). Here's roughly what I'm doing, in a MonoBehaviour class that I'm attaching to an object in the scene:

// The object representing the headset, set in the Unity editor:
// (Uses VRTK's VRTK_SDKObjectAlias script to get the transform of the Oculus OVRCameraRig object)
public GameObject headsetObject;
private string previousRotation;

void FixedUpdate()
{
// Get the headset rotation and time
string headsetRotation = headsetObject.transform.rotation.eulerAngles.ToString("f3");
string curTime = Time.time.ToString("f6");

// Check that the latest rotation isn't equal to the previous value we collected
bool isDuplicate = headsetRotation == previousRotation;
if (isDuplicate)
{
return;
}

// Save the rotation and time somewhere
...
latestRotation = headsetRotation;
}

Here is my problem: I'm saving the rotation value and the timestamp at the same point in the code, but I don't know if the timestamp is accurate. How do we know precisely at what time the rotation of the headset object was set?

Having done some testing, I think that the headset's rotation data is updated once every frame. When FixedUpdate is called twice in one frame, the headset rotation is the same in both calls. I found that FixedUpdate gets the same rotation data as Update, but a couple of milliseconds earlier (since FixedUpdate is called before Update).

In the Oculus Unity Integration, it looks like the script OVRCameraRig.cs is responsible for updating the GameObject's transform. I tried enabling the useFixedUpdateForTracking property, but this didn't seem to change anything.

Does anyone know how to best get accurate timestamps for the values of the position and rotation of a headset?

Thank you!


Replies have been turned off for this discussion