7 #ifndef IFM3D_DESERIALIZE_STRUCT_IMU_INFO_V1_HPP
8 #define IFM3D_DESERIALIZE_STRUCT_IMU_INFO_V1_HPP
11 #include <ifm3d/deserialize/deserialize_utils.hpp>
12 #include <ifm3d/deserialize/struct_calibration.hpp>
13 #include <ifm3d/device/device.h>
14 #include <ifm3d/device/err.h>
15 #include <ifm3d/fg/buffer.h>
16 #include <ifm3d/fg/organizer_utils.h>
22 constexpr
auto IMU_INFO_IMU_VERSION_INDEX = 0x0000;
23 constexpr
auto IMU_INFO_IMU_SAMPLES_INDEX = 0x0004;
24 constexpr
auto IMU_INFO_NUM_SAMPLE_INDEX = 0x1304;
25 constexpr
auto IMU_INFO_EXTRINSIC_IMU_TO_USER_INDEX = 0x1308;
26 constexpr
auto IMU_INFO_EXTRINSIC_IMU_TO_VPU_INDEX = 0x1320;
27 constexpr
auto IMU_INFO_IMU_FIFO_RCV_TIMESTAMP_INDEX = 0x1338;
28 constexpr
auto ARRAY_SIZE_IMU_SAMPLES = 128;
35 using Ptr = std::shared_ptr<IMUInfoV1>;
38 IsValid(
const uint8_t*,
size_t size)
40 return size >= IMU_INFO_V1_SIZE;
44 Read(
const uint8_t* start_ptr,
size_t size)
46 if (!IsValid(start_ptr, size))
52 mkval<std::uint32_t>(start_ptr + IMU_INFO_IMU_VERSION_INDEX);
54 for (std::uint32_t i = 0; i < ARRAY_SIZE_IMU_SAMPLES; ++i)
56 constexpr
size_t IMU_SAMPLE_BYTE_SIZE =
57 sizeof(std::uint16_t) +
sizeof(std::uint64_t) + 7 *
sizeof(float);
60 "IMUSample struct too small for serialized data");
62 imu_samples[i].Read(start_ptr + IMU_INFO_IMU_SAMPLES_INDEX +
63 i * IMU_SAMPLE_BYTE_SIZE);
67 mkval<std::uint32_t>(start_ptr + IMU_INFO_NUM_SAMPLE_INDEX);
69 extrinsic_imu_to_user.Read(start_ptr +
70 IMU_INFO_EXTRINSIC_IMU_TO_USER_INDEX);
72 extrinsic_imu_to_vpu.Read(start_ptr +
73 IMU_INFO_EXTRINSIC_IMU_TO_VPU_INDEX);
75 imu_fifo_rcv_timestamp = mkval<std::uint64_t>(
76 start_ptr + IMU_INFO_IMU_FIFO_RCV_TIMESTAMP_INDEX);
80 std::uint32_t imu_version{};
82 std::array<calibration::IMUSample, ARRAY_SIZE_IMU_SAMPLES> imu_samples;
84 std::uint32_t num_samples{};
95 std::uint64_t imu_fifo_rcv_timestamp{};
98 static constexpr
size_t IMU_INFO_V1_SIZE = 0x1340;
101 Deserialize(
const Buffer& imu_info_buffer)
105 imu_info_v1.Read(imu_info_buffer.
Ptr<uint8_t>(0),
106 imu_info_buffer.
Size());
The class Buffer represent a STL container to store data from the ifm devices in 2 dimension and supp...
Definition: buffer.h:99
T * Ptr(std::uint32_t row)
returns a pointer to the specified Buffer row.
size_t Size() const
Return the size of the buffer in bytes.
Exception wrapper for library and system errors encountered by the library.
Definition: err.h:115
Definition: struct_imu_info_v1.hpp:33
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