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