ifm3d
struct_calibration.hpp
1 // -*- c++ -*-
2 /*
3  * Copyright 2022-present ifm electronic, gmbh
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef IFM3D_DESERIALIZE_STRUCT_CALIBRATION_HPP
8 #define IFM3D_DESERIALIZE_STRUCT_CALIBRATION_HPP
9 
10 #include <array>
11 #include <ifm3d/deserialize/deserialize_utils.hpp>
12 #include <ifm3d/fg/organizer_utils.h>
13 #include <type_traits>
14 
15 namespace ifm3d::calibration
16 {
24  {
25  using Ptr = std::shared_ptr<struct ExtrinsicOpticToUser>;
26  float trans_x; // value in meter
27  float trans_y; // value in meter
28  float trans_z; // value in meter
29  float rot_x; // value in radians
30  float rot_y; // value in radians
31  float rot_z; // value in radians
32 
33  void
34  Read(const uint8_t* data)
35  {
36  trans_x = mkval<float>(data + (sizeof(float) * 0));
37  trans_y = mkval<float>(data + (sizeof(float) * 1));
38  trans_z = mkval<float>(data + (sizeof(float) * 2));
39  rot_x = mkval<float>(data + (sizeof(float) * 3));
40  rot_y = mkval<float>(data + (sizeof(float) * 4));
41  rot_z = mkval<float>(data + (sizeof(float) * 5));
42  }
43  };
44 
59  struct Calibration
60  {
61  using Ptr = std::shared_ptr<struct Calibration>;
62  uint32_t model_id;
63  std::array<float, 32> model_parameters;
64  void
65  Read(const uint8_t* data)
66  {
67  model_id = mkval<uint32_t>(data);
68  mkarray<float, 32>(data + sizeof(uint32_t), model_parameters);
69  }
70  };
71  /*@brief Intrisnsic parameter model for the device/head*/
72  using IntrinsicCalibration = struct Calibration;
73  /*@brief Inverse intrisnsic parameter model for the device/head*/
75 
82  struct IMUSample
83  {
84  uint16_t hw_timestamp;
85  uint64_t timestamp;
86  float temperature;
87  float acc_x;
88  float acc_y;
89  float acc_z;
90  float gyro_x;
91  float gyro_y;
92  float gyro_z;
93 
94  void
95  Read(const uint8_t* data)
96  {
97  size_t offset = 0;
98 
99  auto read = [&](auto& val) {
100  using T = std::remove_reference_t<decltype(val)>;
101  val = mkval<T>(data + offset);
102  offset += sizeof(T);
103  };
104 
105  read(hw_timestamp);
106  read(timestamp);
107  read(temperature);
108  read(acc_x);
109  read(acc_y);
110  read(acc_z);
111  read(gyro_x);
112  read(gyro_y);
113  read(gyro_z);
114  }
115  };
116 
117  /*@brief Extrinsic calibration for converting between IMU and User
118  * coordinates*/
120 
121 } // end namespace calibration
122 
123 // end namespace ifm3d
124 
125 #endif // IFM3D_DESERIALIZE_STRUCT_CALIBRATION_HPP
Definition: struct_calibration.hpp:60
All items are given in SI units, i.e.
Definition: struct_calibration.hpp:24
All items are given in SI units, i.e.
Definition: struct_calibration.hpp:83