forked from IntelRealSense/librealsense
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-sensor-extensions.js
109 lines (97 loc) · 3.51 KB
/
test-sensor-extensions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// Copyright (c) 2017 Intel Corporation. All rights reserved.
// Use of this source code is governed by an Apache 2.0 license
// that can be found in the LICENSE file.
'use strict';
/* global describe, it, before, after */
const assert = require('assert');
let rs2;
let pipeline;
try {
rs2 = require('node-librealsense');
} catch (e) {
rs2 = require('../index.js');
}
let device;
let frameset;
let dev_info;
let motion_product_list = ["0AD5", "0AFE", "0AFF", "0B00", "0B01", "0B3A", "0B3D"];
const ctx = new rs2.Context();
let devices = ctx.queryDevices().devices;
assert(devices.length > 0); // Device must be connected
device = devices[0]
dev_info = device.getCameraInfo();
describe('Sensor extensions test', function() {
before(function() {
// const ctx = new rs2.Context();
// let devices = ctx.queryDevices().devices;
// assert(devices.length > 0); // Device must be connected
// device = devices[0]
// dev_info = device.getCameraInfo();
});
after(function() {
rs2.cleanup();
});
it('Testing constructor - 0 argument', () => {
assert.throws(() => {
new rs2.Align();
});
});
it('Testing ColorSensor extention', () => {
var products_list = ["0AA5, 0B48, 0AD3, 0AD4, 0AD5, 0B01, 0B07, 0B3A, 0B3D"];
let rtn = device.getCameraInfo();
if (products_list.includes(rtn.productId))
{
const sensors = device.querySensors();
let is_found = false;
for (let i = 0; i < sensors.length; i++) {
if (sensors[i] instanceof rs2.ColorSensor) {
const sensor = sensors[i];
const profile = sensor.getStreamProfiles()[0];
assert(profile.streamType === rs2.stream.STREAM_COLOR && profile.format == rs2.format.FORMAT_RGB8);
is_found = true;
}
}
assert(is_found);
}
});
it('Testing FisheyeSensor extention', () => {
var products_list = ["0AD5", "0AFE", "0AFF", "0B00", "0B01"];
let rtn = device.getCameraInfo();
if (products_list.includes(rtn.productId))
{
const sensors = device.querySensors();
let is_found = false;
for (let i = 0; i < sensors.length; i++) {
if (sensors[i] instanceof rs2.FisheyeSensor) {
const sensor = sensors[i];
const profile = sensor.getStreamProfiles()[0];
assert(profile.streamType === rs2.stream.STREAM_COLOR && profile.format == rs2.format.FORMAT_RGB8);
is_found = true;
}
}
assert(is_found);
}
});
if (motion_product_list.includes(dev_info.productId))
{
it('Testing MotionSensor extention', () => {
var products_list = ["0AD5", "0AFE", "0AFF", "0B00", "0B01", "0B3A", "0B3D"];
let rtn = device.getCameraInfo();
if (products_list.includes(rtn.productId))
{
const sensors = device.querySensors();
let is_found = false;
for (let i = 0; i < sensors.length; i++) {
if (sensors[i] instanceof rs2.MotionSensor) {
const sensor = sensors[i];
const profile = sensor.getStreamProfiles()[0];
assert([rs2.stream.STREAM_GYRO, rs2.stream.STREAM_ACCEL].includes(profile.streamType))
assert([rs2.format.FORMAT_MOTION_RAW, rs2.format.FORMAT_MOTION_XYZ32F].includes(profile.format));
is_found = true;
}
}
assert(is_found);
}
});
};
});