Intel® RealSense™ Cross Platform API
Intel Realsense Cross-platform API
rs_device.hpp
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2017 Intel Corporation. All Rights Reserved.
3 
4 #ifndef LIBREALSENSE_RS2_DEVICE_HPP
5 #define LIBREALSENSE_RS2_DEVICE_HPP
6 
7 #include "rs_types.hpp"
8 #include "rs_sensor.hpp"
9 #include <array>
10 
11 namespace rs2
12 {
13  class context;
14  class device_list;
15  class pipeline_profile;
16  class device_hub;
17 
18  class device
19  {
20  public:
25  std::vector<sensor> query_sensors() const
26  {
27  rs2_error* e = nullptr;
28  std::shared_ptr<rs2_sensor_list> list(
29  rs2_query_sensors(_dev.get(), &e),
31  error::handle(e);
32 
33  auto size = rs2_get_sensors_count(list.get(), &e);
34  error::handle(e);
35 
36  std::vector<sensor> results;
37  for (auto i = 0; i < size; i++)
38  {
39  std::shared_ptr<rs2_sensor> dev(
40  rs2_create_sensor(list.get(), i, &e),
42  error::handle(e);
43 
44  sensor rs2_dev(dev);
45  results.push_back(rs2_dev);
46  }
47 
48  return results;
49  }
50 
51  template<class T>
52  T first() const
53  {
54  for (auto&& s : query_sensors())
55  {
56  if (auto t = s.as<T>()) return t;
57  }
58  throw rs2::error("Could not find requested sensor type!");
59  }
60 
66  bool supports(rs2_camera_info info) const
67  {
68  rs2_error* e = nullptr;
69  auto is_supported = rs2_supports_device_info(_dev.get(), info, &e);
70  error::handle(e);
71  return is_supported > 0;
72  }
73 
79  const char* get_info(rs2_camera_info info) const
80  {
81  rs2_error* e = nullptr;
82  auto result = rs2_get_device_info(_dev.get(), info, &e);
83  error::handle(e);
84  return result;
85  }
86 
91  {
92  rs2_error* e = nullptr;
93 
94  rs2_hardware_reset(_dev.get(), &e);
95  error::handle(e);
96  }
97 
98  device& operator=(const std::shared_ptr<rs2_device> dev)
99  {
100  _dev.reset();
101  _dev = dev;
102  return *this;
103  }
104  device& operator=(const device& dev)
105  {
106  *this = nullptr;
107  _dev = dev._dev;
108  return *this;
109  }
110  device() : _dev(nullptr) {}
111 
112  operator bool() const
113  {
114  return _dev != nullptr;
115  }
116  const std::shared_ptr<rs2_device>& get() const
117  {
118  return _dev;
119  }
120 
121  template<class T>
122  bool is() const
123  {
124  T extension(*this);
125  return extension;
126  }
127 
128  template<class T>
129  T as() const
130  {
131  T extension(*this);
132  return extension;
133  }
134  virtual ~device()
135  {
136  }
137 
138  explicit operator std::shared_ptr<rs2_device>() { return _dev; };
139  explicit device(std::shared_ptr<rs2_device> dev) : _dev(dev) {}
140  protected:
141  friend class rs2::context;
142  friend class rs2::device_list;
143  friend class rs2::pipeline_profile;
144  friend class rs2::device_hub;
145 
146  std::shared_ptr<rs2_device> _dev;
147 
148  };
149 
150  template<class T>
152  {
153  T _callback;
154 
155  public:
156  explicit update_progress_callback(T callback) : _callback(callback) {}
157 
158  void on_update_progress(const float progress) override
159  {
160  _callback(progress);
161  }
162 
163  void release() override { delete this; }
164  };
165 
166  class updatable : public device
167  {
168  public:
169  updatable() : device() {}
171  : device(d.get())
172  {
173  rs2_error* e = nullptr;
174  if (rs2_is_device_extendable_to(_dev.get(), RS2_EXTENSION_UPDATABLE, &e) == 0 && !e)
175  {
176  _dev.reset();
177  }
178  error::handle(e);
179  }
180 
181  // Move the device to update state, this will cause the updatable device to disconnect and reconnect as an update device.
182  void enter_update_state() const
183  {
184  rs2_error* e = nullptr;
185  rs2_enter_update_state(_dev.get(), &e);
186  error::handle(e);
187  }
188 
189  // Create backup of camera flash memory. Such backup does not constitute valid firmware image, and cannot be
190  // loaded back to the device, but it does contain all calibration and device information."
191  std::vector<uint8_t> create_flash_backup() const
192  {
193  std::vector<uint8_t> results;
194 
195  rs2_error* e = nullptr;
196  std::shared_ptr<const rs2_raw_data_buffer> list(
197  rs2_create_flash_backup_cpp(_dev.get(), nullptr, &e),
199  error::handle(e);
200 
201  auto size = rs2_get_raw_data_size(list.get(), &e);
202  error::handle(e);
203 
204  auto start = rs2_get_raw_data(list.get(), &e);
205 
206  results.insert(results.begin(), start, start + size);
207 
208  return results;
209  }
210 
211  template<class T>
212  std::vector<uint8_t> create_flash_backup(T callback) const
213  {
214  std::vector<uint8_t> results;
215 
216  rs2_error* e = nullptr;
217  std::shared_ptr<const rs2_raw_data_buffer> list(
218  rs2_create_flash_backup_cpp(_dev.get(), new update_progress_callback<T>(std::move(callback)), &e),
220  error::handle(e);
221 
222  auto size = rs2_get_raw_data_size(list.get(), &e);
223  error::handle(e);
224 
225  auto start = rs2_get_raw_data(list.get(), &e);
226 
227  results.insert(results.begin(), start, start + size);
228 
229  return results;
230  }
231 
232  // Update an updatable device to the provided unsigned firmware. This call is executed on the caller's thread.
233  void update_unsigned(const std::vector<uint8_t>& image, int update_mode = RS2_UNSIGNED_UPDATE_MODE_UPDATE) const
234  {
235  rs2_error* e = nullptr;
236  rs2_update_firmware_unsigned_cpp(_dev.get(), image.data(), (int)image.size(), nullptr, update_mode, &e);
237  error::handle(e);
238  }
239 
240  // Update an updatable device to the provided unsigned firmware. This call is executed on the caller's thread and it supports progress notifications via the callback.
241  template<class T>
242  void update_unsigned(const std::vector<uint8_t>& image, T callback, int update_mode = RS2_UNSIGNED_UPDATE_MODE_UPDATE) const
243  {
244  rs2_error* e = nullptr;
245  rs2_update_firmware_unsigned_cpp(_dev.get(), image.data(), int(image.size()), new update_progress_callback<T>(std::move(callback)), update_mode, &e);
246  error::handle(e);
247  }
248  };
249 
250  class update_device : public device
251  {
252  public:
255  : device(d.get())
256  {
257  rs2_error* e = nullptr;
259  {
260  _dev.reset();
261  }
262  error::handle(e);
263  }
264 
265  // Update an updatable device to the provided firmware.
266  // This call is executed on the caller's thread.
267  void update(const std::vector<uint8_t>& fw_image) const
268  {
269  rs2_error* e = nullptr;
270  rs2_update_firmware_cpp(_dev.get(), fw_image.data(), (int)fw_image.size(), NULL, &e);
271  error::handle(e);
272  }
273 
274  // Update an updatable device to the provided firmware.
275  // This call is executed on the caller's thread and it supports progress notifications via the callback.
276  template<class T>
277  void update(const std::vector<uint8_t>& fw_image, T callback) const
278  {
279  rs2_error* e = nullptr;
280  rs2_update_firmware_cpp(_dev.get(), fw_image.data(), int(fw_image.size()), new update_progress_callback<T>(std::move(callback)), &e);
281  error::handle(e);
282  }
283  };
284 
285  typedef std::vector<uint8_t> calibration_table;
286 
287  class calibrated_device : public device
288  {
289  public:
291  : device(d.get())
292  {}
293 
297  void write_calibration() const
298  {
299  rs2_error* e = nullptr;
300  rs2_write_calibration(_dev.get(), &e);
301  error::handle(e);
302  }
303 
308  {
309  rs2_error* e = nullptr;
311  error::handle(e);
312  }
313  };
314 
316  {
317  public:
319  : calibrated_device(d)
320  {
321  rs2_error* e = nullptr;
323  {
324  _dev.reset();
325  }
326  error::handle(e);
327  }
328 
362  template<class T>
363  calibration_table run_on_chip_calibration(std::string json_content, float* health, T callback, int timeout_ms = 5000) const
364  {
365  std::vector<uint8_t> results;
366 
367  rs2_error* e = nullptr;
368  auto buf = rs2_run_on_chip_calibration_cpp(_dev.get(), json_content.data(), int(json_content.size()), health, new update_progress_callback<T>(std::move(callback)), timeout_ms, &e);
369  error::handle(e);
370 
371  std::shared_ptr<const rs2_raw_data_buffer> list(buf, rs2_delete_raw_data);
372 
373  auto size = rs2_get_raw_data_size(list.get(), &e);
374  error::handle(e);
375 
376  auto start = rs2_get_raw_data(list.get(), &e);
377 
378  results.insert(results.begin(), start, start + size);
379 
380  return results;
381  }
382 
415  calibration_table run_on_chip_calibration(std::string json_content, float* health, int timeout_ms = 5000) const
416  {
417  std::vector<uint8_t> results;
418 
419  rs2_error* e = nullptr;
420  std::shared_ptr<const rs2_raw_data_buffer> list(
421  rs2_run_on_chip_calibration_cpp(_dev.get(), json_content.data(), static_cast< int >( json_content.size() ), health, nullptr, timeout_ms, &e),
423  error::handle(e);
424  auto size = rs2_get_raw_data_size(list.get(), &e);
425  error::handle(e);
426 
427  auto start = rs2_get_raw_data(list.get(), &e);
428 
429  results.insert(results.begin(), start, start + size);
430 
431  return results;
432  }
433 
456  template<class T>
457  calibration_table run_tare_calibration(float ground_truth_mm, std::string json_content, T callback, int timeout_ms = 5000) const
458  {
459  std::vector<uint8_t> results;
460 
461  rs2_error* e = nullptr;
462  std::shared_ptr<const rs2_raw_data_buffer> list(
463  rs2_run_tare_calibration_cpp(_dev.get(), ground_truth_mm, json_content.data(), int(json_content.size()), new update_progress_callback<T>(std::move(callback)), timeout_ms, &e),
465  error::handle(e);
466 
467  auto size = rs2_get_raw_data_size(list.get(), &e);
468  error::handle(e);
469 
470  auto start = rs2_get_raw_data(list.get(), &e);
471 
472  results.insert(results.begin(), start, start + size);
473 
474  return results;
475  }
476 
498  calibration_table run_tare_calibration(float ground_truth_mm, std::string json_content, int timeout_ms = 5000) const
499  {
500  std::vector<uint8_t> results;
501 
502  rs2_error* e = nullptr;
503  std::shared_ptr<const rs2_raw_data_buffer> list(
504  rs2_run_tare_calibration_cpp(_dev.get(), ground_truth_mm, json_content.data(), static_cast< int >( json_content.size() ), nullptr, timeout_ms, &e),
506  error::handle(e);
507 
508  auto size = rs2_get_raw_data_size(list.get(), &e);
509  error::handle(e);
510 
511  auto start = rs2_get_raw_data(list.get(), &e);
512 
513  results.insert(results.begin(), start, start + size);
514 
515  return results;
516  }
517 
523  {
524  std::vector<uint8_t> results;
525 
526  rs2_error* e = nullptr;
527  std::shared_ptr<const rs2_raw_data_buffer> list(
528  rs2_get_calibration_table(_dev.get(), &e),
530  error::handle(e);
531 
532  auto size = rs2_get_raw_data_size(list.get(), &e);
533  error::handle(e);
534 
535  auto start = rs2_get_raw_data(list.get(), &e);
536 
537  results.insert(results.begin(), start, start + size);
538 
539  return results;
540  }
541 
546  void set_calibration_table(const calibration_table& calibration)
547  {
548  rs2_error* e = nullptr;
549  rs2_set_calibration_table(_dev.get(), calibration.data(), static_cast< int >( calibration.size() ), &e);
550  error::handle(e);
551  }
552  };
553 
554  /*
555  Wrapper around any callback function that is given to calibration_change_callback.
556  */
557  template< class callback >
559  {
560  //using callback = std::function< void( rs2_calibration_status ) >;
561  callback _callback;
562  public:
563  calibration_change_callback( callback cb ) : _callback( cb ) {}
564 
565  void on_calibration_change( rs2_calibration_status status ) noexcept override
566  {
567  _callback( status );
568  }
569  void release() override { delete this; }
570  };
571 
572  class device_calibration : public device
573  {
574  public:
576  : device( d.get() )
577  {
578  rs2_error* e = nullptr;
580  {
581  _dev.reset();
582  }
583  error::handle( e );
584  }
585 
586  /*
587  Your callback should look like this, for example:
588  sensor.register_calibration_change_callback(
589  []( rs2_calibration_status ) noexcept
590  {
591  ...
592  })
593  */
594  template< typename T >
596  {
597  // We wrap the callback with an interface and pass it to librealsense, who will
598  // now manage its lifetime. Rather than deleting it, though, it will call its
599  // release() function, where (back in our context) it can be safely deleted:
600  rs2_error* e = nullptr;
602  _dev.get(),
603  new calibration_change_callback< T >( std::move( callback )),
604  &e );
605  error::handle( e );
606  }
607 
612  {
613  rs2_error* e = nullptr;
614  rs2_trigger_device_calibration( _dev.get(), type, &e );
615  error::handle( e );
616  }
617  };
618 
619  class debug_protocol : public device
620  {
621  public:
623  : device(d.get())
624  {
625  rs2_error* e = nullptr;
626  if(rs2_is_device_extendable_to(_dev.get(), RS2_EXTENSION_DEBUG, &e) == 0 && !e)
627  {
628  _dev.reset();
629  }
630  error::handle(e);
631  }
632 
633  std::vector<uint8_t> send_and_receive_raw_data(const std::vector<uint8_t>& input) const
634  {
635  std::vector<uint8_t> results;
636 
637  rs2_error* e = nullptr;
638  std::shared_ptr<const rs2_raw_data_buffer> list(
639  rs2_send_and_receive_raw_data(_dev.get(), (void*)input.data(), (uint32_t)input.size(), &e),
641  error::handle(e);
642 
643  auto size = rs2_get_raw_data_size(list.get(), &e);
644  error::handle(e);
645 
646  auto start = rs2_get_raw_data(list.get(), &e);
647 
648  results.insert(results.begin(), start, start + size);
649 
650  return results;
651  }
652  };
653 
655  {
656  public:
657  explicit device_list(std::shared_ptr<rs2_device_list> list)
658  : _list(move(list)) {}
659 
661  : _list(nullptr) {}
662 
663  operator std::vector<device>() const
664  {
665  std::vector<device> res;
666  for (auto&& dev : *this) res.push_back(dev);
667  return res;
668  }
669 
670  bool contains(const device& dev) const
671  {
672  rs2_error* e = nullptr;
673  auto res = !!(rs2_device_list_contains(_list.get(), dev.get().get(), &e));
674  error::handle(e);
675  return res;
676  }
677 
678  device_list& operator=(std::shared_ptr<rs2_device_list> list)
679  {
680  _list = move(list);
681  return *this;
682  }
683 
684  device operator[](uint32_t index) const
685  {
686  rs2_error* e = nullptr;
687  std::shared_ptr<rs2_device> dev(
688  rs2_create_device(_list.get(), index, &e),
690  error::handle(e);
691 
692  return device(dev);
693  }
694 
695  uint32_t size() const
696  {
697  rs2_error* e = nullptr;
698  auto size = rs2_get_device_count(_list.get(), &e);
699  error::handle(e);
700  return size;
701  }
702 
703  device front() const { return std::move((*this)[0]); }
704  device back() const
705  {
706  return std::move((*this)[size() - 1]);
707  }
708 
710  {
712  const device_list& device_list,
713  uint32_t uint32_t)
714  : _list(device_list),
715  _index(uint32_t)
716  {
717  }
718 
719  public:
721  {
722  return _list[_index];
723  }
724  bool operator!=(const device_list_iterator& other) const
725  {
726  return other._index != _index || &other._list != &_list;
727  }
728  bool operator==(const device_list_iterator& other) const
729  {
730  return !(*this != other);
731  }
733  {
734  _index++;
735  return *this;
736  }
737  private:
738  friend device_list;
739  const device_list& _list;
740  uint32_t _index;
741  };
742 
744  {
745  return device_list_iterator(*this, 0);
746  }
748  {
749  return device_list_iterator(*this, size());
750  }
751  const rs2_device_list* get_list() const
752  {
753  return _list.get();
754  }
755 
756  operator std::shared_ptr<rs2_device_list>() { return _list; };
757 
758  private:
759  std::shared_ptr<rs2_device_list> _list;
760  };
761 
771  class tm2 : public calibrated_device // TODO: add to wrappers [Python done]
772  {
773  public:
775  : calibrated_device(d)
776  {
777  rs2_error* e = nullptr;
778  if (rs2_is_device_extendable_to(_dev.get(), RS2_EXTENSION_TM2, &e) == 0 && !e)
779  {
780  _dev.reset();
781  }
782  error::handle(e);
783  }
784 
789  void enable_loopback(const std::string& from_file)
790  {
791  rs2_error* e = nullptr;
792  rs2_loopback_enable(_dev.get(), from_file.c_str(), &e);
793  error::handle(e);
794  }
795 
800  {
801  rs2_error* e = nullptr;
802  rs2_loopback_disable(_dev.get(), &e);
803  error::handle(e);
804  }
805 
810  bool is_loopback_enabled() const
811  {
812  rs2_error* e = nullptr;
813  int is_enabled = rs2_loopback_is_enabled(_dev.get(), &e);
814  error::handle(e);
815  return is_enabled != 0;
816  }
817 
822  void connect_controller(const std::array<uint8_t, 6>& mac_addr)
823  {
824  rs2_error* e = nullptr;
825  rs2_connect_tm2_controller(_dev.get(), mac_addr.data(), &e);
826  error::handle(e);
827  }
828 
834  {
835  rs2_error* e = nullptr;
836  rs2_disconnect_tm2_controller(_dev.get(), id, &e);
837  error::handle(e);
838  }
839 
845  void set_intrinsics(int fisheye_sensor_id, const rs2_intrinsics& intrinsics)
846  {
847  rs2_error* e = nullptr;
848  auto fisheye_sensor = get_sensor_profile(RS2_STREAM_FISHEYE, fisheye_sensor_id);
849  rs2_set_intrinsics(fisheye_sensor.first.get().get(), fisheye_sensor.second.get(), &intrinsics, &e);
850  error::handle(e);
851  }
852 
861  void set_extrinsics(rs2_stream from_stream, int from_id, rs2_stream to_stream, int to_id, rs2_extrinsics& extrinsics)
862  {
863  rs2_error* e = nullptr;
864  auto from_sensor = get_sensor_profile(from_stream, from_id);
865  auto to_sensor = get_sensor_profile(to_stream, to_id);
866  rs2_set_extrinsics(from_sensor.first.get().get(), from_sensor.second.get(), to_sensor.first.get().get(), to_sensor.second.get(), &extrinsics, &e);
867  error::handle(e);
868  }
869 
875  void set_motion_device_intrinsics(rs2_stream stream_type, const rs2_motion_device_intrinsic& motion_intriniscs)
876  {
877  rs2_error* e = nullptr;
878  auto motion_sensor = get_sensor_profile(stream_type, 0);
879  rs2_set_motion_device_intrinsics(motion_sensor.first.get().get(), motion_sensor.second.get(), &motion_intriniscs, &e);
880  error::handle(e);
881  }
882 
883  private:
884 
885  std::pair<sensor, stream_profile> get_sensor_profile(rs2_stream stream_type, int stream_index) {
886  for (auto s : query_sensors()) {
887  for (auto p : s.get_stream_profiles()) {
888  if (p.stream_type() == stream_type && p.stream_index() == stream_index)
889  return std::pair<sensor, stream_profile>(s, p);
890  }
891  }
892  return std::pair<sensor, stream_profile>();
893  }
894  };
895 }
896 #endif // LIBREALSENSE_RS2_DEVICE_HPP
Definition: rs_types.hpp:92
device operator*() const
Definition: rs_device.hpp:720
void rs2_set_calibration_table(const rs2_device *device, const void *calibration, int calibration_size, rs2_error **error)
device back() const
Definition: rs_device.hpp:704
int rs2_get_sensors_count(const rs2_sensor_list *info_list, rs2_error **error)
rs2_camera_info
Read-only strings that can be queried from the device. Not all information attributes are available o...
Definition: rs_sensor.h:22
Definition: rs_sensor.hpp:102
update_device()
Definition: rs_device.hpp:253
bool is() const
Definition: rs_device.hpp:122
int rs2_device_list_contains(const rs2_device_list *info_list, const rs2_device *device, rs2_error **error)
int rs2_loopback_is_enabled(const rs2_device *device, rs2_error **error)
device_list(std::shared_ptr< rs2_device_list > list)
Definition: rs_device.hpp:657
std::vector< uint8_t > send_and_receive_raw_data(const std::vector< uint8_t > &input) const
Definition: rs_device.hpp:633
std::vector< uint8_t > create_flash_backup() const
Definition: rs_device.hpp:191
void release() override
Definition: rs_device.hpp:163
rs2_calibration_type
Definition: rs_device.h:344
std::vector< sensor > query_sensors() const
Definition: rs_device.hpp:25
auto_calibrated_device(device d)
Definition: rs_device.hpp:318
device()
Definition: rs_device.hpp:110
const char * get_info(rs2_camera_info info) const
Definition: rs_device.hpp:79
device & operator=(const device &dev)
Definition: rs_device.hpp:104
void rs2_register_calibration_change_callback_cpp(rs2_device *dev, rs2_calibration_change_callback *callback, rs2_error **error)
void rs2_trigger_device_calibration(rs2_device *dev, rs2_calibration_type type, rs2_error **error)
Definition: rs_pipeline.hpp:18
bool operator==(const device_list_iterator &other) const
Definition: rs_device.hpp:728
void update_unsigned(const std::vector< uint8_t > &image, int update_mode=RS2_UNSIGNED_UPDATE_MODE_UPDATE) const
Definition: rs_device.hpp:233
void update(const std::vector< uint8_t > &fw_image) const
Definition: rs_device.hpp:267
const rs2_raw_data_buffer * rs2_get_calibration_table(const rs2_device *dev, rs2_error **error)
void rs2_set_intrinsics(const rs2_sensor *sensor, const rs2_stream_profile *profile, const rs2_intrinsics *intrinsics, rs2_error **error)
rs2_sensor * rs2_create_sensor(const rs2_sensor_list *list, int index, rs2_error **error)
calibrated_device(device d)
Definition: rs_device.hpp:290
Definition: rs_sensor.hpp:405
void set_calibration_table(const calibration_table &calibration)
Definition: rs_device.hpp:546
void set_intrinsics(int fisheye_sensor_id, const rs2_intrinsics &intrinsics)
Definition: rs_device.hpp:845
void update_unsigned(const std::vector< uint8_t > &image, T callback, int update_mode=RS2_UNSIGNED_UPDATE_MODE_UPDATE) const
Definition: rs_device.hpp:242
void rs2_delete_device(rs2_device *device)
void connect_controller(const std::array< uint8_t, 6 > &mac_addr)
Definition: rs_device.hpp:822
Definition: rs_sensor.h:48
const unsigned char * rs2_get_raw_data(const rs2_raw_data_buffer *buffer, rs2_error **error)
calibration_table run_tare_calibration(float ground_truth_mm, std::string json_content, int timeout_ms=5000) const
Definition: rs_device.hpp:498
void rs2_write_calibration(const rs2_device *device, rs2_error **e)
void disconnect_controller(int id)
Definition: rs_device.hpp:833
rs2_device * rs2_create_device(const rs2_device_list *info_list, int index, rs2_error **error)
device_list & operator=(std::shared_ptr< rs2_device_list > list)
Definition: rs_device.hpp:678
Definition: rs_device.hpp:151
Definition: rs_context.hpp:11
Definition: rs_types.hpp:62
void rs2_delete_raw_data(const rs2_raw_data_buffer *buffer)
Definition: rs_context.hpp:96
void reset_to_factory_calibration()
Definition: rs_device.hpp:307
Definition: rs_sensor.hpp:389
int rs2_get_raw_data_size(const rs2_raw_data_buffer *buffer, rs2_error **error)
Definition: rs_device.hpp:166
T as() const
Definition: rs_device.hpp:129
void enter_update_state() const
Definition: rs_device.hpp:182
device_calibration(device d)
Definition: rs_device.hpp:575
void rs2_connect_tm2_controller(const rs2_device *device, const unsigned char *mac_addr, rs2_error **error)
device_list_iterator begin() const
Definition: rs_device.hpp:743
void rs2_loopback_enable(const rs2_device *device, const char *from_file, rs2_error **error)
std::vector< uint8_t > calibration_table
Definition: rs_device.hpp:285
void rs2_disconnect_tm2_controller(const rs2_device *device, int id, rs2_error **error)
Definition: rs_device.hpp:619
void set_motion_device_intrinsics(rs2_stream stream_type, const rs2_motion_device_intrinsic &motion_intriniscs)
Definition: rs_device.hpp:875
bool is_loopback_enabled() const
Definition: rs_device.hpp:810
device operator[](uint32_t index) const
Definition: rs_device.hpp:684
int rs2_supports_device_info(const rs2_device *device, rs2_camera_info info, rs2_error **error)
#define RS2_UNSIGNED_UPDATE_MODE_UPDATE
Definition: rs_device.h:206
rs2_calibration_status
Definition: rs_device.h:355
void rs2_delete_sensor(rs2_sensor *sensor)
int rs2_is_device_extendable_to(const rs2_device *device, rs2_extension extension, rs2_error **error)
device front() const
Definition: rs_device.hpp:703
uint32_t size() const
Definition: rs_device.hpp:695
void trigger_device_calibration(rs2_calibration_type type)
Definition: rs_device.hpp:611
void hardware_reset()
Definition: rs_device.hpp:90
void rs2_set_extrinsics(const rs2_sensor *from_sensor, const rs2_stream_profile *from_profile, rs2_sensor *to_sensor, const rs2_stream_profile *to_profile, const rs2_extrinsics *extrinsics, rs2_error **error)
const std::shared_ptr< rs2_device > & get() const
Definition: rs_device.hpp:116
void update(const std::vector< uint8_t > &fw_image, T callback) const
Definition: rs_device.hpp:277
std::shared_ptr< rs2_device > _dev
Definition: rs_device.hpp:146
std::vector< uint8_t > create_flash_backup(T callback) const
Definition: rs_device.hpp:212
void rs2_hardware_reset(const rs2_device *device, rs2_error **error)
Definition: rs_types.h:199
rs2_sensor_list * rs2_query_sensors(const rs2_device *device, rs2_error **error)
void rs2_update_firmware_cpp(const rs2_device *device, const void *fw_image, int fw_image_size, rs2_update_progress_callback *callback, rs2_error **error)
calibration_table get_calibration_table()
Definition: rs_device.hpp:522
void release() override
Definition: rs_device.hpp:569
void write_calibration() const
Definition: rs_device.hpp:297
update_device(device d)
Definition: rs_device.hpp:254
void set_extrinsics(rs2_stream from_stream, int from_id, rs2_stream to_stream, int to_id, rs2_extrinsics &extrinsics)
Definition: rs_device.hpp:861
static void handle(rs2_error *e)
Definition: rs_types.hpp:144
calibration_table run_on_chip_calibration(std::string json_content, float *health, T callback, int timeout_ms=5000) const
Definition: rs_device.hpp:363
rs2_stream
Streams are different types of data provided by RealSense devices.
Definition: rs_sensor.h:42
void register_calibration_change_callback(T callback)
Definition: rs_device.hpp:595
void rs2_reset_to_factory_calibration(const rs2_device *device, rs2_error **e)
void rs2_set_motion_device_intrinsics(const rs2_sensor *sensor, const rs2_stream_profile *profile, const rs2_motion_device_intrinsic *intrinsics, rs2_error **error)
calibration_change_callback(callback cb)
Definition: rs_device.hpp:563
Definition: rs_device.hpp:558
Definition: rs_types.h:184
Cross-stream extrinsics: encodes the topology describing how the different devices are oriented...
Definition: rs_sensor.h:96
calibration_table run_tare_calibration(float ground_truth_mm, std::string json_content, T callback, int timeout_ms=5000) const
Definition: rs_device.hpp:457
const rs2_raw_data_buffer * rs2_create_flash_backup_cpp(const rs2_device *device, rs2_update_progress_callback *callback, rs2_error **error)
bool contains(const device &dev) const
Definition: rs_device.hpp:670
const rs2_raw_data_buffer * rs2_send_and_receive_raw_data(rs2_device *device, void *raw_data_to_send, unsigned size_of_raw_data_to_send, rs2_error **error)
Definition: rs_types.h:203
Definition: rs_types.hpp:83
Definition: rs_types.h:163
bool supports(rs2_camera_info info) const
Definition: rs_device.hpp:66
update_progress_callback(T callback)
Definition: rs_device.hpp:156
device & operator=(const std::shared_ptr< rs2_device > dev)
Definition: rs_device.hpp:98
device_list_iterator & operator++()
Definition: rs_device.hpp:732
device_list()
Definition: rs_device.hpp:660
Definition: rs_device.hpp:315
updatable()
Definition: rs_device.hpp:169
Definition: rs_device.hpp:654
Definition: rs_device.hpp:287
updatable(device d)
Definition: rs_device.hpp:170
void rs2_enter_update_state(const rs2_device *device, rs2_error **error)
Definition: rs_types.h:211
Definition: rs_context.hpp:224
bool operator!=(const device_list_iterator &other) const
Definition: rs_device.hpp:724
Video stream intrinsics.
Definition: rs_types.h:58
Definition: rs_types.h:200
void rs2_update_firmware_unsigned_cpp(const rs2_device *device, const void *fw_image, int fw_image_size, rs2_update_progress_callback *callback, int update_mode, rs2_error **error)
Motion device intrinsics: scale, bias, and variances.
Definition: rs_types.h:97
void on_calibration_change(rs2_calibration_status status) noexcept override
Definition: rs_device.hpp:565
void rs2_delete_sensor_list(rs2_sensor_list *info_list)
void enable_loopback(const std::string &from_file)
Definition: rs_device.hpp:789
void on_update_progress(const float progress) override
Definition: rs_device.hpp:158
struct rs2_device_list rs2_device_list
Definition: rs_types.h:259
debug_protocol(device d)
Definition: rs_device.hpp:622
void disable_loopback()
Definition: rs_device.hpp:799
tm2(device d)
Definition: rs_device.hpp:774
device_list_iterator end() const
Definition: rs_device.hpp:747
Definition: rs_device.hpp:771
const std::shared_ptr< rs2_sensor > & get() const
Definition: rs_sensor.hpp:320
Definition: rs_device.hpp:572
struct rs2_error rs2_error
Definition: rs_types.h:251
Definition: rs_device.hpp:709
void rs2_loopback_disable(const rs2_device *device, rs2_error **error)
Definition: rs_device.hpp:18
int rs2_get_device_count(const rs2_device_list *info_list, rs2_error **error)
Definition: rs_device.hpp:250
const rs2_raw_data_buffer * rs2_run_on_chip_calibration_cpp(rs2_device *device, const void *json_content, int content_size, float *health, rs2_update_progress_callback *progress_callback, int timeout_ms, rs2_error **error)
const rs2_device_list * get_list() const
Definition: rs_device.hpp:751
T first() const
Definition: rs_device.hpp:52
virtual ~device()
Definition: rs_device.hpp:134
const rs2_raw_data_buffer * rs2_run_tare_calibration_cpp(rs2_device *dev, float ground_truth_mm, const void *json_content, int content_size, rs2_update_progress_callback *progress_callback, int timeout_ms, rs2_error **error)
calibration_table run_on_chip_calibration(std::string json_content, float *health, int timeout_ms=5000) const
Definition: rs_device.hpp:415
device(std::shared_ptr< rs2_device > dev)
Definition: rs_device.hpp:139
const char * rs2_get_device_info(const rs2_device *device, rs2_camera_info info, rs2_error **error)