CARLA
载入中...
搜索中...
未找到
Unreal
CarlaUE4
Plugins
Carla
Source
Carla
Recorder
CarlaRecorderState.cpp
浏览该文件的文档.
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 "
CarlaRecorder.h
"
8
#include "
CarlaRecorderState.h
"
9
#include "
CarlaRecorderHelpers.h
"
10
11
void
CarlaRecorderStateTrafficLight::Write
(std::ostream &OutFile)
12
{
13
WriteValue<uint32_t>(OutFile, this->
DatabaseId
);
14
WriteValue<bool>(OutFile, this->
IsFrozen
);
15
WriteValue<float>(OutFile, this->
ElapsedTime
);
16
WriteValue<char>(OutFile, this->
State
);
17
}
18
19
void
CarlaRecorderStateTrafficLight::Read
(std::istream &InFile)
20
{
21
ReadValue<uint32_t>(InFile, this->
DatabaseId
);
22
ReadValue<bool>(InFile, this->
IsFrozen
);
23
ReadValue<float>(InFile, this->
ElapsedTime
);
24
ReadValue<char>(InFile, this->
State
);
25
}
26
27
// ---------------------------------------------
28
29
void
CarlaRecorderStates::Clear
(
void
)
30
{
31
StatesTrafficLights
.clear();
32
}
33
34
void
CarlaRecorderStates::Add
(
const
CarlaRecorderStateTrafficLight
&
State
)
35
{
36
StatesTrafficLights
.push_back(std::move(
State
));
37
}
38
39
void
CarlaRecorderStates::Write
(std::ostream &OutFile)
40
{
41
// write the packet id
42
WriteValue<char>(OutFile,
static_cast<
char
>
(
CarlaRecorderPacketId::State
));
43
44
// write the packet size
45
uint32_t Total = 2 +
StatesTrafficLights
.size() *
sizeof
(
CarlaRecorderStateTrafficLight
);
46
WriteValue<uint32_t>(OutFile, Total);
47
48
// write total records
49
Total =
StatesTrafficLights
.size();
50
WriteValue<uint16_t>(OutFile, Total);
51
52
for
(uint16_t i = 0; i < Total; ++i)
53
{
54
StatesTrafficLights
[i].Write(OutFile);
55
}
56
}
57
58
void
CarlaRecorderStates::Read
(std::istream &InFile)
59
{
60
uint16_t i, Total;
61
CarlaRecorderStateTrafficLight
StateTrafficLight;
62
63
// read Total traffic light states
64
ReadValue<uint16_t>(InFile, Total);
65
for
(i = 0; i < Total; ++i)
66
{
67
StateTrafficLight.
Read
(InFile);
68
Add
(StateTrafficLight);
69
}
70
}
71
72
const
std::vector<CarlaRecorderStateTrafficLight>&
CarlaRecorderStates::GetStates
()
73
{
74
return
StatesTrafficLights
;
75
}
CarlaRecorderHelpers.h
CarlaRecorderState.h
CarlaRecorder.h
CarlaRecorderPacketId::State
@ State
CarlaRecorderStates::Write
void Write(std::ostream &OutFile)
Definition
CarlaRecorderState.cpp:39
CarlaRecorderStates::Clear
void Clear(void)
Definition
CarlaRecorderState.cpp:29
CarlaRecorderStates::Add
void Add(const CarlaRecorderStateTrafficLight &State)
Definition
CarlaRecorderState.cpp:34
CarlaRecorderStates::StatesTrafficLights
std::vector< CarlaRecorderStateTrafficLight > StatesTrafficLights
Definition
CarlaRecorderState.h:45
CarlaRecorderStates::Read
void Read(std::istream &InFile)
Definition
CarlaRecorderState.cpp:58
CarlaRecorderStates::GetStates
const std::vector< CarlaRecorderStateTrafficLight > & GetStates()
Definition
CarlaRecorderState.cpp:72
CarlaRecorderStateTrafficLight
Definition
CarlaRecorderState.h:14
CarlaRecorderStateTrafficLight::IsFrozen
bool IsFrozen
Definition
CarlaRecorderState.h:16
CarlaRecorderStateTrafficLight::Write
void Write(std::ostream &OutFile)
Definition
CarlaRecorderState.cpp:11
CarlaRecorderStateTrafficLight::State
char State
Definition
CarlaRecorderState.h:18
CarlaRecorderStateTrafficLight::Read
void Read(std::istream &InFile)
Definition
CarlaRecorderState.cpp:19
CarlaRecorderStateTrafficLight::DatabaseId
uint32_t DatabaseId
Definition
CarlaRecorderState.h:15
CarlaRecorderStateTrafficLight::ElapsedTime
float ElapsedTime
Definition
CarlaRecorderState.h:17
制作者
1.10.0