Skip to content

Conversation

@AviaAv
Copy link
Contributor

@AviaAv AviaAv commented Jun 26, 2025

Tracked on: [LRS-1275]

@AviaAv AviaAv requested a review from Nir-Az June 26, 2025 09:39
ir1_frame_ts = ir1_frame.get_frame_metadata(rs.frame_metadata_value.frame_timestamp)
ir2_frame_ts = ir2_frame.get_frame_metadata(rs.frame_metadata_value.frame_timestamp)

log.d(f"Depth TS: {depth_ts}, IR1 TS: {ir1_ts}, IR2 TS: {ir2_ts}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add color stream

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And check with an acceptable tolerance, see the Jira ticket for bad and good numbers

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You know what, since the original bug was for IR + Depth that's OK to keep as is.

Do we expect the exactly same TS?

@Nir-Az
Copy link
Collaborator

Nir-Az commented Jul 1, 2025

DO we know why the CI failed?
We expect it to pass right?

@Nir-Az Nir-Az requested review from Copilot and remibettan July 29, 2025 11:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR creates a new test to verify timestamp consistency between different frame types (depth, infrared, and color) from RealSense devices. The test validates both global timestamps and frame metadata timestamps to ensure proper synchronization.

  • Adds a comprehensive timestamp consistency test for D400 series devices
  • Validates synchronization between depth, infrared (channels 1 & 2), and color streams
  • Includes tolerance checks for both global and frame-level timestamps

ir2_frame = frames.get_infrared_frame(2)
color_frame = frames.get_color_frame()

if not (depth_frame and ir1_frame and ir2_frame):
Copy link

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition doesn't check for color_frame validity, but color_frame is used later in the code (lines 41, 44, 49, 53, 59, 62, 67). This could cause AttributeError if color_frame is None.

Suggested change
if not (depth_frame and ir1_frame and ir2_frame):
if not (depth_frame and ir1_frame and ir2_frame and color_frame):

Copilot uses AI. Check for mistakes.
Comment on lines 47 to 59
test.check(depth_ts == ir1_ts)
test.check(depth_ts == ir2_ts)
Copy link

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exact equality comparison for timestamps may be too strict and could lead to flaky tests due to minor timing variations. Consider using approximate equality with a small tolerance instead.

Suggested change
test.check(depth_ts == ir1_ts)
test.check(depth_ts == ir2_ts)
test.check_approx_abs(depth_ts, ir1_ts, GLOBAL_TS_TOLERANCE)
test.check_approx_abs(depth_ts, ir2_ts, GLOBAL_TS_TOLERANCE)

Copilot uses AI. Check for mistakes.

# Check global timestamps
test.check(depth_ts == ir1_ts)
test.check(depth_ts == ir2_ts)
Copy link

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exact equality comparison for timestamps may be too strict and could lead to flaky tests due to minor timing variations. Consider using approximate equality with a small tolerance instead.

Suggested change
test.check(depth_ts == ir2_ts)
test.check_approx_abs(depth_ts, ir2_ts, GLOBAL_TS_TOLERANCE)

Copilot uses AI. Check for mistakes.
Comment on lines 65 to 77
test.check(depth_frame_ts == ir1_frame_ts)
test.check(depth_frame_ts == ir2_frame_ts)
Copy link

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exact equality comparison for frame timestamps may be too strict and could lead to flaky tests due to minor timing variations. Consider using approximate equality with a small tolerance instead.

Suggested change
test.check(depth_frame_ts == ir1_frame_ts)
test.check(depth_frame_ts == ir2_frame_ts)
test.check_approx_abs(depth_frame_ts, ir1_frame_ts, FRAME_TS_TOLERANCE)
test.check_approx_abs(depth_frame_ts, ir2_frame_ts, FRAME_TS_TOLERANCE)

Copilot uses AI. Check for mistakes.
Comment on lines 65 to 77
test.check(depth_frame_ts == ir1_frame_ts)
test.check(depth_frame_ts == ir2_frame_ts)
Copy link

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exact equality comparison for frame timestamps may be too strict and could lead to flaky tests due to minor timing variations. Consider using approximate equality with a small tolerance instead.

Suggested change
test.check(depth_frame_ts == ir1_frame_ts)
test.check(depth_frame_ts == ir2_frame_ts)
test.check_approx_abs(depth_frame_ts, ir1_frame_ts, FRAME_TS_TOLERANCE)
test.check_approx_abs(depth_frame_ts, ir2_frame_ts, FRAME_TS_TOLERANCE)

Copilot uses AI. Check for mistakes.
import pyrealsense2 as rs
from rspy import test, log

# This test is checking that timestamps of depth and infrared frames are consistent
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add about color

Copy link
Contributor

@remibettan remibettan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few comments - impressive python!

@remibettan remibettan self-requested a review July 31, 2025 10:31
Copy link
Contributor

@remibettan remibettan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


# Tolerance for gap between depth and color
GLOBAL_TS_TOLERANCE = 1 # in ms
FRAME_TS_TOLERANCE = 100 # in microseconds
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that too strict? where did you get 100 us from?

@Nir-Az Nir-Az requested a review from remibettan July 31, 2025 11:07
@Nir-Az
Copy link
Collaborator

Nir-Az commented Jul 31, 2025

@remibettan since I see the tests failed on CI I removed your approval.
Let's approve for merge when the test run and pass

@AviaAv AviaAv requested a review from Nir-Az August 18, 2025 06:28
@Nir-Az Nir-Az changed the title Create timestamp test Create timestamp synchronization test Aug 18, 2025
@Nir-Az Nir-Az merged commit 204572f into realsenseai:development Aug 20, 2025
25 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants