CARLA
载入中...
搜索中...
未找到
Unreal
CarlaUE4
Plugins
Carla
Source
Carla
Recorder
CarlaRecorderLightVehicle.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 "
CarlaRecorderLightVehicle.h
"
8
#include "
CarlaRecorder.h
"
9
#include "
CarlaRecorderHelpers.h
"
10
11
12
void
CarlaRecorderLightVehicle::Write
(std::ostream &OutFile)
13
{
14
// database id
15
WriteValue<uint32_t>(OutFile, this->
DatabaseId
);
16
WriteValue<VehicleLightStateType>(OutFile, this->
State
);
17
}
18
void
CarlaRecorderLightVehicle::Read
(std::istream &InFile)
19
{
20
// database id
21
ReadValue<uint32_t>(InFile, this->
DatabaseId
);
22
ReadValue<VehicleLightStateType>(InFile, this->
State
);
23
}
24
25
// ---------------------------------------------
26
27
void
CarlaRecorderLightVehicles::Clear
(
void
)
28
{
29
Vehicles
.clear();
30
}
31
32
void
CarlaRecorderLightVehicles::Add
(
const
CarlaRecorderLightVehicle
&
Vehicle
)
33
{
34
Vehicles
.push_back(
Vehicle
);
35
}
36
37
void
CarlaRecorderLightVehicles::Write
(std::ostream &OutFile)
38
{
39
// write the packet id
40
WriteValue<char>(OutFile,
static_cast<
char
>
(
CarlaRecorderPacketId::VehicleLight
));
41
42
// write a dummy packet size
43
uint32_t Total = 2 +
Vehicles
.size() *
sizeof
(
CarlaRecorderLightVehicle
);
44
WriteValue<uint32_t>(OutFile, Total);
45
46
// write total records
47
Total =
Vehicles
.size();
48
WriteValue<uint16_t>(OutFile, Total);
49
50
for
(
auto
&
Vehicle
:
Vehicles
)
51
{
52
Vehicle
.Write(OutFile);
53
}
54
}
55
56
void
CarlaRecorderLightVehicles::Read
(std::istream &InFile)
57
{
58
uint16_t Total;
59
CarlaRecorderLightVehicle
LightVehicle;
60
61
// read Total walkers
62
ReadValue<uint16_t>(InFile, Total);
63
for
(uint16_t i = 0; i < Total; ++i)
64
{
65
LightVehicle.
Read
(InFile);
66
Add
(LightVehicle);
67
}
68
}
69
70
const
std::vector<CarlaRecorderLightVehicle>&
CarlaRecorderLightVehicles::GetLightVehicles
()
71
{
72
return
Vehicles
;
73
}
CarlaRecorderHelpers.h
CarlaRecorderLightVehicle.h
CarlaRecorder.h
CarlaRecorderPacketId::VehicleLight
@ VehicleLight
Vehicle
@ Vehicle
Definition
Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Util/EnvironmentObject.h:22
CarlaRecorderLightVehicle
Definition
CarlaRecorderLightVehicle.h:15
CarlaRecorderLightVehicle::State
VehicleLightStateType State
Definition
CarlaRecorderLightVehicle.h:20
CarlaRecorderLightVehicle::DatabaseId
uint32_t DatabaseId
Definition
CarlaRecorderLightVehicle.h:19
CarlaRecorderLightVehicle::Write
void Write(std::ostream &OutFile)
Definition
CarlaRecorderLightVehicle.cpp:12
CarlaRecorderLightVehicle::Read
void Read(std::istream &InFile)
Definition
CarlaRecorderLightVehicle.cpp:18
CarlaRecorderLightVehicles::Read
void Read(std::istream &InFile)
Definition
CarlaRecorderLightVehicle.cpp:56
CarlaRecorderLightVehicles::GetLightVehicles
const std::vector< CarlaRecorderLightVehicle > & GetLightVehicles()
Definition
CarlaRecorderLightVehicle.cpp:70
CarlaRecorderLightVehicles::Clear
void Clear(void)
Definition
CarlaRecorderLightVehicle.cpp:27
CarlaRecorderLightVehicles::Write
void Write(std::ostream &OutFile)
Definition
CarlaRecorderLightVehicle.cpp:37
CarlaRecorderLightVehicles::Vehicles
std::vector< CarlaRecorderLightVehicle > Vehicles
Definition
CarlaRecorderLightVehicle.h:44
CarlaRecorderLightVehicles::Add
void Add(const CarlaRecorderLightVehicle &InObj)
Definition
CarlaRecorderLightVehicle.cpp:32
制作者
1.10.0