CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
Unreal
CarlaUnreal
Plugins
Carla
Source
Carla
Recorder
CarlaRecorderWalkerBones.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 "
CarlaRecorderWalkerBones.h
"
8
#include "
CarlaRecorder.h
"
9
#include "
CarlaRecorderHelpers.h
"
10
11
#include <algorithm>
12
#include <limits>
13
14
void
CarlaRecorderWalkerBones::Write
(std::ofstream &OutFile)
15
{
16
// database id
17
WriteValue<uint32_t>
(OutFile, this->
DatabaseId
);
18
19
// write all bones
20
WriteValue<uint16_t>
(OutFile, this->
Bones
.size());
21
for
(
const
auto
& Obj : this->
Bones
)
22
{
23
// name & transform
24
WriteFString
(OutFile, Obj.Name);
25
WriteFVector
(OutFile, Obj.Location);
26
WriteFVector
(OutFile, Obj.Rotation);
27
}
28
}
29
30
void
CarlaRecorderWalkerBones::Read
(std::ifstream &InFile)
31
{
32
// database id
33
ReadValue<uint32_t>
(InFile, this->
DatabaseId
);
34
35
// read all bones
36
uint16_t Total;
37
ReadValue<uint16_t>
(InFile, Total);
38
this->
Bones
.reserve(Total);
39
FString Name;
40
FVector
Location
,
Rotation
;
41
for
(
int
i=0; i<Total; ++i)
42
{
43
// name & transform
44
ReadFString
(InFile, Name);
45
ReadFVector
(InFile,
Location
);
46
ReadFVector
(InFile,
Rotation
);
47
// add to the vector of bones
48
this->
Bones
.emplace_back(Name,
Location
,
Rotation
);
49
}
50
}
51
52
void
CarlaRecorderWalkerBones::Clear
(
void
)
53
{
54
Bones
.clear();
55
}
56
57
// ---------------------------------------------
58
59
void
CarlaRecorderWalkersBones::Clear
(
void
)
60
{
61
Walkers
.clear();
62
}
63
64
void
CarlaRecorderWalkersBones::Add
(
const
CarlaRecorderWalkerBones
&Walker)
65
{
66
Walkers
.push_back(Walker);
67
}
68
69
void
CarlaRecorderWalkersBones::Write
(std::ofstream &OutFile)
70
{
71
// write the packet id
72
WriteValue<char>
(OutFile,
static_cast<
char
>
(
CarlaRecorderPacketId::WalkerBones
));
73
74
std::streampos PosStart = OutFile.tellp();
75
76
// write a dummy packet size
77
uint32_t Total = 0;
78
WriteValue<uint32_t>
(OutFile, Total);
79
80
// write total records
81
Total = std::min<size_t>(
Walkers
.size(), std::numeric_limits<uint16_t>::max());
82
WriteValue<uint16_t>
(OutFile, Total);
83
84
// write records
85
for
(uint16_t i=0; i<Total; ++i)
86
Walkers
[i].
Write
(OutFile);
87
88
// write the real packet size
89
std::streampos PosEnd = OutFile.tellp();
90
Total = PosEnd - PosStart -
sizeof
(uint32_t);
91
OutFile.seekp(PosStart, std::ios::beg);
92
WriteValue<uint32_t>
(OutFile, Total);
93
OutFile.seekp(PosEnd, std::ios::beg);
94
}
WriteFString
void WriteFString(std::ostream &OutFile, const FString &InObj)
Definition
CarlaRecorderHelpers.cpp:57
ReadFString
void ReadFString(std::istream &InFile, FString &OutObj)
Definition
CarlaRecorderHelpers.cpp:90
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
CarlaRecorderWalkerBones.h
CarlaRecorder.h
CarlaRecorderPacketId::WalkerBones
@ WalkerBones
Definition
CarlaRecorder.h:70
CarlaRecorderWalkersBones::Write
void Write(std::ofstream &OutFile)
Definition
CarlaRecorderWalkerBones.cpp:69
CarlaRecorderWalkersBones::Clear
void Clear(void)
Definition
CarlaRecorderWalkerBones.cpp:59
CarlaRecorderWalkersBones::Walkers
std::vector< CarlaRecorderWalkerBones > Walkers
Definition
CarlaRecorderWalkerBones.h:49
CarlaRecorderWalkersBones::Add
void Add(const CarlaRecorderWalkerBones &InObj)
Definition
CarlaRecorderWalkerBones.cpp:64
Rotation
Euler angles of a rotation in CARLA's / Unreal's left-handed frame: x forward, y right,...
Definition
Rotation.h:45
CarlaRecorderWalkerBones
Definition
CarlaRecorderWalkerBones.h:24
CarlaRecorderWalkerBones::DatabaseId
uint32_t DatabaseId
Definition
CarlaRecorderWalkerBones.h:25
CarlaRecorderWalkerBones::Read
void Read(std::ifstream &InFile)
Definition
CarlaRecorderWalkerBones.cpp:30
CarlaRecorderWalkerBones::Clear
void Clear()
Definition
CarlaRecorderWalkerBones.cpp:52
CarlaRecorderWalkerBones::Bones
std::vector< CarlaRecorderWalkerBone > Bones
Definition
CarlaRecorderWalkerBones.h:26
CarlaRecorderWalkerBones::Write
void Write(std::ofstream &OutFile)
Definition
CarlaRecorderWalkerBones.cpp:14
Location
Definition
geom/Location.h:23
Generated by
1.18.0