# How is the drift corrector implemented in ZED Unity SDK

**URL:** <https://community.stereolabs.com/t/how-is-the-drift-corrector-implemented-in-zed-unity-sdk/1133>\
**Category:** C#\
**Tags:** unity\
**Created:** [May 11, 2022, 3:54pm UTC](https://community.stereolabs.com/t/how-is-the-drift-corrector-implemented-in-zed-unity-sdk/1133 "2022-05-11T15:54:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![keli95566](https://community.stereolabs.com/user_avatar/community.stereolabs.com/keli95566/32/318_2.png) [@keli95566](https://community.stereolabs.com/u/keli95566)\
**Post date:** [May 11, 2022, 3:54pm UTC](https://community.stereolabs.com/t/how-is-the-drift-corrector-implemented-in-zed-unity-sdk/1133/1 "2022-05-11T15:54:21Z")

</div>

Hi there! I am currently trying to implement a similar asynchronous time warp effect to compensate for camera streaming latency. And found the “ZEDMixedRealityPlugin” in the ZED Unity SDK. I am wondering how is the drift corrector implemented, and how is the latency calculated? If you can’t share the code, could you please at least share the method for the drift correction? Thank you!

---

<div class="post-metadata">

**Author:** ![BenjaminV](https://community.stereolabs.com/user_avatar/community.stereolabs.com/benjaminv/32/3863_2.png) [@BenjaminV](https://community.stereolabs.com/u/BenjaminV)\
**Post date:** [May 12, 2022, 7:47am UTC](https://community.stereolabs.com/t/how-is-the-drift-corrector-implemented-in-zed-unity-sdk/1133/2 "2022-05-12T07:47:22Z")

</div>

Hi,

Basically, we are looking for the headset position at the timestamp of the image (in the past). The headset position is either retrieved (if it exists), or is estimated if no pose is found at this timestamp. Then, we are projecting the image at this position and display it on the screen.  
That’s what we do here : [https://github.com/stereolabs/zed-unity/blob/master/ZEDCamera/Assets/ZED/SDK/Helpers/Scripts/ZEDManager.cs#L2452](https://github.com/stereolabs/zed-unity/blob/master/ZEDCamera/Assets/ZED/SDK/Helpers/Scripts/ZEDManager.cs#L2452)

Best,  
Benjamin Vallon

Stereolabs Support

---

<div class="post-metadata">

**Author:** ![keli95566](https://community.stereolabs.com/user_avatar/community.stereolabs.com/keli95566/32/318_2.png) [@keli95566](https://community.stereolabs.com/u/keli95566)\
**Post date:** [May 12, 2022, 8:51am UTC](https://community.stereolabs.com/t/how-is-the-drift-corrector-implemented-in-zed-unity-sdk/1133/3 "2022-05-12T08:51:53Z")

</div>

I guess how many latency positions can be found depends on the framerate settings for the camera? And the time distance between Unity’s each frame update is different, what happens when the algorithm doesn’t find a position? Does it perform an interpolation?

---

<div class="post-metadata">

**Author:** ![BenjaminV](https://community.stereolabs.com/user_avatar/community.stereolabs.com/benjaminv/32/3863_2.png) [@BenjaminV](https://community.stereolabs.com/u/BenjaminV)\
**Post date:** [May 12, 2022, 8:57am UTC](https://community.stereolabs.com/t/how-is-the-drift-corrector-implemented-in-zed-unity-sdk/1133/4 "2022-05-12T08:57:26Z")

</div>

Yes you can interpolate the headset position if you don’t have one at a specific timestamp.  
We are collecting new headset pose at fixed rate, it’s done here : [https://github.com/stereolabs/zed-unity/blob/9c342d6d204639637e769a09e6720490b6876cf4/ZEDCamera/Assets/ZED/SDK/Helpers/Scripts/ZEDManager.cs#L2543](https://github.com/stereolabs/zed-unity/blob/9c342d6d204639637e769a09e6720490b6876cf4/ZEDCamera/Assets/ZED/SDK/Helpers/Scripts/ZEDManager.cs#L2543) for example.

Stereolabs Support

---

<div class="post-metadata">

**Author:** ![keli95566](https://community.stereolabs.com/user_avatar/community.stereolabs.com/keli95566/32/318_2.png) [@keli95566](https://community.stereolabs.com/u/keli95566)\
**Post date:** [May 12, 2022, 9:49am UTC](https://community.stereolabs.com/t/how-is-the-drift-corrector-implemented-in-zed-unity-sdk/1133/5 "2022-05-12T09:49:11Z")

</div>

How would Lateupdate() collect pose at a fixed rate? I guess if we use FixedUpdate the update frequency would be too low…

---

<div class="post-metadata">

**Author:** ![BenjaminV](https://community.stereolabs.com/user_avatar/community.stereolabs.com/benjaminv/32/3863_2.png) [@BenjaminV](https://community.stereolabs.com/u/BenjaminV)\
**Post date:** [May 12, 2022, 10:31am UTC](https://community.stereolabs.com/t/how-is-the-drift-corrector-implemented-in-zed-unity-sdk/1133/6 "2022-05-12T10:31:37Z")

</div>

It’s not at fixed rate indeed, my bad on that. I meant the headset pose is retrieved every frame.

Stereolabs Support
