7 #ifndef IFM3D_DESERIALIZE_STRUCT_O3R_ODS_POLAR_OCCUPANCY_GRID_V1_HPP
8 #define IFM3D_DESERIALIZE_STRUCT_O3R_ODS_POLAR_OCCUPANCY_GRID_V1_HPP
11 #include <ifm3d/deserialize/deserialize_utils.hpp>
12 #include <ifm3d/device/device.h>
13 #include <ifm3d/device/err.h>
14 #include <ifm3d/fg/buffer.h>
15 #include <ifm3d/fg/organizer_utils.h>
21 constexpr
auto ODS_POLAR_OCCUPANCY_GRID_VERSION_INDEX = 0x0000;
22 constexpr
auto ODS_POLAR_OCCUPANCY_GRID_POLAR_OCC_GRID_INDEX = 0x0004;
23 constexpr
auto ARRAY_SIZE = 675;
24 constexpr
auto ODS_POLAR_OCCUPANCY_GRID_TIMESTAMP_NS_INDEX = 0x054A;
31 using Ptr = std::shared_ptr<ODSPolarOccupancyGridV1>;
34 IsValid(
const uint8_t* data,
size_t size)
37 mkval<std::uint32_t>(data + ODS_POLAR_OCCUPANCY_GRID_VERSION_INDEX);
39 return size >= ODS_POLAR_OCCUPANCY_GRID_V1_MINIMUM_SIZE && version >= 1;
43 Read(
const uint8_t* start_ptr,
size_t size)
45 if (!IsValid(start_ptr, size))
50 version = mkval<std::uint32_t>(start_ptr +
51 ODS_POLAR_OCCUPANCY_GRID_VERSION_INDEX);
52 mkarray<uint16_t, ARRAY_SIZE>(
53 start_ptr + ODS_POLAR_OCCUPANCY_GRID_POLAR_OCC_GRID_INDEX,
55 timestamp_ns = mkval<std::uint64_t>(
56 start_ptr + ODS_POLAR_OCCUPANCY_GRID_TIMESTAMP_NS_INDEX);
67 std::array<uint16_t, ARRAY_SIZE> polar_occ_grid;
69 uint64_t timestamp_ns;
72 static constexpr
size_t ODS_POLAR_OCCUPANCY_GRID_V1_MINIMUM_SIZE = 1354;
76 Deserialize(
const Buffer& ods_polar_occupancy_buffer_grid)
80 ods_polar_occupancy_grid_v1.Read(
81 ods_polar_occupancy_buffer_grid.
Ptr<uint8_t>(0),
82 ods_polar_occupancy_buffer_grid.
Size());
83 return ods_polar_occupancy_grid_v1;
88 #endif // IFM3D_DESERIALIZE_STRUCT_O3R_ODS_POLAR_OCCUPANCY_GRID_V1_HPP