Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
unit-tests
func
reflectivity
l500
reflectivity/l500/test-dependencies.cpp
Go to the documentation of this file.
1
// License: Apache 2.0. See LICENSE file in root directory.
2
// Copyright(c) 2021 Intel Corporation. All Rights Reserved.
3
4
//#test:tag reflectivity
5
//#test:device L500*
6
7
#include "../../func-common.h"
8
9
// Test group description:
10
// * This tests group verifies IR reflectivity option restrictions,
11
// according to [RS-8358].
12
//
13
// Current test description:
14
// * While not streaming, activating IR Reflectivity option should make sure the visual preset is 'Max Range' and the sensor mode is 'VGA',
15
// if it is not it will set the visual preset to max range and the sensor mode to 'VGA'.
16
// * Starting non VGA stream when IR Reflectivity is on, turns it off.
17
// * Activating IR Reflectivity while Max Usable Range is off
18
// should turn on Max Usable Range option.
19
// If the MUR option was turned on by activating IR Reflectivity,
20
// Turning off IR Reflectivity should turn off MUR option.
21
// * If MUR option was already on when IR Reflectivity was turned on,
22
// turning off IR Reflectivity should not turn off MUR option.
23
// * While streaming, Activating IR Reflectivity while Max Usable Range is off
24
// should turn on Max Usable Range option.
25
// If the MUR option was turned on by activating IR Reflectivity,
26
// Turning off IR Reflectivity should turn off MUR option.
27
// * Verify turning off MUR option turns off IR Reflectivity option,
28
// Reflectivity require MUR to be on otherwise it can't work.
29
//
30
// Note: * L515 specific test
31
// * Test will pass if no L515 device is connected.
32
// * Test will be performed on the first L515 device detected.
33
34
TEST_CASE
(
"IR Reflectivity option change visual preset and sensor mode if not streaming"
,
"[reflectivity]"
)
35
{
36
auto
ds
37
=
find_first_supported_depth_sensor_or_exit
(
"L515"
,
RS2_OPTION_ENABLE_IR_REFLECTIVITY
);
38
39
// Verify alt IR is off
40
if
(
ds
.supports(
RS2_OPTION_ALTERNATE_IR
) )
41
ds
.set_option(
RS2_OPTION_ALTERNATE_IR
, 0 );
42
43
ds
.set_option(
RS2_OPTION_SENSOR_MODE
,
RS2_SENSOR_MODE_XGA
);
44
ds
.set_option(
RS2_OPTION_VISUAL_PRESET
,
RS2_L500_VISUAL_PRESET_SHORT_RANGE
);
45
CHECK_NOTHROW
(
ds
.set_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
, 1.f ) );
46
CHECK
(
RS2_L500_VISUAL_PRESET_MAX_RANGE
==
ds
.get_option(
RS2_OPTION_VISUAL_PRESET
) );
47
CHECK
(
RS2_SENSOR_MODE_VGA
==
ds
.get_option(
RS2_OPTION_SENSOR_MODE
));
48
}
49
50
TEST_CASE
(
"Starting streaming non VGA sensor mode turns off IR Reflectivity"
,
"[reflectivity]"
)
51
{
52
auto
ds
53
=
find_first_supported_depth_sensor_or_exit
(
"L515"
,
RS2_OPTION_ENABLE_IR_REFLECTIVITY
);
54
55
// Verify alt IR is off
56
if
(
ds
.supports(
RS2_OPTION_ALTERNATE_IR
))
57
ds
.set_option(
RS2_OPTION_ALTERNATE_IR
, 0);
58
59
ds
.set_option(
RS2_OPTION_VISUAL_PRESET
,
RS2_L500_VISUAL_PRESET_MAX_RANGE
);
60
ds
.set_option(
RS2_OPTION_SENSOR_MODE
,
RS2_SENSOR_MODE_VGA
);
61
62
// Verify activating IR Reflectivity
63
CHECK_NOTHROW
(
ds
.set_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
, 1.f));
64
CHECK
(
ds
.get_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
));
65
66
67
auto
profiles
=
ds
.get_stream_profiles();
68
// Find a profile that sensor mode != VGA
69
auto
non_vga_depth_profile
70
= std::find_if(profiles.begin(), profiles.end(), [](
rs2::stream_profile
sp) {
71
auto
vp = sp.as<
rs2::video_stream_profile
>();
72
73
return
((sp.stream_type() ==
RS2_STREAM_DEPTH
) && (sp.format() ==
RS2_FORMAT_Z16
)
74
&& (vp.width() != 640) && (vp.height() != 480));
75
});
76
77
REQUIRE
(non_vga_depth_profile != profiles.end());
78
ds
.open(*non_vga_depth_profile);
79
ds
.start([](
rs2::frame
f
) {});
80
81
// Verify turned off
82
CHECK_FALSE
(
ds
.get_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
));
83
84
ds
.stop();
85
ds
.close();
86
}
87
88
TEST_CASE
(
"Automatically turn on MUR option - non streaming"
,
"[reflectivity]"
)
89
{
90
auto
ds
91
=
find_first_supported_depth_sensor_or_exit
(
"L515"
,
RS2_OPTION_ENABLE_IR_REFLECTIVITY
);
92
93
// Verify alt IR is off
94
if
(
ds
.supports(
RS2_OPTION_ALTERNATE_IR
))
95
ds
.set_option(
RS2_OPTION_ALTERNATE_IR
, 0);
96
97
ds
.set_option(
RS2_OPTION_SENSOR_MODE
,
RS2_SENSOR_MODE_VGA
);
98
ds
.set_option(
RS2_OPTION_VISUAL_PRESET
,
RS2_L500_VISUAL_PRESET_MAX_RANGE
);
99
CHECK_NOTHROW
(
ds
.set_option(
RS2_OPTION_ENABLE_MAX_USABLE_RANGE
, 0));
100
// Verify automatically turn on of MUR option
101
CHECK_NOTHROW
(
ds
.set_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
, 1.f));
102
CHECK
(
ds
.get_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
));
103
CHECK
(
ds
.get_option(
RS2_OPTION_ENABLE_MAX_USABLE_RANGE
));
104
105
// Verify automatically turn off of MUR option
106
CHECK_NOTHROW
(
ds
.set_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
, 0));
107
CHECK_FALSE
(
ds
.get_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
));
108
CHECK_FALSE
(
ds
.get_option(
RS2_OPTION_ENABLE_MAX_USABLE_RANGE
));
109
110
// Turn on MUR
111
CHECK_NOTHROW
(
ds
.set_option(
RS2_OPTION_ENABLE_MAX_USABLE_RANGE
, 1));
112
113
CHECK_NOTHROW
(
ds
.set_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
, 1.f));
114
CHECK
(
ds
.get_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
));
115
CHECK
(
ds
.get_option(
RS2_OPTION_ENABLE_MAX_USABLE_RANGE
));
116
117
CHECK_NOTHROW
(
ds
.set_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
, 0));
118
CHECK_FALSE
(
ds
.get_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
));
119
// Verify MUR stays on
120
CHECK
(
ds
.get_option(
RS2_OPTION_ENABLE_MAX_USABLE_RANGE
));
121
}
122
123
124
TEST_CASE
(
"Automatically turn on/off MUR option - streaming"
,
"[reflectivity]"
)
125
{
126
auto
ds
127
=
find_first_supported_depth_sensor_or_exit
(
"L515"
,
RS2_OPTION_ENABLE_IR_REFLECTIVITY
);
128
129
// Verify alt IR is off
130
if
(
ds
.supports(
RS2_OPTION_ALTERNATE_IR
))
131
ds
.set_option(
RS2_OPTION_ALTERNATE_IR
, 0);
132
133
ds
.set_option(
RS2_OPTION_SENSOR_MODE
,
RS2_SENSOR_MODE_VGA
);
134
ds
.set_option(
RS2_OPTION_VISUAL_PRESET
,
RS2_L500_VISUAL_PRESET_MAX_RANGE
);
135
CHECK_NOTHROW
(
ds
.set_option(
RS2_OPTION_ENABLE_MAX_USABLE_RANGE
, 0));
136
137
auto
depth_vga_profile
138
=
get_profile_by_stream_parameters
(
ds
,
RS2_STREAM_DEPTH
,
RS2_FORMAT_Z16
, 640, 480, 30 );
139
140
REQUIRE
(depth_vga_profile);
141
142
ds
.open(depth_vga_profile);
143
ds
.start([](
rs2::frame
f
) {});
144
145
// Verify automatically turn on of MUR option
146
CHECK_NOTHROW
(
ds
.set_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
, 1.f));
147
CHECK
(
ds
.get_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
));
148
CHECK
(
ds
.get_option(
RS2_OPTION_ENABLE_MAX_USABLE_RANGE
));
149
150
// Verify automatically turn off of MUR option
151
CHECK_NOTHROW
(
ds
.set_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
, 0));
152
CHECK_FALSE
(
ds
.get_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
));
153
CHECK_FALSE
(
ds
.get_option(
RS2_OPTION_ENABLE_MAX_USABLE_RANGE
));
154
155
// Turn on MUR
156
CHECK_NOTHROW
(
ds
.set_option(
RS2_OPTION_ENABLE_MAX_USABLE_RANGE
, 1));
157
158
CHECK_NOTHROW
(
ds
.set_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
, 1.f));
159
CHECK
(
ds
.get_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
));
160
CHECK
(
ds
.get_option(
RS2_OPTION_ENABLE_MAX_USABLE_RANGE
));
161
162
CHECK_NOTHROW
(
ds
.set_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
, 0));
163
CHECK_FALSE
(
ds
.get_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
));
164
// Verify MUR stays on
165
CHECK
(
ds
.get_option(
RS2_OPTION_ENABLE_MAX_USABLE_RANGE
));
166
167
ds
.stop();
168
ds
.close();
169
}
170
171
TEST_CASE
(
"Turning off MUR option turns off IR Reflectivity"
,
"[reflectivity]"
)
172
{
173
auto
depth_sensor
174
=
find_first_supported_depth_sensor_or_exit
(
"L515"
,
RS2_OPTION_ENABLE_MAX_USABLE_RANGE
);
175
auto
mur =
depth_sensor
.
as
<
rs2::max_usable_range_sensor
>();
176
REQUIRE
(mur);
177
mur.set_option(
RS2_OPTION_VISUAL_PRESET
,
RS2_L500_VISUAL_PRESET_MAX_RANGE
);
178
179
// Verify alt IR is off before enabling IR Reflectivity
180
if
(mur.supports(
RS2_OPTION_ALTERNATE_IR
))
181
mur.set_option(
RS2_OPTION_ALTERNATE_IR
, 0);
182
183
auto
depth_vga_profile
184
=
get_profile_by_stream_parameters
( mur,
RS2_STREAM_DEPTH
,
RS2_FORMAT_Z16
, 640, 480, 30 );
185
186
REQUIRE
(depth_vga_profile);
187
188
// Check while not streaming
189
mur.set_option(
RS2_OPTION_ENABLE_MAX_USABLE_RANGE
, 1.
f
);
190
mur.set_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
, 1.
f
);
191
CHECK
(mur.get_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
));
192
mur.set_option(
RS2_OPTION_ENABLE_MAX_USABLE_RANGE
, 0);
193
CHECK_FALSE
(mur.get_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
));
194
195
mur.open(depth_vga_profile);
196
mur.start([](
rs2::frame
f
) {});
197
198
// Check while streaming
199
mur.set_option(
RS2_OPTION_ENABLE_MAX_USABLE_RANGE
, 1.f);
200
mur.set_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
, 1.f);
201
CHECK
(mur.get_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
));
202
mur.set_option(
RS2_OPTION_ENABLE_MAX_USABLE_RANGE
, 0);
203
CHECK_FALSE
(mur.get_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
));
204
205
mur.stop();
206
mur.close();
207
}
rs2::stream_profile
Definition:
rs_frame.hpp:22
rs2::frame
Definition:
rs_frame.hpp:343
RS2_L500_VISUAL_PRESET_MAX_RANGE
Definition:
rs_option.h:157
RS2_SENSOR_MODE_XGA
Definition:
rs_option.h:168
rs2::depth_sensor
Definition:
rs_sensor.hpp:454
RS2_FORMAT_Z16
Definition:
rs_sensor.h:62
RS2_SENSOR_MODE_VGA
Definition:
rs_option.h:167
f
GLdouble f
Definition:
glad/glad/glad.h:1518
REQUIRE
REQUIRE(n_callbacks==1)
find_first_supported_depth_sensor_or_exit
rs2::depth_sensor find_first_supported_depth_sensor_or_exit(const std::string &dev_name, rs2_option opt)
Definition:
func-common.h:77
rs2::sensor::as
T as() const
Definition:
rs_sensor.hpp:333
RS2_OPTION_ENABLE_IR_REFLECTIVITY
Definition:
rs_option.h:109
t265_stereo.profiles
profiles
Definition:
t265_stereo.py:139
rs2::max_usable_range_sensor
Definition:
rs_sensor.hpp:728
RS2_STREAM_DEPTH
Definition:
rs_sensor.h:45
test_sensor_first_frame_delay.ds
ds
Definition:
test_sensor_first_frame_delay.py:75
RS2_OPTION_ALTERNATE_IR
Definition:
rs_option.h:107
RS2_OPTION_ENABLE_MAX_USABLE_RANGE
Definition:
rs_option.h:106
CHECK_NOTHROW
#define CHECK_NOTHROW(...)
Definition:
catch.hpp:17421
RS2_L500_VISUAL_PRESET_SHORT_RANGE
Definition:
rs_option.h:158
TEST_CASE
TEST_CASE("IR Reflectivity option change visual preset and sensor mode if not streaming","[reflectivity]")
Definition:
reflectivity/l500/test-dependencies.cpp:34
rs2::video_stream_profile
Definition:
rs_frame.hpp:201
CHECK
#define CHECK(condition)
Definition:
easylogging++.h:4483
RS2_OPTION_VISUAL_PRESET
Definition:
rs_option.h:36
RS2_OPTION_SENSOR_MODE
Definition:
rs_option.h:95
get_profile_by_stream_parameters
rs2::stream_profile get_profile_by_stream_parameters(rs2::sensor s, rs2_stream stream=RS2_STREAM_ANY, rs2_format format=RS2_FORMAT_ANY, int width=-1, int height=-1, int fps=-1, int stream_index=-1)
Definition:
func-common.h:227
CHECK_FALSE
CHECK_FALSE(inverse(inverse(p))==p)
librealsense2
Author(s): Sergey Dorodnicov
, Doron Hirshberg
, Mark Horn
, Reagan Lopez
, Itay Carpis
autogenerated on Mon May 3 2021 02:50:11