CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
Unreal
CarlaUnreal
Plugins
Carla
Source
Carla
Recorder
CarlaRecorderWeather.cpp
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
#include "
CarlaRecorderWeather.h
"
8
#include "
CarlaRecorder.h
"
9
#include "
CarlaRecorderHelpers.h
"
10
11
void
CarlaRecorderWeather::Write
(std::ostream &OutFile)
12
{
13
WriteValue
(OutFile, this->
Cloudiness
);
14
WriteValue
(OutFile, this->
Precipitation
);
15
WriteValue
(OutFile, this->
PrecipitationDeposits
);
16
WriteValue
(OutFile, this->
WindIntensity
);
17
WriteValue
(OutFile, this->
SunAzimuthAngle
);
18
WriteValue
(OutFile, this->
SunAltitudeAngle
);
19
WriteValue
(OutFile, this->
FogDensity
);
20
WriteValue
(OutFile, this->
FogDistance
);
21
WriteValue
(OutFile, this->
FogFalloff
);
22
WriteValue
(OutFile, this->
Wetness
);
23
WriteValue
(OutFile, this->
ScatteringIntensity
);
24
WriteValue
(OutFile, this->
MieScatteringScale
);
25
WriteValue
(OutFile, this->
RayleighScatteringScale
);
26
WriteValue
(OutFile, this->
DustStorm
);
27
}
28
29
void
CarlaRecorderWeather::Read
(std::istream &InFile)
30
{
31
ReadValue
(InFile, this->
Cloudiness
);
32
ReadValue
(InFile, this->
Precipitation
);
33
ReadValue
(InFile, this->
PrecipitationDeposits
);
34
ReadValue
(InFile, this->
WindIntensity
);
35
ReadValue
(InFile, this->
SunAzimuthAngle
);
36
ReadValue
(InFile, this->
SunAltitudeAngle
);
37
ReadValue
(InFile, this->
FogDensity
);
38
ReadValue
(InFile, this->
FogDistance
);
39
ReadValue
(InFile, this->
FogFalloff
);
40
ReadValue
(InFile, this->
Wetness
);
41
ReadValue
(InFile, this->
ScatteringIntensity
);
42
ReadValue
(InFile, this->
MieScatteringScale
);
43
ReadValue
(InFile, this->
RayleighScatteringScale
);
44
ReadValue
(InFile, this->
DustStorm
);
45
}
46
47
// ---------------------------------------------
48
49
void
CarlaRecorderWeathers::Clear
(
void
)
50
{
51
Weathers
.clear();
52
}
53
54
void
CarlaRecorderWeathers::Add
(
const
CarlaRecorderWeather
&InObj)
55
{
56
Weathers
.push_back(InObj);
57
}
58
59
void
CarlaRecorderWeathers::Write
(std::ostream &OutFile)
60
{
61
if
(
Weathers
.size() == 0)
62
{
63
return
;
64
}
65
66
// write the packet id
67
WriteValue<char>
(OutFile,
static_cast<
char
>
(
CarlaRecorderPacketId::Weather
));
68
69
// write the packet size
70
uint32_t Total = 2 +
Weathers
.size() *
sizeof
(
CarlaRecorderWeather
);
71
WriteValue<uint32_t>
(OutFile, Total);
72
73
// write total records
74
Total =
Weathers
.size();
75
WriteValue<uint16_t>
(OutFile, Total);
76
77
// write records
78
for
(
auto
&
Weather
:
Weathers
)
79
{
80
Weather
.Write(OutFile);
81
}
82
}
83
84
void
CarlaRecorderWeathers::Read
(std::istream &InFile)
85
{
86
uint16_t Total = 0;
87
ReadValue<uint16_t>
(InFile, Total);
88
for
(uint16_t i = 0; (i < Total) && InFile; ++i)
89
{
90
CarlaRecorderWeather
Record;
91
Record.
Read
(InFile);
92
Add
(Record);
93
}
94
}
95
96
const
std::vector<CarlaRecorderWeather>&
CarlaRecorderWeathers::GetWeathers
()
const
97
{
98
return
Weathers
;
99
}
100
101
bool
CarlaRecorderWeathers::IsEmpty
()
const
102
{
103
return
Weathers
.empty();
104
}
CarlaRecorderHelpers.h
WriteValue
void WriteValue(std::ostream &OutFile, const T &InObj)
Definition
CarlaRecorderHelpers.h:21
ReadValue
void ReadValue(std::istream &InFile, T &OutObj)
Definition
CarlaRecorderHelpers.h:60
CarlaRecorderWeather.h
CarlaRecorder.h
CarlaRecorderPacketId::Weather
@ Weather
Definition
CarlaRecorder.h:75
CarlaRecorderWeathers::IsEmpty
bool IsEmpty() const
Definition
CarlaRecorderWeather.cpp:101
CarlaRecorderWeathers::Clear
void Clear(void)
Definition
CarlaRecorderWeather.cpp:49
CarlaRecorderWeathers::Weathers
std::vector< CarlaRecorderWeather > Weathers
Definition
CarlaRecorderWeather.h:56
CarlaRecorderWeathers::Read
void Read(std::istream &InFile)
Definition
CarlaRecorderWeather.cpp:84
CarlaRecorderWeathers::GetWeathers
const std::vector< CarlaRecorderWeather > & GetWeathers() const
Definition
CarlaRecorderWeather.cpp:96
CarlaRecorderWeathers::Write
void Write(std::ostream &OutFile)
Definition
CarlaRecorderWeather.cpp:59
CarlaRecorderWeathers::Add
void Add(const CarlaRecorderWeather &InObj)
Definition
CarlaRecorderWeather.cpp:54
CarlaRecorderWeather
Definition
CarlaRecorderWeather.h:16
CarlaRecorderWeather::RayleighScatteringScale
float RayleighScatteringScale
Definition
CarlaRecorderWeather.h:29
CarlaRecorderWeather::WindIntensity
float WindIntensity
Definition
CarlaRecorderWeather.h:20
CarlaRecorderWeather::Write
void Write(std::ostream &OutFile)
Definition
CarlaRecorderWeather.cpp:11
CarlaRecorderWeather::DustStorm
float DustStorm
Definition
CarlaRecorderWeather.h:30
CarlaRecorderWeather::SunAltitudeAngle
float SunAltitudeAngle
Definition
CarlaRecorderWeather.h:22
CarlaRecorderWeather::FogDistance
float FogDistance
Definition
CarlaRecorderWeather.h:24
CarlaRecorderWeather::Wetness
float Wetness
Definition
CarlaRecorderWeather.h:26
CarlaRecorderWeather::ScatteringIntensity
float ScatteringIntensity
Definition
CarlaRecorderWeather.h:27
CarlaRecorderWeather::FogDensity
float FogDensity
Definition
CarlaRecorderWeather.h:23
CarlaRecorderWeather::MieScatteringScale
float MieScatteringScale
Definition
CarlaRecorderWeather.h:28
CarlaRecorderWeather::Read
void Read(std::istream &InFile)
Definition
CarlaRecorderWeather.cpp:29
CarlaRecorderWeather::PrecipitationDeposits
float PrecipitationDeposits
Definition
CarlaRecorderWeather.h:19
CarlaRecorderWeather::SunAzimuthAngle
float SunAzimuthAngle
Definition
CarlaRecorderWeather.h:21
CarlaRecorderWeather::Cloudiness
float Cloudiness
Definition
CarlaRecorderWeather.h:17
CarlaRecorderWeather::Precipitation
float Precipitation
Definition
CarlaRecorderWeather.h:18
CarlaRecorderWeather::FogFalloff
float FogFalloff
Definition
CarlaRecorderWeather.h:25
Generated by
1.18.0