LibMultiSense
LibMultiSense Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
MultiSenseSerialization.hh
Go to the documentation of this file.
1 
37 #pragma once
38 
39 #include <nlohmann/json.hpp>
40 
41 #include "MultiSenseChannel.hh"
42 #include "MultiSenseTypes.hh"
43 
44 namespace nlohmann
45 {
46  template <>
47  struct adl_serializer<std::chrono::microseconds>
48  {
49  static void to_json(json& j, const std::chrono::microseconds &d)
50  {
51  j = d.count();
52  }
53 
54  static void from_json(const json& j, std::chrono::microseconds &d)
55  {
56  d = std::chrono::microseconds(j.get<std::chrono::microseconds::rep>());
57  }
58  };
59 
60  template <>
61  struct adl_serializer<std::chrono::milliseconds>
62  {
63  static void to_json(json& j, const std::chrono::milliseconds &d)
64  {
65  j = d.count();
66  }
67 
68  static void from_json(const json& j, std::chrono::milliseconds &d)
69  {
70  d = std::chrono::milliseconds(j.get<std::chrono::milliseconds::rep>());
71  }
72  };
73 
74  template <>
75  struct adl_serializer<std::chrono::nanoseconds>
76  {
77  static void to_json(json& j, const std::chrono::nanoseconds &d)
78  {
79  j = d.count();
80  }
81 
82  static void from_json(const json& j, std::chrono::nanoseconds &d)
83  {
84  d = std::chrono::nanoseconds(j.get<std::chrono::nanoseconds::rep>());
85  }
86  };
87 
91  template <typename T>
92  struct adl_serializer<std::optional<T>>
93  {
94  static void to_json(json& j, const std::optional<T> &opt)
95  {
96  if (opt.has_value())
97  {
98  j = *opt;
99  }
100  else
101  {
102  j = nullptr;
103  }
104  }
105 
106  static void from_json(const json& j, std::optional<T> &opt)
107  {
108  if (j.is_null())
109  {
110  opt = std::nullopt;
111  }
112  else
113  {
114  T v{};
115  j.get_to(v);
116  opt = std::move(v);
117  }
118  }
119  };
120 
121 }
122 
123 namespace multisense
124 {
125 
127  {Status::UNKNOWN, "UNKNOWN"},
128  {Status::OK, "OK"},
129  {Status::TIMEOUT, "TIMEOUT"},
130  {Status::INTERNAL_ERROR, "INTERNAL_ERROR"},
131  {Status::FAILED, "FAILED"},
132  {Status::UNSUPPORTED, "UNSUPPORTED"},
133  {Status::EXCEPTION, "EXCEPTION"},
134  {Status::UNINITIALIZED, "UNINITIALIZED"},
135  {Status::INCOMPLETE_APPLICATION, "INCOMPLETE_APPLICATION"}
136 })
137 
139  {DataSource::UNKNOWN, "UNKNOWN"},
140  {DataSource::ALL, "ALL"},
141  {DataSource::LEFT_MONO_RAW, "LEFT_MONO_RAW"},
142  {DataSource::RIGHT_MONO_RAW, "RIGHT_MONO_RAW"},
143  {DataSource::LEFT_MONO_COMPRESSED, "LEFT_MONO_COMPRESSED"},
144  {DataSource::RIGHT_MONO_COMPRESSED, "RIGHT_MONO_COMPRESSED"},
145  {DataSource::LEFT_RECTIFIED_RAW, "LEFT_RECTIFIED_RAW"},
146  {DataSource::RIGHT_RECTIFIED_RAW, "RIGHT_RECTIFIED_RAW"},
147  {DataSource::LEFT_RECTIFIED_COMPRESSED, "LEFT_RECTIFIED_COMPRESSED"},
148  {DataSource::RIGHT_RECTIFIED_COMPRESSED, "RIGHT_RECTIFIED_COMPRESSED"},
149  {DataSource::LEFT_DISPARITY_RAW, "LEFT_DISPARITY_RAW"},
150  {DataSource::LEFT_DISPARITY_COMPRESSED, "LEFT_DISPARITY_COMPRESSED"},
151  {DataSource::AUX_COMPRESSED, "AUX_COMPRESSED"},
152  {DataSource::AUX_RECTIFIED_COMPRESSED, "AUX_RECTIFIED_COMPRESSED"},
153  {DataSource::AUX_LUMA_RAW, "AUX_LUMA_RAW"},
154  {DataSource::AUX_LUMA_RECTIFIED_RAW, "AUX_LUMA_RECTIFIED_RAW"},
155  {DataSource::AUX_CHROMA_RAW, "AUX_CHROMA_RAW"},
156  {DataSource::AUX_CHROMA_RECTIFIED_RAW, "AUX_CHROMA_RECTIFIED_RAW"},
157  {DataSource::AUX_RAW, "AUX_RAW"},
158  {DataSource::AUX_RECTIFIED_RAW, "AUX_RECTIFIED_RAW"},
159  {DataSource::COST_RAW, "COST_RAW"},
160  {DataSource::IMU, "IMU"}
161 })
162 
167 })
168 
173 })
174 
179 })
180 
193 })
194 
204 })
205 
213 })
214 
219 })
220 
223 })
224 
225 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(CameraCalibration,
226  K,
227  R,
228  P,
229  distortion_type,
230  D)
231 
232 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(StereoCalibration,
233  left,
234  right,
235  aux)
236 
237 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseConfig::StereoConfig,
238  postfilter_strength)
239 
240 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseConfig::ManualExposureConfig,
241  gain,
242  exposure_time)
243 
244 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseConfig::AutoExposureRoiConfig,
245  top_left_x_position,
246  top_left_y_position,
247  width,
248  height)
249 
250 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseConfig::AutoExposureConfig,
251  max_exposure_time,
252  decay,
253  target_intensity,
254  target_threshold,
255  max_gain,
256  roi)
257 
258 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseConfig::ManualWhiteBalanceConfig,
259  red,
260  blue)
261 
262 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseConfig::AutoWhiteBalanceConfig,
263  decay,
264  threshold)
265 
266 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseConfig::ImageConfig,
267  gamma,
268  auto_exposure_enabled,
269  manual_exposure,
270  auto_exposure,
271  auto_white_balance_enabled,
272  manual_white_balance,
273  auto_white_balance)
274 
275 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseConfig::AuxConfig,
276  image_config,
277  sharpening_enabled,
278  sharpening_percentage,
279  sharpening_limit)
280 
281 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseConfig::TimeConfig,
282  ptp_enabled)
283 
284 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseConfig::NetworkTransmissionConfig,
285  packet_delay_enabled)
286 
287 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ImuRate,
288  sample_rate,
289  bandwith_cutoff)
290 
291 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ImuRange,
292  range,
293  resolution)
294 
295 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseConfig::ImuConfig::OperatingMode,
296  enabled,
297  rate,
298  range)
299 
300 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseConfig::LightingConfig::InternalConfig,
301  intensity,
302  flash)
303 
304 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseConfig::LightingConfig::ExternalConfig,
305  intensity,
306  flash,
307  pulses_per_exposure,
308  startup_time)
309 
310 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseConfig::LightingConfig,
311  internal,
312  external)
313 
314 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseConfig::ImuConfig,
315  samples_per_frame,
316  accelerometer,
317  gyroscope,
318  magnetometer)
319 
320 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseConfig,
321  width,
322  height,
323  disparities,
324  frames_per_second,
325  stereo_config,
326  image_config,
327  aux_config,
328  time_config,
329  network_config,
330  imu_config,
331  lighting_config)
332 
333 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseStatus::PtpStatus,
334  grandmaster_present,
335  grandmaster_id,
336  grandmaster_offset,
337  path_delay,
338  steps_from_local_to_grandmaster)
339 
340 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseStatus::CameraStatus,
341  cameras_ok,
342  processing_pipeline_ok)
343 
344 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseStatus::TemperatureStatus,
345  fpga_temperature,
346  left_imager_temperature,
347  right_imager_temperature,
348  power_supply_temperature)
349 
350 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseStatus::PowerStatus,
351  input_voltage,
352  input_current,
353  fpga_power)
354 
355 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseStatus::ClientNetworkStatus,
356  received_messages,
357  dropped_messages,
358  invalid_packets)
359 
360 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseStatus::TimeStatus,
361  camera_time,
362  client_host_time,
363  network_delay)
364 
365 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseStatus,
366  system_ok,
367  ptp,
368  camera,
369  temperature,
370  power,
371  client_network,
372  time)
373 
374 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseInfo::NetworkInfo,
375  ip_address,
376  gateway,
377  netmask)
378 
379 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseInfo::DeviceInfo::PcbInfo,
380  name,
381  revision)
382 
383 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseInfo::DeviceInfo,
384  camera_name,
385  build_date,
386  serial_number,
387  hardware_revision,
388  pcb_info,
389  imager_name,
390  imager_type,
391  imager_width,
392  imager_height,
393  lens_name,
394  lens_type,
395  nominal_stereo_baseline,
396  nominal_focal_length,
397  nominal_relative_aperture,
398  lighting_type,
399  number_of_lights)
400 
401 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseInfo::Version,
402  major,
403  minor,
404  patch)
405 
406 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseInfo::SensorVersion,
407  firmware_build_date,
408  firmware_version,
409  hardware_version)
410 
411 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseInfo::SupportedOperatingMode,
412  width,
413  height,
414  disparities,
415  supported_sources)
416 
417 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseInfo::ImuInfo::Source,
418  name,
419  device,
420  rates,
421  ranges)
422 
423 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseInfo::ImuInfo,
424  accelerometer,
425  gyroscope,
426  magnetometer)
427 
428 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultiSenseInfo,
429  device,
430  version,
431  operating_modes,
432  imu,
433  network)
434 
435 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Channel::ReceiveBufferConfig,
436  num_small_buffers,
437  small_buffer_size,
438  num_large_buffers,
439  large_buffer_size)
440 
441 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Channel::Config,
442  ip_address,
443  mtu,
444  receive_timeout,
445  command_port,
446  interface,
447  receive_buffer_configuration)
448 
449 }
multisense::DataSource::RIGHT_RECTIFIED_COMPRESSED
@ RIGHT_RECTIFIED_COMPRESSED
multisense::NLOHMANN_JSON_SERIALIZE_ENUM
NLOHMANN_JSON_SERIALIZE_ENUM(Status, { {Status::UNKNOWN, "UNKNOWN"}, {Status::OK, "OK"}, {Status::TIMEOUT, "TIMEOUT"}, {Status::INTERNAL_ERROR, "INTERNAL_ERROR"}, {Status::FAILED, "FAILED"}, {Status::UNSUPPORTED, "UNSUPPORTED"}, {Status::EXCEPTION, "EXCEPTION"}, {Status::UNINITIALIZED, "UNINITIALIZED"}, {Status::INCOMPLETE_APPLICATION, "INCOMPLETE_APPLICATION"} }) NLOHMANN_JSON_SERIALIZE_ENUM(DataSource
multisense::Status::INCOMPLETE_APPLICATION
@ INCOMPLETE_APPLICATION
multisense::MultiSenseInfo::DeviceInfo::HardwareRevision::MONOCAM
@ MONOCAM
multisense::DataSource::RIGHT_MONO_COMPRESSED
@ RIGHT_MONO_COMPRESSED
multisense::Status::UNKNOWN
@ UNKNOWN
multisense::MultiSenseInfo::DeviceInfo::LightingType::EXTERNAL
@ EXTERNAL
Drive lights via an external output.
multisense::DataSource::AUX_RECTIFIED_RAW
@ AUX_RECTIFIED_RAW
multisense::MultiSenseInfo::DeviceInfo::ImagerType::CMV4000_COLOR
@ CMV4000_COLOR
multisense::MultiSenseInfo::DeviceInfo::ImagerType::UNKNOWN
@ UNKNOWN
multisense::Status::UNINITIALIZED
@ UNINITIALIZED
multisense::MultiSenseInfo::DeviceInfo::ImagerType::CMV4000_GREY
@ CMV4000_GREY
multisense::MultiSenseInfo::DeviceInfo::HardwareRevision::S7
@ S7
multisense::MultiSenseInfo::DeviceInfo::LightingType::INTERNAL
@ INTERNAL
Lights driven internally.
multisense::Status
Status
Definition: MultiSenseTypes.hh:67
multisense::CameraCalibration::DistortionType::NONE
@ NONE
multisense::DataSource::AUX_COMPRESSED
@ AUX_COMPRESSED
multisense::MultiSenseInfo::DeviceInfo::ImagerType::FLIR_TAU2
@ FLIR_TAU2
multisense::CameraCalibration::DistortionType::PLUMBBOB
@ PLUMBBOB
nlohmann
Definition: MultiSenseSerialization.hh:44
MultiSenseChannel.hh
multisense::MultiSenseInfo::DeviceInfo::LensType::STANDARD
@ STANDARD
multisense::DataSource::LEFT_RECTIFIED_RAW
@ LEFT_RECTIFIED_RAW
multisense::MultiSenseInfo::DeviceInfo::LensType::FISHEYE
@ FISHEYE
multisense::MultiSenseInfo::DeviceInfo::HardwareRevision::KS21
@ KS21
multisense::DataSource::AUX_LUMA_RAW
@ AUX_LUMA_RAW
multisense::MultiSenseConfig::MaxDisparities::D128
@ D128
128 pixels
multisense::DataSource::LEFT_DISPARITY_COMPRESSED
@ LEFT_DISPARITY_COMPRESSED
multisense::DataSource::AUX_LUMA_RECTIFIED_RAW
@ AUX_LUMA_RECTIFIED_RAW
multisense::DataSource::RIGHT_MONO_RAW
@ RIGHT_MONO_RAW
nlohmann::adl_serializer< std::chrono::milliseconds >::from_json
static void from_json(const json &j, std::chrono::milliseconds &d)
Definition: MultiSenseSerialization.hh:68
multisense::DataSource::LEFT_MONO_RAW
@ LEFT_MONO_RAW
MultiSenseTypes.hh
multisense::MultiSenseInfo::DeviceInfo::ImagerType::AR0239_COLOR
@ AR0239_COLOR
multisense::MultiSenseInfo::DeviceInfo::ImagerType::CMV2000_GREY
@ CMV2000_GREY
multisense::MultiSenseConfig::MaxDisparities
MaxDisparities
Predefined disparity pixel search windows.
Definition: MultiSenseTypes.hh:776
multisense::MultiSenseInfo::DeviceInfo::LightingType::OUTPUT_TRIGGER
@ OUTPUT_TRIGGER
A GPIO line is used to trigger an external light.
multisense::Channel::ChannelImplementation
ChannelImplementation
Identifiers for the different Channel implementations.
Definition: MultiSenseChannel.hh:52
multisense::MultiSenseInfo::DeviceInfo::HardwareRevision::S30
@ S30
multisense::DataSource
DataSource
Identifies which camera or data source the image is from.
Definition: MultiSenseTypes.hh:83
multisense::MultiSenseConfig::LightingConfig::ExternalConfig::FlashMode::SYNC_WITH_AUX
@ SYNC_WITH_AUX
nlohmann::adl_serializer< std::optional< T > >::to_json
static void to_json(json &j, const std::optional< T > &opt)
Definition: MultiSenseSerialization.hh:94
multisense::DataSource::ALL
@ ALL
nlohmann::adl_serializer< std::chrono::microseconds >::from_json
static void from_json(const json &j, std::chrono::microseconds &d)
Definition: MultiSenseSerialization.hh:54
multisense::MultiSenseInfo::DeviceInfo::HardwareRevision
HardwareRevision
MultiSense Hardware revisions.
Definition: MultiSenseTypes.hh:1310
multisense::DataSource::COST_RAW
@ COST_RAW
multisense::MultiSenseInfo::DeviceInfo::HardwareRevision::ST25
@ ST25
multisense::MultiSenseInfo::DeviceInfo::LightingType
LightingType
MultiSense lighting types.
Definition: MultiSenseTypes.hh:1344
multisense::MultiSenseInfo::DeviceInfo::HardwareRevision::UNKNOWN
@ UNKNOWN
nlohmann::adl_serializer< std::chrono::nanoseconds >::to_json
static void to_json(json &j, const std::chrono::nanoseconds &d)
Definition: MultiSenseSerialization.hh:77
multisense::MultiSenseInfo::DeviceInfo::HardwareRevision::ST21
@ ST21
multisense::DataSource::LEFT_MONO_COMPRESSED
@ LEFT_MONO_COMPRESSED
multisense::Status::EXCEPTION
@ EXCEPTION
multisense::CameraCalibration::DistortionType
DistortionType
Distortion type.
Definition: MultiSenseTypes.hh:120
multisense::Status::UNSUPPORTED
@ UNSUPPORTED
multisense::Status::OK
@ OK
multisense::Channel::ChannelImplementation::LEGACY
@ LEGACY
Use the Legacy MultiSense wire protocol implemented as part of LibMultiSense.
multisense::DataSource::AUX_CHROMA_RECTIFIED_RAW
@ AUX_CHROMA_RECTIFIED_RAW
multisense::MultiSenseInfo::DeviceInfo::LensType::UNKNOWN
@ UNKNOWN
multisense::MultiSenseConfig::LightingConfig::ExternalConfig::FlashMode::SYNC_WITH_MAIN_STEREO
@ SYNC_WITH_MAIN_STEREO
multisense::DataSource::AUX_RAW
@ AUX_RAW
multisense::Status::TIMEOUT
@ TIMEOUT
multisense::MultiSenseInfo::DeviceInfo::HardwareRevision::S27
@ S27
multisense::MultiSenseConfig::LightingConfig::ExternalConfig::FlashMode
FlashMode
Different flash modes for the camera.
Definition: MultiSenseTypes.hh:936
multisense::MultiSenseConfig::LightingConfig::ExternalConfig::FlashMode::NONE
@ NONE
multisense::MultiSenseInfo::DeviceInfo::LightingType::PATTERN_PROJECTOR
@ PATTERN_PROJECTOR
A pattern projector.
multisense::MultiSenseInfo::DeviceInfo::ImagerType
ImagerType
Different imager types.
Definition: MultiSenseTypes.hh:1328
multisense
Definition: MultiSenseChannel.hh:44
multisense::Status::FAILED
@ FAILED
nlohmann::adl_serializer< std::chrono::microseconds >::to_json
static void to_json(json &j, const std::chrono::microseconds &d)
Definition: MultiSenseSerialization.hh:49
multisense::MultiSenseInfo::DeviceInfo::ImagerType::CMV2000_COLOR
@ CMV2000_COLOR
multisense::MultiSenseInfo::DeviceInfo::HardwareRevision::KS21i
@ KS21i
multisense::DataSource::RIGHT_RECTIFIED_RAW
@ RIGHT_RECTIFIED_RAW
multisense::DataSource::AUX_CHROMA_RAW
@ AUX_CHROMA_RAW
multisense::MultiSenseInfo::DeviceInfo::LightingType::PATTERN_PROJECTOR_OUTPUT_TRIGGER
@ PATTERN_PROJECTOR_OUTPUT_TRIGGER
A pattern projector with a GPIO line used to trigger a external light.
nlohmann::adl_serializer< std::chrono::nanoseconds >::from_json
static void from_json(const json &j, std::chrono::nanoseconds &d)
Definition: MultiSenseSerialization.hh:82
multisense::DataSource::AUX_RECTIFIED_COMPRESSED
@ AUX_RECTIFIED_COMPRESSED
multisense::MultiSenseInfo::DeviceInfo::LightingType::NONE
@ NONE
No lights.
multisense::MultiSenseInfo::DeviceInfo::LensType
LensType
MultiSense lens types.
Definition: MultiSenseTypes.hh:1376
multisense::DataSource::IMU
@ IMU
multisense::CameraCalibration::DistortionType::RATIONAL_POLYNOMIAL
@ RATIONAL_POLYNOMIAL
multisense::MultiSenseConfig::MaxDisparities::D64
@ D64
64 pixels
multisense::MultiSenseConfig::MaxDisparities::D256
@ D256
256 pixels
nlohmann::adl_serializer< std::optional< T > >::from_json
static void from_json(const json &j, std::optional< T > &opt)
Definition: MultiSenseSerialization.hh:106
nlohmann::adl_serializer< std::chrono::milliseconds >::to_json
static void to_json(json &j, const std::chrono::milliseconds &d)
Definition: MultiSenseSerialization.hh:63
multisense::MultiSenseInfo::DeviceInfo::HardwareRevision::S21
@ S21
multisense::MultiSenseInfo::DeviceInfo::HardwareRevision::KS21_SILVER
@ KS21_SILVER
multisense::DataSource::UNKNOWN
@ UNKNOWN
multisense::Status::INTERNAL_ERROR
@ INTERNAL_ERROR
multisense::DataSource::LEFT_RECTIFIED_COMPRESSED
@ LEFT_RECTIFIED_COMPRESSED
multisense::DataSource::LEFT_DISPARITY_RAW
@ LEFT_DISPARITY_RAW
multisense::MultiSenseInfo::DeviceInfo::ImagerType::AR0234_GREY
@ AR0234_GREY