Skip to content

Stable timestamp sync test - #14311

Merged
Nir-Az merged 6 commits into
realsenseai:developmentfrom
Nir-Az:stable_timestamp_test
Sep 29, 2025
Merged

Stable timestamp sync test#14311
Nir-Az merged 6 commits into
realsenseai:developmentfrom
Nir-Az:stable_timestamp_test

Conversation

@Nir-Az

@Nir-Az Nir-Az commented Sep 25, 2025

Copy link
Copy Markdown
Collaborator

Skip dropped frames
Resync when needed
Increase run time
Run only on nightly
Increase threshold as we saw a 1.2 ms peeks occasionally

@Nir-Az
Nir-Az requested a review from AviaAv September 25, 2025 10:10
@AviaAv
AviaAv requested a review from Copilot September 25, 2025 10:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 improves the stability of timestamp synchronization tests by replacing the original test-timestamps.py with an enhanced test-sync.py that includes frame drop detection, re-synchronization logic, and runs only on nightly builds with increased tolerance thresholds.

  • Implements frame drop detection using hardware frame counters to identify when synchronization may be compromised
  • Adds re-synchronization mechanism that skips frames after detecting drops to allow sensors to stabilize
  • Increases test duration from 50 to 100 frames and adjusts tolerance from 1ms to 1.5ms to handle observed peak variations

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
unit-tests/live/metadata/test-timestamps.py Removed original test file
unit-tests/live/metadata/test-sync.py Added enhanced test with frame drop detection, re-sync logic, and nightly-only execution

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread unit-tests/live/metadata/test-sync.py Outdated
Comment thread unit-tests/live/metadata/test-sync.py Outdated

# Tolerance for gaps between frames
TS_TOLERANCE_MS = 1.5 # in ms
TS_TOLERANCE_MICROSEC = TS_TOLERANCE_MS * 1000 # in microseconds - 1 ms

Copilot AI Sep 25, 2025

Copy link

Choose a reason for hiding this comment

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

Comment is misleading - it states '1 ms' but the actual value is 1.5ms (TS_TOLERANCE_MS * 1000). Should be updated to reflect the correct value.

Suggested change
TS_TOLERANCE_MICROSEC = TS_TOLERANCE_MS * 1000 # in microseconds - 1 ms
TS_TOLERANCE_MICROSEC = TS_TOLERANCE_MS * 1000 # in microseconds - 1.5 ms (1500 microseconds)

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

Comment thread unit-tests/live/metadata/test-sync.py Outdated
# Check for frame drops
if prev_frame_counters[sensor_name] is not None:
expected_counter = prev_frame_counters[sensor_name] + 1
if current_counter != expected_counter:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we can remove this condition to simplify the function - if they are equal, dropped_frames will be zero and no drop message will show

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Agree, will remove

Comment thread unit-tests/live/metadata/test-sync.py Outdated
if frame_drop_detected:
frames_to_skip = SKIP_FRAMES_AFTER_DROP
log.w(f"Frame drop detected at frame {frame_count}, will skip next {frames_to_skip} frames for re-sync")
log.w(f"Drop details: {'; '.join(drop_info)}")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need to log again? we already log at detect_frame_drops if we have a drop

If we don't need to log again, we don't need drop_info here or in the function

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Agree will remove


log.d(f"Frame TS - Depth:{frame_timestamps['depth']}, IR1:{frame_timestamps['ir1']}, IR2:{frame_timestamps['ir2']}, Color:{frame_timestamps['color']}")

test.check_approx_abs(frame_timestamps['depth'], frame_timestamps['ir1'], TS_TOLERANCE_MICROSEC)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's add a comment to distinguish between frame ts and global ts above

@AviaAv AviaAv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, let's get green libci with the test before merging

@Nir-Az
Nir-Az merged commit 5d68d16 into realsenseai:development Sep 29, 2025
25 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