ifm3d
struct_tof_info_v4.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_TOF_INFO_V4_HPP
8 #define IFM3D_DESERIALIZE_STRUCT_TOF_INFO_V4_HPP
9 
10 #include <array>
11 #include <chrono>
12 #include <ifm3d/device/device.h>
13 #include <ifm3d/device/err.h>
14 #include <ifm3d/fg/organizer_utils.h>
15 #include <ifm3d/fg/buffer.h>
16 #include <ifm3d/deserialize/deserialize_utils.hpp>
17 #include <ifm3d/deserialize/struct_tof_info_v3.hpp>
18 
19 namespace ifm3d
20 {
21  namespace
22  {
23  constexpr auto TOF_INFO_MEASUREMENT_BLOCK_INDEX = 0x01A0;
24  constexpr auto TOF_INFO_MEASUREMENT_RANGE_MIN_INDEX = 0x01A4;
25  constexpr auto TOF_INFO_MEASUREMENT_RANGE_MAX_INDEX = 0x01A8;
26  };
27 
29  class TOFInfoV4 : public TOFInfoV3
30  {
31  public:
32  using Ptr = std::shared_ptr<TOFInfoV4>;
33 
34  void
35  Read(const uint8_t* data, size_t size)
36  {
37  if (size < tof_info_v4_size)
38  {
39  throw ifm3d::Error(IFM3D_CORRUPTED_STRUCT);
40  }
41 
42  TOFInfoV3::Read(data, size);
43  const uint8_t* start_ptr = data;
45  mkval<std::uint32_t>(start_ptr + TOF_INFO_MEASUREMENT_BLOCK_INDEX);
46  measurement_range_min =
47  mkval<float>(start_ptr + TOF_INFO_MEASUREMENT_RANGE_MIN_INDEX);
48  measurement_range_max =
49  mkval<float>(start_ptr + TOF_INFO_MEASUREMENT_RANGE_MAX_INDEX);
50  };
56  uint32_t measurement_block_index;
57  /*
58  * @brief Current minimum measurement range [m].
59  * The value is based on the camera-individual ToF calibration.
60  * It is influenced by temperature.
61  **/
62  float measurement_range_min;
63  /*
64  * @brief Current maximum measurement range [m].
65  * The value is based on the camera-individual ToF calibration.
66  * It is influenced by temperature.
67  **/
68  float measurement_range_max;
72  const size_t tof_info_v4_size = 428;
73 
74  static TOFInfoV4
75  Deserialize(const Buffer& tof_info_buffer)
76  {
77  TOFInfoV4 tof_info_v4;
78 
79  tof_info_v4.Read(tof_info_buffer.ptr<uint8_t>(0),
80  tof_info_buffer.size());
81  return tof_info_v4;
82  }
83  };
84 } // end namespace ifm3d
85 
86 #endif // IFM3D_DESERIALIZE_STRUCT_TOF_INFO_V3_HPP
ifm3d::Buffer::size
size_t size() const
Return the size of the buffer in bytes.
ifm3d::Buffer
The class Buffer represent a STL container to store data from the ifm devices in 2 dimension and supp...
Definition: buffer.h:98
ifm3d::Buffer::ptr
T * ptr(const std::uint32_t row)
returns a pointer to the specified Buffer row.
ifm3d::TOFInfoV3
Definition: struct_tof_info_v3.hpp:39
ifm3d::Error
Definition: err.h:112
ifm3d::TOFInfoV4
Definition: struct_tof_info_v4.hpp:29
ifm3d::TOFInfoV4::tof_info_v4_size
const size_t tof_info_v4_size
size of ToFInfoV4 in bytes
Definition: struct_tof_info_v4.hpp:72
ifm3d::TOFInfoV4::measurement_block_index
uint32_t measurement_block_index
Current measurement block index (range 0 to N-1, where N is the number of sub-modes).
Definition: struct_tof_info_v4.hpp:50