-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Test timestamp domain #10925
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
Test timestamp domain #10925
Changes from 8 commits
f43330b
bba9950
7da6029
8d2c7c4
ae281dc
a7598f4
b191e67
796ec03
f8c63a1
f1de5ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| # License: Apache 2.0. See LICENSE file in root directory. | ||
| # Copyright(c) 2022 Intel Corporation. All Rights Reserved. | ||
|
|
||
| # test:device D400* | ||
|
|
||
| import time | ||
| import pyrealsense2 as rs | ||
|
|
||
| from rspy import test | ||
|
|
||
|
|
||
| def close_resources(sensor): | ||
| """ | ||
| Stop and Close sensor. | ||
| :sensor: sensor of device | ||
| """ | ||
| if len(sensor.get_active_streams()) > 0: | ||
| sensor.stop() | ||
| sensor.close() | ||
|
|
||
|
|
||
| def set_and_verify_timestamp_domain(sensor, global_time_enabled: bool): | ||
| """ | ||
| Perform sensor (depth or color) test according given global time | ||
| :sensor: depth or color sensor in device | ||
| :global_time_enabled bool: True - timestamp is enabled otherwise false | ||
| """ | ||
| global frame_queue | ||
|
|
||
| try: | ||
| sensor.set_option(rs.option.global_time_enabled, 1 if global_time_enabled else 0) | ||
| time.sleep(0.7) | ||
| frame = frame_queue.wait_for_frame() | ||
|
|
||
| if frame_queue is None or frame_queue.size() == 0: | ||
|
||
| test.fail() | ||
|
|
||
| expected_ts_domain = rs.timestamp_domain.global_time if global_time_enabled else \ | ||
| rs.timestamp_domain.hardware_clock | ||
|
|
||
| test.check_equal(sensor.get_option(rs.option.global_time_enabled), 1 if global_time_enabled else 0) | ||
Nir-Az marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| test.check_equal(frame.get_frame_timestamp_domain(), expected_ts_domain) | ||
|
|
||
| except Exception as exc: | ||
Nir-Az marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Nir-Az marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| print(str(exc)) | ||
| test.fail() | ||
|
|
||
|
|
||
| depth_sensor = None | ||
| color_sensor = None | ||
|
|
||
Tamir91 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| try: | ||
| frame_queue = rs.frame_queue(capacity=5, keep_frames=False) | ||
Nir-Az marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| device = test.find_first_device_or_exit() | ||
|
|
||
| # Depth sensor test | ||
| depth_sensor = device.first_depth_sensor() | ||
| depth_profile = next(p for p in depth_sensor.profiles if p.stream_type() == rs.stream.depth) | ||
| depth_sensor.open(depth_profile) | ||
Nir-Az marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| depth_sensor.start(frame_queue) | ||
|
|
||
| # Test #1 | ||
| test.start('Check setting global time domain: depth sensor - timestamp domain is OFF') | ||
| set_and_verify_timestamp_domain(depth_sensor, False) | ||
| test.finish() | ||
|
|
||
| # Test #2 | ||
| test.start('Check setting global time domain: depth sensor - timestamp domain is ON') | ||
| set_and_verify_timestamp_domain(depth_sensor, True) | ||
| test.finish() | ||
|
|
||
| close_resources(depth_sensor) | ||
|
|
||
| # Color sensor test | ||
| color_sensor = device.first_color_sensor() | ||
| color_profile = next(p for p in color_sensor.profiles if p.stream_type() == rs.stream.color) | ||
| color_sensor.open(color_profile) | ||
| color_sensor.start(frame_queue) | ||
|
|
||
| # Test #3 | ||
| test.start('Check setting global time domain: color sensor - timestamp domain is OFF') | ||
| set_and_verify_timestamp_domain(color_sensor, False) | ||
| test.finish() | ||
|
|
||
| # Test #4 | ||
| test.start('Check setting global time domain: color sensor - timestamp domain is ON') | ||
| set_and_verify_timestamp_domain(color_sensor, True) | ||
| test.finish() | ||
|
|
||
Nir-Az marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| test.print_results_and_exit() | ||
|
|
||
| except Exception as e: | ||
Nir-Az marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| print(str(e)) | ||
| test.fail() | ||
| finally: | ||
| close_resources(color_sensor) | ||
Nir-Az marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Uh oh!
There was an error while loading. Please reload this page.