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 
573  {
574  public:
575  calibration_change_device() = default;
577  : device(d.get())
578  {
579  rs2_error* e = nullptr;
581  {
582  _dev.reset();
583  }
584  error::handle(e);
585  }
586 
587  /*
588  Your callback should look like this, for example:
589  sensor.register_calibration_change_callback(
590  []( rs2_calibration_status ) noexcept
591  {
592  ...
593  })
594  */
595  template< typename T >
597  {
598  // We wrap the callback with an interface and pass it to librealsense, who will
599  // now manage its lifetime. Rather than deleting it, though, it will call its
600  // release() function, where (back in our context) it can be safely deleted:
601  rs2_error* e = nullptr;
603  _dev.get(),
604  new calibration_change_callback< T >(std::move(callback)),
605  &e);
606  error::handle(e);
607  }
608  };
609 
611  {
612  public:
613  device_calibration() = default;
615  {
616  rs2_error* e = nullptr;
618  {
619  _dev = d.get();
620  }
621  error::handle( e );
622  }
623 
628  {
629  rs2_error* e = nullptr;
630  rs2_trigger_device_calibration( _dev.get(), type, &e );
631  error::handle( e );
632  }
633  };
634 
635  class debug_protocol : public device
636  {
637  public:
639  : device(d.get())
640  {
641  rs2_error* e = nullptr;
642  if(rs2_is_device_extendable_to(_dev.get(), RS2_EXTENSION_DEBUG, &e) == 0 && !e)
643  {
644  _dev.reset();
645  }
646  error::handle(e);
647  }
648 
649  std::vector<uint8_t> send_and_receive_raw_data(const std::vector<uint8_t>& input) const
650  {
651  std::vector<uint8_t> results;
652 
653  rs2_error* e = nullptr;
654  std::shared_ptr<const rs2_raw_data_buffer> list(
655  rs2_send_and_receive_raw_data(_dev.get(), (void*)input.data(), (uint32_t)input.size(), &e),
657  error::handle(e);
658 
659  auto size = rs2_get_raw_data_size(list.get(), &e);
660  error::handle(e);
661 
662  auto start = rs2_get_raw_data(list.get(), &e);
663 
664  results.insert(results.begin(), start, start + size);
665 
666  return results;
667  }
668  };
669 
671  {
672  public:
673  explicit device_list(std::shared_ptr<rs2_device_list> list)
674  : _list(move(list)) {}
675 
677  : _list(nullptr) {}
678 
679  operator std::vector<device>() const
680  {
681  std::vector<device> res;
682  for (auto&& dev : *this) res.push_back(dev);
683  return res;
684  }
685 
686  bool contains(const device& dev) const
687  {
688  rs2_error* e = nullptr;
689  auto res = !!(rs2_device_list_contains(_list.get(), dev.get().get(), &e));
690  error::handle(e);
691  return res;
692  }
693 
694  device_list& operator=(std::shared_ptr<rs2_device_list> list)
695  {
696  _list = move(list);
697  return *this;
698  }
699 
700  device operator[](uint32_t index) const
701  {
702  rs2_error* e = nullptr;
703  std::shared_ptr<rs2_device> dev(
704  rs2_create_device(_list.get(), index, &e),
706  error::handle(e);
707 
708  return device(dev);
709  }
710 
711  uint32_t size() const
712  {
713  rs2_error* e = nullptr;
714  auto size = rs2_get_device_count(_list.get(), &e);
715  error::handle(e);
716  return size;
717  }
718 
719  device front() const { return std::move((*this)[0]); }
720  device back() const
721  {
722  return std::move((*this)[size() - 1]);
723  }
724 
726  {
728  const device_list& device_list,
729  uint32_t uint32_t)
730  : _list(device_list),
731  _index(uint32_t)
732  {
733  }
734 
735  public:
737  {
738  return _list[_index];
739  }
740  bool operator!=(const device_list_iterator& other) const
741  {
742  return other._index != _index || &other._list != &_list;
743  }
744  bool operator==(const device_list_iterator& other) const
745  {
746  return !(*this != other);
747  }
749  {
750  _index++;
751  return *this;
752  }
753  private:
754  friend device_list;
755  const device_list& _list;
756  uint32_t _index;
757  };
758 
760  {
761  return device_list_iterator(*this, 0);
762  }
764  {
765  return device_list_iterator(*this, size());
766  }
767  const rs2_device_list* get_list() const
768  {
769  return _list.get();
770  }
771 
772  operator std::shared_ptr<rs2_device_list>() { return _list; };
773 
774  private:
775  std::shared_ptr<rs2_device_list> _list;
776  };
777 
787  class tm2 : public calibrated_device // TODO: add to wrappers [Python done]
788  {
789  public:
791  : calibrated_device(d)
792  {
793  rs2_error* e = nullptr;
794  if (rs2_is_device_extendable_to(_dev.get(), RS2_EXTENSION_TM2, &e) == 0 && !e)
795  {
796  _dev.reset();
797  }
798  error::handle(e);
799  }
800 
805  void enable_loopback(const std::string& from_file)
806  {
807  rs2_error* e = nullptr;
808  rs2_loopback_enable(_dev.get(), from_file.c_str(), &e);
809  error::handle(e);
810  }
811 
816  {
817  rs2_error* e = nullptr;
818  rs2_loopback_disable(_dev.get(), &e);
819  error::handle(e);
820  }
821 
826  bool is_loopback_enabled() const
827  {
828  rs2_error* e = nullptr;
829  int is_enabled = rs2_loopback_is_enabled(_dev.get(), &e);
830  error::handle(e);
831  return is_enabled != 0;
832  }
833 
838  void connect_controller(const std::array<uint8_t, 6>& mac_addr)
839  {
840  rs2_error* e = nullptr;
841  rs2_connect_tm2_controller(_dev.get(), mac_addr.data(), &e);
842  error::handle(e);
843  }
844 
850  {
851  rs2_error* e = nullptr;
852  rs2_disconnect_tm2_controller(_dev.get(), id, &e);
853  error::handle(e);
854  }
855 
861  void set_intrinsics(int fisheye_sensor_id, const rs2_intrinsics& intrinsics)
862  {
863  rs2_error* e = nullptr;
864  auto fisheye_sensor = get_sensor_profile(RS2_STREAM_FISHEYE, fisheye_sensor_id);
865  rs2_set_intrinsics(fisheye_sensor.first.get().get(), fisheye_sensor.second.get(), &intrinsics, &e);
866  error::handle(e);
867  }
868 
877  void set_extrinsics(rs2_stream from_stream, int from_id, rs2_stream to_stream, int to_id, rs2_extrinsics& extrinsics)
878  {
879  rs2_error* e = nullptr;
880  auto from_sensor = get_sensor_profile(from_stream, from_id);
881  auto to_sensor = get_sensor_profile(to_stream, to_id);
882  rs2_set_extrinsics(from_sensor.first.get().get(), from_sensor.second.get(), to_sensor.first.get().get(), to_sensor.second.get(), &extrinsics, &e);
883  error::handle(e);
884  }
885 
891  void set_motion_device_intrinsics(rs2_stream stream_type, const rs2_motion_device_intrinsic& motion_intriniscs)
892  {
893  rs2_error* e = nullptr;
894  auto motion_sensor = get_sensor_profile(stream_type, 0);
895  rs2_set_motion_device_intrinsics(motion_sensor.first.get().get(), motion_sensor.second.get(), &motion_intriniscs, &e);
896  error::handle(e);
897  }
898 
899  private:
900 
901  std::pair<sensor, stream_profile> get_sensor_profile(rs2_stream stream_type, int stream_index) {
902  for (auto s : query_sensors()) {
903  for (auto p : s.get_stream_profiles()) {
904  if (p.stream_type() == stream_type && p.stream_index() == stream_index)
905  return std::pair<sensor, stream_profile>(s, p);
906  }
907  }
908  return std::pair<sensor, stream_profile>();
909  }
910  };
911 }
912 #endif // LIBREALSENSE_RS2_DEVICE_HPP
Definition: rs_types.hpp:92
device operator*() const
Definition: rs_device.hpp:736
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:720
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)
Definition: rs_types.h:223
device_list(std::shared_ptr< rs2_device_list > list)
Definition: rs_device.hpp:673
std::vector< uint8_t > send_and_receive_raw_data(const std::vector< uint8_t > &input) const
Definition: rs_device.hpp:649
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:744
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:861
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:838
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:849
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:694
calibration_change_device(device d)
Definition: rs_device.hpp:576
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:614
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:759
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:635
void set_motion_device_intrinsics(rs2_stream stream_type, const rs2_motion_device_intrinsic &motion_intriniscs)
Definition: rs_device.hpp:891
bool is_loopback_enabled() const
Definition: rs_device.hpp:826
device operator[](uint32_t index) const
Definition: rs_device.hpp:700
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:356
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:719
uint32_t size() const
Definition: rs_device.hpp:711
void trigger_device_calibration(rs2_calibration_type type)
Definition: rs_device.hpp:627
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:205
Definition: rs_device.hpp:572
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:877
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 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:190
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:686
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:209
Definition: rs_types.hpp:83
Definition: rs_types.h:169
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:748
device_list()
Definition: rs_device.hpp:676
Definition: rs_device.hpp:315
updatable()
Definition: rs_device.hpp:169
Definition: rs_device.hpp:670
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:217
Definition: rs_context.hpp:224
bool operator!=(const device_list_iterator &other) const
Definition: rs_device.hpp:740
Video stream intrinsics.
Definition: rs_types.h:58
Definition: rs_types.h:206
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:103
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:805
void on_update_progress(const float progress) override
Definition: rs_device.hpp:158
struct rs2_device_list rs2_device_list
Definition: rs_types.h:266
debug_protocol(device d)
Definition: rs_device.hpp:638
void disable_loopback()
Definition: rs_device.hpp:815
tm2(device d)
Definition: rs_device.hpp:790
device_list_iterator end() const
Definition: rs_device.hpp:763
Definition: rs_device.hpp:787
const std::shared_ptr< rs2_sensor > & get() const
Definition: rs_sensor.hpp:320
void register_calibration_change_callback(T callback)
Definition: rs_device.hpp:596
Definition: rs_device.hpp:610
struct rs2_error rs2_error
Definition: rs_types.h:258
Definition: rs_device.hpp:725
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:767
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)