CARLA
 
载入中...
搜索中...
未找到
RawData.h
浏览该文件的文档.
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
16namespace carla {
17namespace 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
#define DEBUG_ASSERT(predicate)
Definition Debug.h:66
A piece of raw data.
const_iterator begin() const noexcept
const_iterator end() const noexcept
Compile-time map for mapping sensor objects to serializers.
Wrapper around the raw data generated by a sensor plus some useful meta-information.
Definition RawData.h:21
uint64_t GetFrame() const
Frame count when the data was generated.
Definition RawData.h:37
auto begin() const noexcept
Begin iterator to the data generated by the sensor.
Definition RawData.h:57
auto end() noexcept
Past-the-end iterator to the data generated by the sensor.
Definition RawData.h:62
auto data() const noexcept
Retrieve a pointer to the memory containing the data generated by the sensor.
Definition RawData.h:78
const auto & GetHeader() const
Definition RawData.h:25
auto data() noexcept
Retrieve a pointer to the memory containing the data generated by the sensor.
Definition RawData.h:73
auto end() const noexcept
Past-the-end iterator to the data generated by the sensor.
Definition RawData.h:67
double GetTimestamp() const
Timestamp when the data was generated.
Definition RawData.h:42
const rpc::Transform & GetSensorTransform() const
Sensor's transform when the data was generated.
Definition RawData.h:47
auto begin() noexcept
Begin iterator to the data generated by the sensor.
Definition RawData.h:52
uint64_t GetSensorTypeId() const
Type-id of the sensor that generated the data.
Definition RawData.h:32
size_t size() const
Size in bytes of the data generated by the sensor.
Definition RawData.h:83
RawData(Buffer &&buffer)
Definition RawData.h:94
Serializes the meta-information (header) sent with all the sensor data.
static const Header & Deserialize(const Buffer &message)
This file contains definitions of common data structures used in traffic manager.
Definition Carla.cpp:133