test-bad-conditions.py
Go to the documentation of this file.
1 # License: Apache 2.0. See LICENSE file in root directory.
2 # Copyright(c) 2020 Intel Corporation. All Rights Reserved.
3 
4 #test:device L500*
5 
6 from rspy import test
7 test.set_env_vars({"RS2_AC_DISABLE_CONDITIONS":"0",
8  "RS2_AC_LOG_TO_STDOUT":"1"
9  })
10 
11 import pyrealsense2 as rs
12 from rspy import ac
13 
14 # rs.log_to_file( rs.log_severity.debug, "rs.log" )
15 
16 dev = test.find_first_device_or_exit()
17 depth_sensor = dev.first_depth_sensor()
18 color_sensor = dev.first_color_sensor()
19 
20 d2r = rs.device_calibration(dev)
21 d2r.register_calibration_change_callback( ac.status_list_callback )
22 
23 cp = next(p for p in color_sensor.profiles if p.fps() == 30
24  and p.stream_type() == rs.stream.color
25  and p.format() == rs.format.yuyv
26  and p.as_video_stream_profile().width() == 1280
27  and p.as_video_stream_profile().height() == 720)
28 
29 dp = next(p for p in
30  depth_sensor.profiles if p.fps() == 30
31  and p.stream_type() == rs.stream.depth
32  and p.format() == rs.format.z16
33  and p.as_video_stream_profile().width() == 1024
34  and p.as_video_stream_profile().height() == 768)
35 
36 depth_sensor.open( dp )
37 depth_sensor.start( lambda f: None )
38 color_sensor.open( cp )
39 color_sensor.start( lambda f: None )
40 
41 #############################################################################################
42 test.start("Failing check_conditions function")
43 # If ambient light is RS2_DIGITAL_GAIN_LOW (2) receiver_gain must be 18
44 # If ambient light is RS2_DIGITAL_GAIN_HIGH (1) receiver_gain must be 9
45 old_receiver_gain = depth_sensor.get_option(rs.option.receiver_gain)
46 depth_sensor.set_option(rs.option.receiver_gain, 15)
47 try:
48  d2r.trigger_device_calibration( rs.calibration_type.manual_depth_to_rgb )
49  test.unreachable()
50  ac.wait_for_calibration()
51 except Exception as e:
52  test.check_exception(e, RuntimeError)
53 else:
54  test.unexpected_exception()
55 test.check_equal_lists(ac.status_list, [rs.calibration_status.bad_conditions])
56 depth_sensor.set_option(rs.option.receiver_gain, old_receiver_gain)
58 #############################################################################################
59 
60 color_sensor.stop()
61 color_sensor.close()
62 depth_sensor.stop()
63 depth_sensor.close()
64 
65 test.print_results_and_exit()
virtual frame finish(frame f)
void next(auto_any_t cur, type2type< T, C > *)
Definition: foreach.hpp:757


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:50:11