CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
Unreal
CarlaUnreal
Plugins
Carla
Source
Carla
Sensor
DataStream.h
Go to the documentation of this file.
1
// Copyright (c) 2026 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/Sensor/AsyncDataStream.h
"
10
11
#include <
util/disable-ue4-macros.h
>
12
#include <
carla/streaming/Stream.h
>
13
#include <
util/enable-ue4-macros.h
>
14
15
#include <optional>
16
17
// =============================================================================
18
// -- FDataStreamTmpl ----------------------------------------------------------
19
// =============================================================================
20
21
/// A streaming channel for sending sensor data to clients. Each sensor has its
22
/// own FDataStream. Note however that this class does not provide a send
23
/// function. In order to send data, a FAsyncDataStream needs to be created
24
/// using "MakeAsyncDataStream" function. FAsyncDataStream allows sending data
25
/// from any thread.
26
template
<
typename
T>
27
class
FDataStreamTmpl
28
{
29
public
:
30
31
using
StreamType
= T;
32
33
FDataStreamTmpl
() =
default
;
34
35
FDataStreamTmpl
(
StreamType
InStream) :
Stream
(
std
::move(InStream)) {}
36
37
/// Create a FAsyncDataStream object.
38
///
39
/// @pre This functions needs to be called in the game-thread.
40
template
<
typename
SensorT>
41
FAsyncDataStreamTmpl<T>
MakeAsyncDataStream
(
const
SensorT &Sensor,
double
Timestamp)
42
{
43
check(
Stream
.has_value());
44
return
FAsyncDataStreamTmpl<T>
{Sensor, Timestamp, *
Stream
};
45
}
46
47
bool
IsStreamReady
()
48
{
49
return
Stream
.has_value();
50
}
51
52
/// Return the token that allows subscribing to this stream.
53
auto
GetToken
()
const
54
{
55
check(
Stream
.has_value());
56
return
Stream
->token();
57
}
58
59
uint64_t
GetSensorType
()
60
{
61
check(
Stream
.has_value());
62
return
Stream
->get_stream_id();
63
}
64
65
bool
AreClientsListening
()
66
{
67
check(
Stream
.has_value());
68
return
Stream
->AreClientsListening();
69
}
70
71
private
:
72
73
std::optional<StreamType>
Stream
;
74
};
75
76
// =============================================================================
77
// -- FDataStream and FDataMultiStream -----------------------------------------
78
// =============================================================================
79
80
using
FDataStream
=
FDataStreamTmpl<carla::streaming::Stream>
;
81
82
using
FDataMultiStream
=
FDataStreamTmpl<carla::streaming::Stream>
;
AsyncDataStream.h
FDataMultiStream
FDataStreamTmpl< carla::streaming::Stream > FDataMultiStream
Definition
DataStream.h:82
FDataStream
FDataStreamTmpl< carla::streaming::Stream > FDataStream
Definition
DataStream.h:80
Stream.h
FAsyncDataStreamTmpl
A streaming channel for sending sensor data to clients, supports sending data asynchronously.
Definition
AsyncDataStream.h:38
FDataStreamTmpl
A streaming channel for sending sensor data to clients.
Definition
DataStream.h:28
FDataStreamTmpl< carla::streaming::Stream >::Stream
std::optional< StreamType > Stream
Definition
DataStream.h:73
FDataStreamTmpl::FDataStreamTmpl
FDataStreamTmpl()=default
FDataStreamTmpl::IsStreamReady
bool IsStreamReady()
Definition
DataStream.h:47
FDataStreamTmpl::StreamType
T StreamType
Definition
DataStream.h:31
FDataStreamTmpl::GetToken
auto GetToken() const
Return the token that allows subscribing to this stream.
Definition
DataStream.h:53
FDataStreamTmpl::GetSensorType
uint64_t GetSensorType()
Definition
DataStream.h:59
FDataStreamTmpl::FDataStreamTmpl
FDataStreamTmpl(StreamType InStream)
Definition
DataStream.h:35
FDataStreamTmpl::AreClientsListening
bool AreClientsListening()
Definition
DataStream.h:65
FDataStreamTmpl::MakeAsyncDataStream
FAsyncDataStreamTmpl< T > MakeAsyncDataStream(const SensorT &Sensor, double Timestamp)
Create a FAsyncDataStream object.
Definition
DataStream.h:41
disable-ue4-macros.h
enable-ue4-macros.h
std
Definition
CarlaRecorderCollision.h:31
Generated by
1.18.0