RsDevice.cpp
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 #include "RsDevice.hh"
5 #include "RsUsageEnvironment.h"
6 #include <iostream>
7 #include <thread>
8 
9 int RsDevice::getPhysicalSensorUniqueKey(rs2_stream stream_type, int sensors_index)
10 {
11  return stream_type * 10 + sensors_index;
12 }
13 
14 RsDevice::RsDevice(UsageEnvironment* t_env)
15  : env(t_env)
16 {
17  //get LRS device
18  // The context represents the current platform with respect to connected devices
19 
20  bool found = false;
21  bool first = true;
22  do
23  {
27  if(devices.size())
28  {
29  try
30  {
31  m_device = devices[0]; // Only one device is supported
32  *env << "RealSense Device Connected\n";
33 
34  found = true;
35  }
36  catch(const std::exception& e)
37  {
38  std::cerr << e.what() << '\n';
39  }
40  }
41  if(!found)
42  {
43  if(first)
44  {
45  std::cerr << "Waiting for Device..." << std::endl;
46  first = false;
47  }
48  std::this_thread::sleep_for(std::chrono::seconds(1));
49  }
50  } while(!found);
51 
52  //get RS sensors
53  for(auto& sensor : m_device.query_sensors())
54  {
55  m_sensors.push_back(RsSensor(env, sensor, m_device));
56  }
57 }
58 
60 {
61  std::cerr << "RsDevice destructor" << std::endl;
62 }
std::vector< sensor > query_sensors() const
Definition: rs_device.hpp:25
std::vector< RsSensor > m_sensors
Definition: RsDevice.hh:36
device_list query_devices() const
Definition: rs_context.hpp:112
uint32_t size() const
Definition: rs_device.hpp:711
~RsDevice()
Definition: RsDevice.cpp:59
e
Definition: rmse.py:177
static int getPhysicalSensorUniqueKey(rs2_stream stream_type, int sensors_index)
Definition: RsDevice.cpp:9
devices
Definition: test-fg.py:9
rs2::device m_device
Definition: RsDevice.hh:35
RsDevice(UsageEnvironment *t_env)
Definition: RsDevice.cpp:14
GLint first
rs2_stream
Streams are different types of data provided by RealSense devices.
Definition: rs_sensor.h:42
UsageEnvironment * env
Definition: RsDevice.hh:38
std::ostream & cerr()


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