Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An evident Timestamp gap between host and hardware #9495

Closed
oym1994 opened this issue Jul 26, 2021 · 5 comments
Closed

An evident Timestamp gap between host and hardware #9495

oym1994 opened this issue Jul 26, 2021 · 5 comments

Comments

@oym1994
Copy link

oym1994 commented Jul 26, 2021

Required Info
Camera Model { D435i }
Firmware Version 05.12.13.50
Operating System & Version Ubuntu 18.04
Kernel Version (Linux Only) 5.4.0-77-generic
Platform PC
SDK Version librealsense 2
Language C++
Segment Robot

` //Get timestamp in the callback function
double hostTimeNow = System::Time::now().toSec();
double hardwareTime = data.get_timestamp() * 0.001;
mDriverHealth.mHardwareImageFps = 1 / (hardwareTime - mDriverHealth.mHardwareImageTime);
mDriverHealth.mHardwareImageTime = hardwareTime;
mDriverHealth.mHostImageFps = 1 / (hostTimeNow - mDriverHealth.mHostImageTime);
mDriverHealth.mHostImageTime = hostTimeNow;

    //Print timestamp later
     std::cout << "HardwareImageFps: " << mDriverHealth.mHardwareImageFps << std::endl;
    std::cout << "HostImageFps: " << mDriverHealth.mHostImageFps << std::endl;
    std::cout << "HostImageTime: " << mDriverHealth.mHostImageTime << " HardwareImageTime: " << mDriverHealth.mHardwareImageTime << "; Time diff " << mDriverHealth.mHostImageTime - mDriverHealth.mHardwareImageTime << std::endl;

outputHardwareImageFps: 30
HostImageFps: 30
HostImageTime: 1627292572.279579162597656 HardwareImageTime: 1627292572.23203182220459; Time diff 0.04754734039306640625
`

Only color image is enabled and set RS2_OPTION_GLOBAL_TIME_ENABLED to be 1.

The problem is that the timestamp diff(0.047s) between the hardware and host is more than the image creation time interval(0.033s). Is it normal? I think the ideal timestamp diff is 0, am I right?

Thank you!

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Jul 26, 2021

Hi @oym1994 Global Time is designed to aid timestamp synchronization across multiple cameras. So it may not be necessary to use it if you are only using a single camera and a single stream (color).

#3909

Could you provide information please about what you are trying to achieve in comparing system time and hardware time? This will help to provide an answer that is helpful to your needs.

In general, if metadata support for hardware timestamps is enabled then hardware timestamps are provided by the SDK, otherwise software timestamps based on system time are provided if that metadata support is not enabled.

In regard to your questions about the accuracy of your timestamp values, I do not personally have the specialist timestamp knowledge to offer advice on that particular subject.

@oym1994
Copy link
Author

oym1994 commented Jul 27, 2021

Thanks for ur kind response!For I want to do time synchronization with other device,such as lidar. My solution is to synchronize those device with the PC first!(which means the timestamps of all device are from PC). BTW,what do u mean when mentioning metadata support?How to verify whether it is supported in my current device and setting?Thanks again for ur kind help!

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Jul 27, 2021

Given that you are aiming to sync with non-D435i devices such as lidar, you could perhaps use the time_of_arrival timestamp, like a RealSense user in the link below did when synchronizing a RealSense D415 with a non-RealSense Stereolabs ZED depth camera.

#2186

In the link below where a RealSense team member describes the different types of timestamp tha are supported by the RealSense SDK, time_of_arrival is defined as "host clock for the time when the frame buffer reaches Librealsense"

#2188 (comment)


In regard to metadata support, there are some types of timestamp that need to have an additional layer of support enabled in order to access their values. In some cases that support may be automatically included when installing the SDK by certain methods, such as in librealsense Debian packages or from source code over an internet connection using the RSUSB backend installation method.

When building from source code on Linux without the RSUSB method, the kernel needs to be patched to add support for metadata in the SDK.

On Windows, metadata support can be added by editing the Windows registry or by the much easier method of enabling it in the RealSense Viewer program.

The SDK documentation link below states that when retrieving metadata with the get_timestamp() instruction, the timestamp types sensor_timestamp and frame_timestamp require metadata support to be enabled.

https://intelrealsense.github.io/librealsense/doxygen/classrs2_1_1frame.html#a25f71d45193f2f4d77960320276b83f1

You can read more documentation about SDK metadata here:

https://dev.intelrealsense.com/docs/frame-metadata


You can check whether metadata support is present with the SDK instruction rs2_supports_frame_metadata - there are C++ code example snippets for this in the metadata documentation:

https://dev.intelrealsense.com/docs/frame-metadata#section-metadata-query-api

https://dev.intelrealsense.com/docs/frame-metadata#section-librealsense2-api-for-metadata

@MartyG-RealSense
Copy link
Collaborator

Hi @oym1994 Do you require further assistance with this case, please? Thanks!

@MartyG-RealSense
Copy link
Collaborator

Case closed due to no further comments received.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants