7 #ifndef IFM3D_DESERIALIZE_STRUCT_O3R_ODS_OCCUPANCY_GRID_V1_HPP
8 #define IFM3D_DESERIALIZE_STRUCT_O3R_ODS_OCCUPANCY_GRID_V1_HPP
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>
22 constexpr
auto ODS_OCCUPANCY_GRID_TIMESTAMP_NS_INDEX = 0x0000;
23 constexpr
auto ODS_OCCUPANCY_GRID_WIDTH_INDEX = 0x0008;
24 constexpr
auto ODS_OCCUPANCY_GRID_HEIGHT_INDEX = 0x000C;
25 constexpr
auto ODS_OCCUPANCY_GRID_TRANSFORM_CELL_CENTER_TO_USER_INDEX =
27 constexpr
auto ODS_OCCUPANCY_GRID_IMAGE_INDEX = 0x0028;
34 using Ptr = std::shared_ptr<ODSOccupancyGridV1>;
37 Read(
const uint8_t* data,
size_t size)
39 if (size < ods_occupancy_grid_v1_minimum_size)
43 const uint8_t* start_ptr = data;
44 timestamp_ns = mkval<std::uint64_t>(
45 start_ptr + ODS_OCCUPANCY_GRID_TIMESTAMP_NS_INDEX);
46 width = mkval<std::uint32_t>(start_ptr + ODS_OCCUPANCY_GRID_WIDTH_INDEX);
48 mkval<std::uint32_t>(start_ptr + ODS_OCCUPANCY_GRID_HEIGHT_INDEX);
50 start_ptr + ODS_OCCUPANCY_GRID_TRANSFORM_CELL_CENTER_TO_USER_INDEX,
51 transform_cell_center_to_user);
52 ods_occupancy_grid_v1_size =
53 ods_occupancy_grid_v1_minimum_size + width * height;
54 if (size < ods_occupancy_grid_v1_size)
59 image =
ifm3d::Buffer(height, width, 1, ifm3d::pixel_format::FORMAT_8U);
60 std::memcpy(image.
ptr<uint8_t>(0),
61 start_ptr + ODS_OCCUPANCY_GRID_IMAGE_INDEX,
65 uint64_t timestamp_ns;
75 std::array<float, 6> transform_cell_center_to_user;
79 size_t ods_occupancy_grid_v1_size;
82 const size_t ods_occupancy_grid_v1_minimum_size = 40;
86 Deserialize(
const Buffer& ods_occupancy_buffer_grid)
90 ods_occupancy_grid_v1.Read(ods_occupancy_buffer_grid.
ptr<uint8_t>(0),
91 ods_occupancy_buffer_grid.
size());
92 return ods_occupancy_grid_v1;
97 #endif // IFM3D_DESERIALIZE_STRUCT_O3R_ODS_OCCUPANCY_GRID_V1_HPP