Skip to content

Commit 11c15bc

Browse files
authored
PR #13682 from OhadMeir: Stabilize DDS tests on LibCI
2 parents 71f4938 + 87be9c2 commit 11c15bc

File tree

4 files changed

+105
-19
lines changed

4 files changed

+105
-19
lines changed

unit-tests/dds/d455.py

+83-1
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ def color_stream():
207207
stream = dds.color_stream_server( "Color", "RGB Camera" )
208208
stream.init_profiles( color_stream_profiles(), 10 )
209209
stream.init_options( rgb_camera_options() )
210+
stream.set_intrinsics( color_stream_intrinsics() )
210211
return stream
211212

212213

@@ -398,4 +399,85 @@ def get_extrinsics():
398399
extrinsics[("Infrared_2","Infrared_1")] = extr
399400

400401
return extrinsics
401-
402+
403+
def color_stream_intrinsics():
404+
intrinsics = []
405+
406+
intr = dds.video_intrinsics();
407+
intr.width = 1280
408+
intr.height = 800
409+
intr.principal_point.x = 648.580993652344
410+
intr.principal_point.y = 398.820983886719
411+
intr.focal_length.x = 636.450012207031
412+
intr.focal_length.y = 635.621948242188
413+
intr.distortion.model = dds.distortion_model.inverse_brown
414+
intr.distortion.coeffs = [-0.0569772012531757,0.0660239011049271,0.000211432998185046,0.00068545201793313,-0.0208512991666794]
415+
intrinsics.append( intr )
416+
417+
intr = dds.video_intrinsics();
418+
intr.width = 1280
419+
intr.height = 720
420+
intr.principal_point.x = 648.580993652344
421+
intr.principal_point.y = 358.821014404297
422+
intr.focal_length.x = 636.450012207031
423+
intr.focal_length.y = 635.622009277344
424+
intr.distortion.model = dds.distortion_model.inverse_brown
425+
intr.distortion.coeffs = [-0.0569772012531757,0.0660239011049271,0.000211432998185046,0.00068545201793313,-0.0208512991666794]
426+
intrinsics.append( intr )
427+
428+
intr = dds.video_intrinsics();
429+
intr.width = 848
430+
intr.height = 480
431+
intr.principal_point.x = 429.684906005859
432+
intr.principal_point.y = 239.21891784668
433+
intr.focal_length.x = 421.648132324219
434+
intr.focal_length.y = 421.099578857422
435+
intr.distortion.model = dds.distortion_model.inverse_brown
436+
intr.distortion.coeffs = [-0.0569772012531757,0.0660239011049271,0.000211432998185046,0.00068545201793313,-0.0208512991666794]
437+
intrinsics.append( intr )
438+
439+
intr = dds.video_intrinsics();
440+
intr.width = 640
441+
intr.height = 480
442+
intr.principal_point.x = 325.148590087891
443+
intr.principal_point.y = 239.292602539062
444+
intr.focal_length.x = 381.869995117188
445+
intr.focal_length.y = 381.373199462891
446+
intr.distortion.model = dds.distortion_model.inverse_brown
447+
intr.distortion.coeffs = [-0.0569772012531757,0.0660239011049271,0.000211432998185046,0.00068545201793313,-0.0208512991666794]
448+
intrinsics.append( intr )
449+
450+
intr = dds.video_intrinsics();
451+
intr.width = 640
452+
intr.height = 360
453+
intr.principal_point.x = 324.290496826172
454+
intr.principal_point.y = 179.410507202148
455+
intr.focal_length.x = 318.225006103516
456+
intr.focal_length.y = 317.811004638672
457+
intr.distortion.model = dds.distortion_model.inverse_brown
458+
intr.distortion.coeffs = [-0.0569772012531757,0.0660239011049271,0.000211432998185046,0.00068545201793313,-0.0208512991666794]
459+
intrinsics.append( intr )
460+
461+
intr = dds.video_intrinsics();
462+
intr.width = 480
463+
intr.height = 270
464+
intr.principal_point.x = 243.217880249023
465+
intr.principal_point.y = 134.557876586914
466+
intr.focal_length.x = 238.668746948242
467+
intr.focal_length.y = 238.358245849609
468+
intr.distortion.model = dds.distortion_model.inverse_brown
469+
intr.distortion.coeffs = [-0.0569772012531757,0.0660239011049271,0.000211432998185046,0.00068545201793313,-0.0208512991666794]
470+
intrinsics.append( intr )
471+
472+
intr = dds.video_intrinsics();
473+
intr.width = 424
474+
intr.height = 240
475+
intr.principal_point.x = 214.84245300293
476+
intr.principal_point.y = 119.60945892334
477+
intr.focal_length.x = 210.824066162109
478+
intr.focal_length.y = 210.549789428711
479+
intr.distortion.model = dds.distortion_model.inverse_brown
480+
intr.distortion.coeffs = [-0.0569772012531757,0.0660239011049271,0.000211432998185046,0.00068545201793313,-0.0208512991666794]
481+
intrinsics.append( intr )
482+
483+
return set( intrinsics )

unit-tests/dds/test-device-discovery.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def create_server_2( root ):
6868

