- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Currently, we have connected the camera to our laptop but in reality the camera will be far away and is connected via internet. We want to simulate the network latency and measure our performance based on the length of latency but don't how. Any guidance is appreciated.
Thanks
Iman
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you are writing your own program in Unity, you could put a Unity instruction called WaitForSeconds in your script at the point where it loops round to start the next frame. WaitForSeconds can be any number you want, such as 0.1 (seconds). Unity does not allow the loop (e.g the next frame) to start again until the period specified in the WaitForSeconds instruction has passed. Here's an example script from my own Unity project:
On the last line, change the value in the bracket from 0.1 to whatever pause period you want. Remember to leave the 'f' on the end of the number if its a decimal number.
StartCoroutine(PauseTracking());
}
IEnumerator PauseTracking()
{
yield return new WaitForSeconds(0.1f);
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You could try using Unity's own in-built performance profiling tool, under Window > Analysis > Profiler. If you open the Profiler window whilst the program is running, it gives you extremely detailed feedback about where lag is occurring. Its default mode is a graphical line chart showing the frames per second (FPS) that the program is running at after processing lag is taken into account. You can dig deep into textual information about every aspect of the program's processing activities though.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the reply. We don't want to understand current lag in the system. We need to artificially add latency between what the current frame that the camera captures and when the frame is available for processing, so we can simulate what we'll encounter in the real world. Right now we connect the camera to the laptop and do our processing locally but in reality the camera needs to send it's data over internet to a different location. Therefore, there will be a delay between when camera captures a frame and when it is available for processing. How can we simulate such lag?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you are writing your own program in Unity, you could put a Unity instruction called WaitForSeconds in your script at the point where it loops round to start the next frame. WaitForSeconds can be any number you want, such as 0.1 (seconds). Unity does not allow the loop (e.g the next frame) to start again until the period specified in the WaitForSeconds instruction has passed. Here's an example script from my own Unity project:
On the last line, change the value in the bracket from 0.1 to whatever pause period you want. Remember to leave the 'f' on the end of the number if its a decimal number.
StartCoroutine(PauseTracking());
}
IEnumerator PauseTracking()
{
yield return new WaitForSeconds(0.1f);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wouldn't this lower the frequency as opposed to adding latency? We are also using the sample provided by librealsense in unity. RsDevice object is used to reconstruct the 3D environment.
Thanks for your prompt replies MartyG
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
WaitForSeconds is not related to frames per second. It is a general 'pause button' for processing that stops a script from running any further past the WaitForSeconds point until the time has elapsed.
I understand what you are trying to achieve. It was a good idea to post your question on the GitHub too, as there are highly technical staff there who may be able to offer a cleverer solution than I can think of.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page