CARLA
SensorHeaderSerializer.h
Go to the documentation of this file.
1 // Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
2 // de Barcelona (UAB).
3 //
4 // This work is licensed under the terms of the MIT license.
5 // For a copy, see <https://opensource.org/licenses/MIT>.
6 
7 #pragma once
8 
9 #include "carla/Buffer.h"
10 #include "carla/rpc/Transform.h"
11 
12 namespace carla {
13 namespace sensor {
14 namespace s11n {
15 
16  /// Serializes the meta-information (header) sent with all the sensor data.
18  public:
19 
20 #pragma pack(push, 1)
21  struct Header {
22  uint64_t sensor_type;
23  uint64_t frame;
24  double timestamp;
26  };
27 #pragma pack(pop)
28 
29  constexpr static auto header_offset = sizeof(Header);
30 
31  static Buffer Serialize(
32  uint64_t index,
33  uint64_t frame,
34  double timestamp,
35  rpc::Transform transform);
36 
37  static const Header &Deserialize(const Buffer &message) {
38  return *reinterpret_cast<const Header *>(message.data());
39  }
40  };
41 
42 } // namespace s11n
43 } // namespace sensor
44 } // namespace carla
static Buffer Serialize(uint64_t index, uint64_t frame, double timestamp, rpc::Transform transform)
const value_type * data() const noexcept
Direct access to the allocated memory or nullptr if no memory is allocated.
Definition: carla/Buffer.h:156
Serializes the meta-information (header) sent with all the sensor data.
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:133
static const Header & Deserialize(const Buffer &message)
A piece of raw data.
Definition: carla/Buffer.h:42