6969
# We listen directly on the device-info topic
7070
device_info_topic = dds.message.device_info.create_topic( participant, dds.topics.device_info )
71-
device_info = dds.topic_reader( device_info_topic )
71+
device_info_reader = dds.topic_reader( device_info_topic )
7272
broadcast_received = threading.Event()
7373
broadcast_devices = []
7474
def on_device_info_available( reader ):
@@ -81,8 +81,8 @@ def on_device_info_available( reader ):
8181
global broadcast_devices
8282
broadcast_devices.append( j )
8383
broadcast_received.set()
84-
device_info.on_data_available( on_device_info_available )
85-
device_info.run( dds.topic_reader.qos() )
84+
device_info_reader.on_data_available( on_device_info_available )
85+
device_info_reader.run( dds.topic_reader.qos() )
8686

8787
def detect_broadcast():
8888
global broadcast_received, broadcast_devices
@@ -203,6 +203,9 @@ def __exit__( self, type, value, traceback ):
203203
reader_2 = dds.topic_reader( device_info_topic )
204204
reader_2.run( dds.topic_reader.qos() )
205205
test.check_equal( len(broadcast_devices), 2 )
206+
# Add short sleep to avoid a possible deadlock. Devices broadcast is handled by `on_device_info_available` callback,
207+
# we may still be checking for messages (in eProcima reader thread) when trying to delete reader_2.
208+
sleep( 0.1 )
206209
del reader_2
207210

208211
#############################################################################################
@@ -300,7 +303,7 @@ def __exit__( self, type, value, traceback ):
300303

301304

302305
del watcher
303-
device_info.stop()
304-
del device_info
306+
device_info_reader.stop()
307+
del device_info_reader
305308
del participant
306309
test.print_results_and_exit()

unit-tests/dds/test-librs-intrinsics.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import pyrealdds as dds
1313
import d435i
14+
import d455
1415

1516
dds.debug( log.is_debug_on(), log.nested )
1617

@@ -34,22 +35,22 @@ def broadcast_device( server, device_info ):
3435

3536
def build_scaled_intrinsics_server():
3637
color = dds.color_stream_server( 'Color', 'RGB Camera' )
37-
color.init_profiles( d435i.color_stream_profiles(), 8 )
38+
color.init_profiles( d455.color_stream_profiles(), 5 )
3839
color.init_options( [] )
3940

4041
# Add only a single set of intrinsics for 1920x1080, from which we expect to scale to all resolutions:
4142
i = dds.video_intrinsics();
42-
i.width = 1920
43-
i.height = 1080
44-
i.principal_point.x = 970.4506225585938
45-
i.principal_point.y = 542.8473510742188
46-
i.focal_length.x = 1362.133056640625
47-
i.focal_length.y = 1362.629638671875
43+
i.width = 1280
44+
i.height = 720
45+
i.principal_point.x = 648.580993652344
46+
i.principal_point.y = 358.821014404297
47+
i.focal_length.x = 636.450012207031
48+
i.focal_length.y = 635.622009277344
4849
i.distortion.model = dds.distortion_model.inverse_brown
49-
i.distortion.coeffs = [0.0,0.0,0.0,0.0,0.0]
50+
i.distortion.coeffs = [-0.0569772012531757,0.0660239011049271,0.000211432998185046,0.00068545201793313,-0.0208512991666794]
5051
color.set_intrinsics( set( [i] ) )
5152

52-
dev = dds.device_server( participant, d435i.device_info.topic_root )
53+
dev = dds.device_server( participant, d455.device_info.topic_root )
5354
dev.init( [color], [], {} )
5455
return dev
5556

@@ -167,7 +168,7 @@ def close_server( instance ):
167168
dev = None
168169

169170
with test.closure( 'Scaled intrinsics' ):
170-
remote.run( 'instance = broadcast_device( build_scaled_intrinsics_server(), d435i.device_info )' )
171+
remote.run( 'instance = broadcast_device( build_scaled_intrinsics_server(), d455.device_info )' )
171172
dev = rs.wait_for_devices( context, rs.only_sw_devices, n=1. )
172173
sensors = dev.query_sensors()
173174
test.check_equal( len(sensors), 1 )

unit-tests/dds/test-md-syncer.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ def md_thread():
354354

355355
def frame_callback( image, metadata ):
356356
on_frame_ready( image, metadata ) # for reporting
357-
sleep( 0.1 )
357+
sleep( 0.2 )
358358
log.d( f'<{image_id(image):->4} {dds.now()} [{threading.get_native_id()}]' )
359359

360360
syncer = new_syncer( on_frame_ready=frame_callback )
@@ -366,11 +366,11 @@ def frame_thread():
366366
idstr = f'i{image_id(image)}'
367367
log.d( f'{idstr:>5} {dds.now()} [{threadid}] enqueue {image}' )
368368
syncer.enqueue_frame( i, image )
369-
sleep( 0.05 )
369+
sleep( 0.1 )
370370

371371
threadA = threading.Thread( target=frame_thread )
372372
threadA.start()
373-
sleep( 0.12 ) # Between 2nd and 3rd enqueue_frame
373+
sleep( 0.22 ) # Between 2nd and 3rd enqueue_frame
374374
md = new_metadata( 1, time_stamp( 1 ) )
375375
syncer.enqueue_metadata( 1, md )
376376
threadA.join()

0 commit comments

Comments
 (0)