CARLA
RawData.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"
11 #include "carla/ros2/ROS2.h"
12 
13 #include <cstdint>
14 #include <iterator>
15 
16 namespace carla {
17 namespace sensor {
18 
19  /// Wrapper around the raw data generated by a sensor plus some useful
20  /// meta-information.
21  class RawData {
23  private:
24 
25  const auto &GetHeader() const {
27  }
28 
29  public:
30 
31  /// Type-id of the sensor that generated the data.
32  uint64_t GetSensorTypeId() const {
33  return GetHeader().sensor_type;
34  }
35 
36  /// Frame count when the data was generated.
37  uint64_t GetFrame() const {
38  return GetHeader().frame;
39  }
40 
41  /// Timestamp when the data was generated.
42  double GetTimestamp() const {
43  return GetHeader().timestamp;
44  }
45 
46  /// Sensor's transform when the data was generated.
48  return GetHeader().sensor_transform;
49  }
50 
51  /// Begin iterator to the data generated by the sensor.
52  auto begin() noexcept {
54  }
55 
56  /// @copydoc begin()
57  auto begin() const noexcept {
59  }
60 
61  /// Past-the-end iterator to the data generated by the sensor.
62  auto end() noexcept {
63  return _buffer.end();
64  }
65 
66  /// @copydoc end()
67  auto end() const noexcept {
68  return _buffer.end();
69  }
70 
71  /// Retrieve a pointer to the memory containing the data generated by the
72  /// sensor.
73  auto data() noexcept {
74  return begin();
75  }
76 
77  /// @copydoc data()
78  auto data() const noexcept {
79  return begin();
80  }
81 
82  /// Size in bytes of the data generated by the sensor.
83  size_t size() const {
84  DEBUG_ASSERT(std::distance(begin(), end()) >= 0);
85  return static_cast<size_t>(std::distance(begin(), end()));
86  }
87 
88  private:
89 
90  template <typename... Items>
91  friend class CompositeSerializer;
92  friend class carla::ros2::ROS2;
93 
94  RawData(Buffer &&buffer) : _buffer(std::move(buffer)) {}
95 
97  };
98 
99 } // namespace sensor
100 } // namespace carla
const auto & GetHeader() const
Definition: RawData.h:25
Serializes the meta-information (header) sent with all the sensor data.
auto end() const noexcept
Past-the-end iterator to the data generated by the sensor.
Definition: RawData.h:67
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:133
auto begin() noexcept
Begin iterator to the data generated by the sensor.
Definition: RawData.h:52
auto begin() const noexcept
Begin iterator to the data generated by the sensor.
Definition: RawData.h:57
size_t size() const
Size in bytes of the data generated by the sensor.
Definition: RawData.h:83
#define DEBUG_ASSERT(predicate)
Definition: Debug.h:66
Compile-time map for mapping sensor objects to serializers.
auto end() noexcept
Past-the-end iterator to the data generated by the sensor.
Definition: RawData.h:62
const_iterator end() const noexcept
Definition: carla/Buffer.h:233
const_iterator begin() const noexcept
Definition: carla/Buffer.h:221
auto data() const noexcept
Retrieve a pointer to the memory containing the data generated by the sensor.
Definition: RawData.h:78
static const Header & Deserialize(const Buffer &message)
auto data() noexcept
Retrieve a pointer to the memory containing the data generated by the sensor.
Definition: RawData.h:73
uint64_t GetSensorTypeId() const
Type-id of the sensor that generated the data.
Definition: RawData.h:32
const rpc::Transform & GetSensorTransform() const
Sensor&#39;s transform when the data was generated.
Definition: RawData.h:47
double GetTimestamp() const
Timestamp when the data was generated.
Definition: RawData.h:42
A piece of raw data.
Definition: carla/Buffer.h:42
RawData(Buffer &&buffer)
Definition: RawData.h:94
uint64_t GetFrame() const
Frame count when the data was generated.
Definition: RawData.h:37
Wrapper around the raw data generated by a sensor plus some useful meta-information.
Definition: RawData.h:21