CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
Unreal
CarlaUnreal
Plugins
Carla
Source
Carla
Recorder
CarlaRecorderPosition.cpp
Go to the documentation of this file.
1
// Copyright (c) 2026 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 "
CarlaRecorderPosition.h
"
8
#include "
CarlaRecorder.h
"
9
#include "
CarlaRecorderHelpers.h
"
10
11
void
CarlaRecorderPosition::Write
(std::ostream &OutFile)
12
{
13
// database id
14
WriteValue<uint32_t>
(OutFile, this->
DatabaseId
);
15
// transform
16
WriteFVector
(OutFile, this->
Location
);
17
WriteFVector
(OutFile, this->
Rotation
);
18
}
19
void
CarlaRecorderPosition::Read
(std::istream &InFile)
20
{
21
// database id
22
ReadValue<uint32_t>
(InFile, this->
DatabaseId
);
23
// transform
24
ReadFVector
(InFile, this->
Location
);
25
ReadFVector
(InFile, this->
Rotation
);
26
}
27
28
// ---------------------------------------------
29
30
void
CarlaRecorderPositions::Clear
(
void
)
31
{
32
Positions
.clear();
33
}
34
35
void
CarlaRecorderPositions::Add
(
const
CarlaRecorderPosition
&Position)
36
{
37
Positions
.push_back(
Position
);
38
}
39
40
void
CarlaRecorderPositions::Write
(std::ostream &OutFile)
41
{
42
// write the packet id
43
WriteValue<char>
(OutFile,
static_cast<
char
>
(
CarlaRecorderPacketId::Position
));
44
45
// write the packet size
46
uint32_t Total = 2 +
Positions
.size() *
sizeof
(
CarlaRecorderPosition
);
47
WriteValue<uint32_t>
(OutFile, Total);
48
49
// write total records
50
Total =
Positions
.size();
51
WriteValue<uint16_t>
(OutFile, Total);
52
53
// write records
54
if
(Total > 0)
55
{
56
OutFile.write(
reinterpret_cast<
const
char
*
>
(
Positions
.data()),
57
Positions
.size() *
sizeof
(
CarlaRecorderPosition
));
58
}
59
}
60
61
void
CarlaRecorderPositions::Read
(std::istream &InFile)
62
{
63
uint16_t i, Total = 0;
64
65
// read all positions
66
ReadValue<uint16_t>
(InFile, Total);
67
for
(i = 0; (i < Total) && InFile; ++i)
68
{
69
CarlaRecorderPosition
Pos;
70
Pos.
Read
(InFile);
71
Add
(Pos);
72
}
73
}
74
75
const
std::vector<CarlaRecorderPosition>&
CarlaRecorderPositions::GetPositions
()
76
{
77
return
Positions
;
78
}
WriteFVector
void WriteFVector(std::ostream &OutFile, const FVector &InObj)
Definition
CarlaRecorderHelpers.cpp:42
ReadFVector
void ReadFVector(std::istream &InFile, FVector &OutObj)
Definition
CarlaRecorderHelpers.cpp:72
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
CarlaRecorderPosition.h
CarlaRecorder.h
CarlaRecorderPacketId::Position
@ Position
Definition
CarlaRecorder.h:57
CarlaRecorderPositions::Clear
void Clear(void)
Definition
CarlaRecorderPosition.cpp:30
CarlaRecorderPositions::Positions
std::vector< CarlaRecorderPosition > Positions
Definition
CarlaRecorderPosition.h:42
CarlaRecorderPositions::GetPositions
const std::vector< CarlaRecorderPosition > & GetPositions()
Definition
CarlaRecorderPosition.cpp:75
CarlaRecorderPositions::Add
void Add(const CarlaRecorderPosition &InObj)
Definition
CarlaRecorderPosition.cpp:35
CarlaRecorderPositions::Read
void Read(std::istream &InFile)
Definition
CarlaRecorderPosition.cpp:61
CarlaRecorderPositions::Write
void Write(std::ostream &OutFile)
Definition
CarlaRecorderPosition.cpp:40
CarlaRecorderPosition
Definition
CarlaRecorderPosition.h:14
CarlaRecorderPosition::Rotation
FVector Rotation
Definition
CarlaRecorderPosition.h:17
CarlaRecorderPosition::DatabaseId
uint32_t DatabaseId
Definition
CarlaRecorderPosition.h:15
CarlaRecorderPosition::Read
void Read(std::istream &InFile)
Definition
CarlaRecorderPosition.cpp:19
CarlaRecorderPosition::Location
FVector Location
Definition
CarlaRecorderPosition.h:16
CarlaRecorderPosition::Write
void Write(std::ostream &OutFile)
Definition
CarlaRecorderPosition.cpp:11
Generated by
1.18.0