CARLA
CarlaRecorderKinematics.cpp
Go to the documentation of this file.
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 
8 #include "CarlaRecorder.h"
9 #include "CarlaRecorderHelpers.h"
10 
11 void CarlaRecorderKinematics::Write(std::ostream &OutFile)
12 {
13  WriteValue<uint32_t>(OutFile, this->DatabaseId);
14  WriteFVector(OutFile, this->LinearVelocity);
15  WriteFVector(OutFile, this->AngularVelocity);
16 }
17 
18 void CarlaRecorderKinematics::Read(std::istream &InFile)
19 {
20  ReadValue<uint32_t>(InFile, this->DatabaseId);
21  ReadFVector(InFile, this->LinearVelocity);
22  ReadFVector(InFile, this->AngularVelocity);
23 }
24 
25 // ---------------------------------------------
26 
28 {
29  Kinematics.clear();
30 }
31 
33 {
34  Kinematics.push_back(InObj);
35 }
36 
37 void CarlaRecorderActorsKinematics::Write(std::ostream &OutFile)
38 {
39  if (Kinematics.size() == 0)
40  {
41  return;
42  }
43  // write the packet id
44  WriteValue<char>(OutFile, static_cast<char>(CarlaRecorderPacketId::Kinematics));
45 
46  // write the packet size
47  uint32_t Total = 2 + Kinematics.size() * sizeof(CarlaRecorderKinematics);
48  WriteValue<uint32_t>(OutFile, Total);
49 
50  // write total records
51  Total = Kinematics.size();
52  WriteValue<uint16_t>(OutFile, Total);
53 
54  // write records
55  for (auto& Kinematic : Kinematics)
56  {
57  Kinematic.Write(OutFile);
58  }
59 }
void ReadFVector(std::istream &InFile, FVector &OutObj)
void Add(const CarlaRecorderKinematics &InObj)
void Write(std::ostream &OutFile)
void WriteFVector(std::ostream &OutFile, const FVector &InObj)
void Write(std::ostream &OutFile)
void Read(std::istream &InFile)