l500-private.cpp
Go to the documentation of this file.
1 
4 #include "l500-private.h"
5 #include "l500-device.h"
6 #include "l500-color.h"
7 #include "l500-depth.h"
9 #include "context.h"
10 #include "core/video.h"
12 #include "log.h"
13 #include <chrono>
15 
16 using namespace std;
17 
18 namespace librealsense
19 {
20  namespace ivcam2
21  {
22  const int ac_depth_results::table_id;
23  const uint16_t ac_depth_results::this_version;
24 
25  const uint16_t rgb_calibration_table::table_id;
26  const uint16_t rgb_calibration_table::eeprom_table_id;
27 
28 
29  rs2_extrinsics get_color_stream_extrinsic(const std::vector<uint8_t>& raw_data)
30  {
31  if (raw_data.size() < sizeof(pose))
32  throw invalid_value_exception("size of extrinsic invalid");
33 
34  assert( sizeof( pose ) == sizeof( rs2_extrinsics ) );
35  auto res = *(rs2_extrinsics*)raw_data.data();
36  AC_LOG( DEBUG, "raw extrinsics data from camera:\n" << std::setprecision(15) << res );
37 
38  return from_raw_extrinsics(res);
39  }
40 
41  bool try_fetch_usb_device(std::vector<platform::usb_device_info>& devices,
43  {
44  for (auto it = devices.begin(); it != devices.end(); ++it)
45  {
46  if (it->unique_id == info.unique_id)
47  {
48 
49  result = *it;
50  switch(info.pid)
51  {
52  case L515_PID_PRE_PRQ:
53  case L515_PID:
54  if(result.mi == 7)
55  {
56  devices.erase(it);
57  return true;
58  }
59  break;
60  case L500_PID:
61  if(result.mi == 4 || result.mi == 6)
62  {
63  devices.erase(it);
64  return true;
65  }
66  break;
67  default:
68  break;
69  }
70  }
71  }
72  return false;
73  }
75  {
76  if (!is_enabled())
77  throw wrong_api_call_sequence_exception("query is available during streaming only");
78 
79  auto temperature_data = _l500_depth_dev->get_temperatures();
80 
81  switch (_option)
82  {
84  return float(temperature_data.LDD_temperature);
86  return float(temperature_data.MC_temperature);
88  return float(temperature_data.MA_temperature);
90  return float(temperature_data.APD_temperature);
92  return float(temperature_data.HUM_temperature);
93  default:
94  throw invalid_value_exception(to_string() << _option << " is not temperature option!");
95  }
96  }
97 
98  l500_temperature_options::l500_temperature_options(l500_device *l500_depth_dev,
99  rs2_option opt,
100  const std::string& description )
101  :_l500_depth_dev(l500_depth_dev)
102  , _option( opt )
103  , _description( description )
104  {
105  }
106 
108  {
109  switch (flash_version)
110  {
111  // { number of payloads in section { ro table types }} see Flash.xml
112  case 103: return { 1, { 40, 320, 321, 326, 327, 54} };
113  default:
114  throw std::runtime_error("Unsupported flash version: " + std::to_string(flash_version));
115  }
116  }
117 
119  {
120  switch (flash_version)
121  {
122  // { number of payloads in section { ro table types }} see Flash.xml
123  case 103: return { 4, { 256, 257, 258, 263, 264, 512, 25, 2 } };
124  default:
125  throw std::runtime_error("Unsupported flash version: " + std::to_string(flash_version));
126  }
127  }
128 
129  flash_info get_flash_info(const std::vector<uint8_t>& flash_buffer)
130  {
131  flash_info rv = {};
132 
133  uint32_t header_offset = FLASH_INFO_HEADER_OFFSET;
134  memcpy(&rv.header, flash_buffer.data() + header_offset, sizeof(rv.header));
135 
138 
139  auto ro_toc = parse_table_of_contents(flash_buffer, ro_toc_offset);
140  auto rw_toc = parse_table_of_contents(flash_buffer, rw_toc_offset);
141 
142  auto ro_structure = get_ro_flash_structure(ro_toc.header.version);
143  auto rw_structure = get_rw_flash_structure(rw_toc.header.version);
144 
145  rv.read_only_section = parse_flash_section(flash_buffer, ro_toc, ro_structure);
147  rv.read_write_section = parse_flash_section(flash_buffer, rw_toc, rw_structure);
149 
150  return rv;
151  }
152 
154  : _hwm( hwm )
155  , _enabled( enabled )
156  {
157  // bool_option initializes with def=true, which is what we want
158  assert( is_true() );
159  }
160 
162  {
163  bool_option::set( value );
164 
166  auto res = _hwm.send( cmd );
167  _record_action( *this );
168  }
169 
171  {
172  if( e != is_enabled() )
173  {
174  if( !e && is_true() )
175  set( 0 );
176  _enabled = e;
177  }
178  }
179 
180  hw_sync_option::hw_sync_option( hw_monitor& hwm, std::shared_ptr< freefall_option > freefall_opt )
181  : bool_option( false )
182  , _hwm( hwm )
183  , _freefall_opt( freefall_opt )
184  {
185  }
186 
188  {
189  bool_option::set( value );
190 
191  // Disable the free-fall option if we're enabled!
192  if( _freefall_opt )
193  _freefall_opt->enable( ! is_true() );
194 
196  auto res = _hwm.send( cmd );
197  _record_action( *this );
198  }
199 
200 
201  float nest_option::query() const
202  {
203  auto temperature_data = _l500_depth_dev->get_temperatures();
204  return (float)(temperature_data.nest_avg);
205  }
206 
208  {
209  if ((width == 240 && height == 320) || (width == 320 && height == 240))
210  return RS2_SENSOR_MODE_QVGA;
211  else if ((width == 640 && height == 480) || (width == 480 && height == 640))
212  return RS2_SENSOR_MODE_VGA;
213  else if ((width == 1024 && height == 768) || (width == 768 && height == 1024))
214  return RS2_SENSOR_MODE_XGA;
215  else
216  throw std::runtime_error(to_string() << "Invalid resolution " << width << "x" << height);
217  }
218 
219 } // librealsense::ivcam2
220 } // namespace librealsense
rs2_sensor_mode get_resolution_from_width_height(int width, int height)
flash_section parse_flash_section(const std::vector< uint8_t > &flash_buffer, flash_table toc, flash_structure s)
const uint32_t FLASH_RW_TABLE_OF_CONTENT_OFFSET
Definition: l500-private.h:37
std::shared_ptr< freefall_option > _freefall_opt
Definition: l500-private.h:606
void set(float value) override
Definition: option.cpp:35
rs2_option
Defines general configuration controls. These can generally be mapped to camera UVC controls...
Definition: rs_option.h:22
std::function< void(const option &)> _record_action
Definition: l500-private.h:582
GLfloat value
bool try_fetch_usb_device(std::vector< platform::usb_device_info > &devices, const platform::uvc_device_info &info, platform::usb_device_info &result)
std::function< void(const option &)> _record_action
Definition: l500-private.h:604
unsigned short uint16_t
Definition: stdint.h:79
GLsizei const GLchar *const * string
e
Definition: rmse.py:177
hw_sync_option(hw_monitor &hwm, std::shared_ptr< freefall_option > freefall_opt)
::realsense_legacy_msgs::pose_< std::allocator< void > > pose
Definition: pose.h:88
float query() const override
const uint32_t FLASH_RO_TABLE_OF_CONTENT_OFFSET
Definition: l500-private.h:38
def info(name, value, persistent=False)
Definition: test.py:301
freefall_option(hw_monitor &hwm, bool enabled=true)
rs2_extrinsics from_raw_extrinsics(rs2_extrinsics extr)
Definition: types.cpp:39
std::vector< uint8_t > send(std::vector< uint8_t > const &data) const
Definition: hw-monitor.cpp:115
unsigned int uint32_t
Definition: stdint.h:80
devices
Definition: test-fg.py:9
GLint GLsizei GLsizei height
GLenum GLenum GLsizei const GLuint GLboolean enabled
virtual void set(float value) override
flash_structure get_ro_flash_structure(const uint32_t flash_version)
flash_info get_flash_info(const std::vector< uint8_t > &flash_buffer)
flash_table parse_table_of_contents(const std::vector< uint8_t > &flash_buffer, uint32_t toc_offset)
#define AC_LOG(TYPE, MSG)
rs2_sensor_mode
For setting the camera_mode option.
Definition: rs_option.h:165
Cross-stream extrinsics: encodes the topology describing how the different devices are oriented...
Definition: rs_sensor.h:96
const uint32_t FLASH_INFO_HEADER_OFFSET
Definition: l500-private.h:39
virtual void set(float value) override
GLenum query
static auto it
const uint16_t L515_PID
Definition: l500-private.h:22
flash_structure get_rw_flash_structure(const uint32_t flash_version)
GLuint res
Definition: glext.h:8856
rs2_extrinsics get_color_stream_extrinsic(const std::vector< uint8_t > &raw_data)
const uint16_t L515_PID_PRE_PRQ
Definition: l500-private.h:21
GLuint64EXT * result
Definition: glext.h:10921
const uint16_t L500_PID
Definition: l500-private.h:20
GLint GLsizei width
std::string to_string(T value)


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