CARLA
载入中...
搜索中...
未找到
Unreal
CarlaUE4
Plugins
Carla
Source
Carla
Recorder
CarlaRecorderTraficLightTime.cpp
浏览该文件的文档.
1
// Copyright (c) 2020 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 "
CarlaRecorderTraficLightTime.h
"
8
#include "
CarlaRecorder.h
"
9
#include "
CarlaRecorderHelpers.h
"
10
11
12
void
CarlaRecorderTrafficLightTime::Write
(std::ostream &OutFile)
13
{
14
WriteValue<uint32_t>(OutFile, this->
DatabaseId
);
15
WriteValue
(OutFile, this->
GreenTime
);
16
WriteValue
(OutFile, this->
YellowTime
);
17
WriteValue
(OutFile, this->
RedTime
);
18
}
19
20
void
CarlaRecorderTrafficLightTime::Read
(std::istream &InFile)
21
{
22
ReadValue<uint32_t>(InFile, this->
DatabaseId
);
23
ReadValue
(InFile, this->
GreenTime
);
24
ReadValue
(InFile, this->
YellowTime
);
25
ReadValue
(InFile, this->
RedTime
);
26
}
27
28
// ---------------------------------------------
29
30
void
CarlaRecorderTrafficLightTimes::Clear
(
void
)
31
{
32
TrafficLightTimes
.clear();
33
}
34
35
void
CarlaRecorderTrafficLightTimes::Add
(
const
CarlaRecorderTrafficLightTime
&InObj)
36
{
37
TrafficLightTimes
.push_back(InObj);
38
}
39
40
void
CarlaRecorderTrafficLightTimes::Write
(std::ostream &OutFile)
41
{
42
if
(
TrafficLightTimes
.size() == 0)
43
{
44
return
;
45
}
46
// write the packet id
47
WriteValue<char>(OutFile,
static_cast<
char
>
(
CarlaRecorderPacketId::TrafficLightTime
));
48
49
uint32_t Total =
sizeof
(uint16_t) +
TrafficLightTimes
.size() *
sizeof
(
CarlaRecorderTrafficLightTime
);
50
WriteValue<uint32_t>(OutFile, Total);
51
52
Total =
TrafficLightTimes
.size();
53
WriteValue<uint16_t>(OutFile, Total);
54
55
for
(
auto
&
TrafficLightTime
:
TrafficLightTimes
)
56
{
57
TrafficLightTime
.Write(OutFile);
58
}
59
}
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
CarlaRecorderTraficLightTime.h
CarlaRecorder.h
CarlaRecorderPacketId::TrafficLightTime
@ TrafficLightTime
CarlaRecorderTrafficLightTimes::Add
void Add(const CarlaRecorderTrafficLightTime &InObj)
Definition
CarlaRecorderTraficLightTime.cpp:35
CarlaRecorderTrafficLightTimes::Write
void Write(std::ostream &OutFile)
Definition
CarlaRecorderTraficLightTime.cpp:40
CarlaRecorderTrafficLightTimes::Clear
void Clear(void)
Definition
CarlaRecorderTraficLightTime.cpp:30
CarlaRecorderTrafficLightTimes::TrafficLightTimes
std::vector< CarlaRecorderTrafficLightTime > TrafficLightTimes
Definition
CarlaRecorderTraficLightTime.h:38
CarlaRecorderTrafficLightTime
Definition
CarlaRecorderTraficLightTime.h:14
CarlaRecorderTrafficLightTime::RedTime
float RedTime
Definition
CarlaRecorderTraficLightTime.h:18
CarlaRecorderTrafficLightTime::GreenTime
float GreenTime
Definition
CarlaRecorderTraficLightTime.h:16
CarlaRecorderTrafficLightTime::DatabaseId
uint32_t DatabaseId
Definition
CarlaRecorderTraficLightTime.h:15
CarlaRecorderTrafficLightTime::Read
void Read(std::istream &InFile)
Definition
CarlaRecorderTraficLightTime.cpp:20
CarlaRecorderTrafficLightTime::Write
void Write(std::ostream &OutFile)
Definition
CarlaRecorderTraficLightTime.cpp:12
CarlaRecorderTrafficLightTime::YellowTime
float YellowTime
Definition
CarlaRecorderTraficLightTime.h:17
制作者
1.10.0