CARLA
 
载入中...
搜索中...
未找到
FrameData.h
浏览该文件的文档.
1// Copyright (c) 2022 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#pragma once
8
33
34
35#include <sstream>
36#include <unordered_map>
37
38class UCarlaEpisode;
39class FCarlaActor;
40
42{
43 // structures
65
66 #pragma pack(push, 1)
67 struct Header
68 {
69 char Id;
70 uint32_t Size;
71 };
72 #pragma pack(pop)
73
74public:
75
76 void SetEpisode(UCarlaEpisode* ThisEpisode) {Episode = ThisEpisode;}
77
78 void GetFrameData(UCarlaEpisode *ThisEpisode, bool bAdditionalData = false, bool bIncludeActorsAgain = false);
79
80 void PlayFrameData(UCarlaEpisode *ThisEpisode, std::unordered_map<uint32_t, uint32_t>& MappedId);
81
82 void Clear();
83
84 void Write(std::ostream& OutStream);
85 void Read(std::istream& InStream);
86
87 // record functions
89 uint32_t DatabaseId,
90 uint8_t Type,
91 const FTransform &Transform,
92 FActorDescription ActorDescription,
93 bool bAddOtherRelatedInfo = true);
94 void AddEvent(const CarlaRecorderEventAdd &Event);
95 void AddEvent(const CarlaRecorderEventDel &Event);
96 void AddEvent(const CarlaRecorderEventParent &Event);
97
98private:
99 void AddCollision(AActor *Actor1, AActor *Actor2);
103 void AddAnimVehicleWheels(const CarlaRecorderAnimWheels &VehicleWheels);
104 void AddAnimWalker(const CarlaRecorderAnimWalker &Walker);
105 void AddAnimBiker(const CarlaRecorderAnimBiker &Biker);
106 void AddLightVehicle(const CarlaRecorderLightVehicle &LightVehicle);
107 void AddEventLightSceneChanged(const UCarlaLight* Light);
108 void AddKinematics(const CarlaRecorderKinematics &ActorKinematics);
109 void AddBoundingBox(const CarlaRecorderActorBoundingBox &ActorBoundingBox);
110 void AddTriggerVolume(const ATrafficSignBase &TrafficSign);
113
114 void AddActorPosition(FCarlaActor *CarlaActor);
115 void AddWalkerAnimation(FCarlaActor *CarlaActor);
117 void AddVehicleAnimation(FCarlaActor *CarlaActor);
118 void AddVehicleWheelsAnimation(FCarlaActor *CarlaActor);
119 void AddTrafficLightState(FCarlaActor *CarlaActor);
120 void AddVehicleLight(FCarlaActor *CarlaActor);
121 void AddActorKinematics(FCarlaActor *CarlaActor);
122 void AddActorBoundingBox(FCarlaActor *CarlaActor);
123
124 void GetFrameCounter();
125
126 std::pair<int, FCarlaActor*> CreateOrReuseActor(
127 FVector &Location,
128 FVector &Rotation,
129 FActorDescription &ActorDesc,
130 uint32_t DesiredId,
131 bool SpawnSensors,
132 std::unordered_map<uint32_t, uint32_t>& MappedId);
133
134 // replay event for creating actor
135 std::pair<int, uint32_t> ProcessReplayerEventAdd(
136 FVector Location,
137 FVector Rotation,
139 uint32_t DesiredId,
140 bool bIgnoreHero,
141 bool ReplaySensors,
142 std::unordered_map<uint32_t, uint32_t>& MappedId);
143
144 // replay event for removing actor
145 bool ProcessReplayerEventDel(uint32_t DatabaseId);
146 // replay event for parenting actors
147 bool ProcessReplayerEventParent(uint32_t ChildId, uint32_t ParentId);
148 // reposition actors
150 CarlaRecorderPosition Pos2, double Per, double DeltaTime);
151 // replay event for traffic light state
153 // set the animation for Vehicles
155 // set the animation for walkers
157 // set the animation for Vehicles Wheels
159 // set the animation for bikers
161 // set the vehicle light
163 // set scene lights
165 // replay finish
166 bool ProcessReplayerFinish(bool bApplyAutopilot, bool bIgnoreHero,
167 std::unordered_map<uint32_t, bool> &IsHero);
168 // set the camera position to follow an actor
169 bool SetCameraPosition(uint32_t Id, FVector Offset, FQuat Rotation);
170 // set the velocity of the actor
171 void SetActorVelocity(FCarlaActor *CarlaActor, FVector Velocity);
172 // set the animation speed for walkers
173 void SetWalkerSpeed(uint32_t ActorId, float Speed);
174 // enable / disable physics for an actor
175 bool SetActorSimulatePhysics(FCarlaActor *CarlaActor, bool bEnabled);
176
177 void SetFrameCounter();
178
179 FCarlaActor* FindTrafficLightAt(FVector Location);
180
181 void AddExistingActors(void);
182
184};
Base class for CARLA wheeled vehicles.
A view over an actor and its properties.
Definition CarlaActor.h:25
void AddPhysicsControl(const ACarlaWheeledVehicle &Vehicle)
void AddAnimVehicle(const CarlaRecorderAnimVehicle &Vehicle)
CarlaRecorderEventsDel EventsDel
Definition FrameData.h:47
void ProcessReplayerLightVehicle(CarlaRecorderLightVehicle LightVehicle)
bool ProcessReplayerEventDel(uint32_t DatabaseId)
CarlaRecorderLightVehicles LightVehicles
Definition FrameData.h:56
void GetFrameData(UCarlaEpisode *ThisEpisode, bool bAdditionalData=false, bool bIncludeActorsAgain=false)
Definition FrameData.cpp:23
CarlaRecorderCollisions Collisions
Definition FrameData.h:49
std::pair< int, FCarlaActor * > CreateOrReuseActor(FVector &Location, FVector &Rotation, FActorDescription &ActorDesc, uint32_t DesiredId, bool SpawnSensors, std::unordered_map< uint32_t, uint32_t > &MappedId)
CarlaRecorderInfo Info
Definition FrameData.h:44
void SetActorVelocity(FCarlaActor *CarlaActor, FVector Velocity)
void AddBikerAnimation(FCarlaActor *CarlaActor)
void Read(std::istream &InStream)
bool ProcessReplayerStateTrafficLight(CarlaRecorderStateTrafficLight State)
CarlaRecorderEventsParent EventsParent
Definition FrameData.h:48
bool ProcessReplayerPosition(CarlaRecorderPosition Pos1, CarlaRecorderPosition Pos2, double Per, double DeltaTime)
void AddActorBoundingBox(FCarlaActor *CarlaActor)
bool ProcessReplayerFinish(bool bApplyAutopilot, bool bIgnoreHero, std::unordered_map< uint32_t, bool > &IsHero)
void Write(std::ostream &OutStream)
void ProcessReplayerLightScene(CarlaRecorderLightScene LightScene)
void AddExistingActors(void)
void AddAnimBiker(const CarlaRecorderAnimBiker &Biker)
CarlaRecorderLightScenes LightScenes
Definition FrameData.h:57
CarlaRecorderActorTriggerVolumes TriggerVolumes
Definition FrameData.h:60
FCarlaActor * FindTrafficLightAt(FVector Location)
void ProcessReplayerAnimVehicleWheels(CarlaRecorderAnimWheels Vehicle)
void AddVehicleWheelsAnimation(FCarlaActor *CarlaActor)
CarlaRecorderAnimBikers Bikers
Definition FrameData.h:55
void SetFrameCounter()
bool SetActorSimulatePhysics(FCarlaActor *CarlaActor, bool bEnabled)
void AddState(const CarlaRecorderStateTrafficLight &State)
void ProcessReplayerAnimVehicle(CarlaRecorderAnimVehicle Vehicle)
CarlaRecorderActorBoundingBoxes BoundingBoxes
Definition FrameData.h:59
void AddCollision(AActor *Actor1, AActor *Actor2)
void AddLightVehicle(const CarlaRecorderLightVehicle &LightVehicle)
void AddVehicleAnimation(FCarlaActor *CarlaActor)
CarlaRecorderFrames Frames
Definition FrameData.h:45
void AddVehicleLight(FCarlaActor *CarlaActor)
CarlaRecorderTrafficLightTimes TrafficLightTimes
Definition FrameData.h:63
void AddTriggerVolume(const ATrafficSignBase &TrafficSign)
CarlaRecorderAnimVehicles Vehicles
Definition FrameData.h:52
void ProcessReplayerAnimBiker(CarlaRecorderAnimBiker Biker)
CarlaRecorderFrameCounter FrameCounter
Definition FrameData.h:64
CarlaRecorderAnimVehicleWheels Wheels
Definition FrameData.h:53
CarlaRecorderEventsAdd EventsAdd
Definition FrameData.h:46
void AddActorPosition(FCarlaActor *CarlaActor)
void AddWalkerAnimation(FCarlaActor *CarlaActor)
bool SetCameraPosition(uint32_t Id, FVector Offset, FQuat Rotation)
void AddTrafficLightTime(const ATrafficLightBase &TrafficLight)
void AddPosition(const CarlaRecorderPosition &Position)
void SetWalkerSpeed(uint32_t ActorId, float Speed)
void PlayFrameData(UCarlaEpisode *ThisEpisode, std::unordered_map< uint32_t, uint32_t > &MappedId)
Definition FrameData.cpp:78
CarlaRecorderPositions Positions
Definition FrameData.h:50
void AddActorKinematics(FCarlaActor *CarlaActor)
CarlaRecorderPhysicsControls PhysicsControls
Definition FrameData.h:62
CarlaRecorderStates States
Definition FrameData.h:51
void AddAnimVehicleWheels(const CarlaRecorderAnimWheels &VehicleWheels)
void SetEpisode(UCarlaEpisode *ThisEpisode)
Definition FrameData.h:76
void ProcessReplayerAnimWalker(CarlaRecorderAnimWalker Walker)
CarlaRecorderActorsKinematics Kinematics
Definition FrameData.h:58
void AddEvent(const CarlaRecorderEventAdd &Event)
CarlaRecorderAnimWalkers Walkers
Definition FrameData.h:54
void GetFrameCounter()
void CreateRecorderEventAdd(uint32_t DatabaseId, uint8_t Type, const FTransform &Transform, FActorDescription ActorDescription, bool bAddOtherRelatedInfo=true)
std::pair< int, uint32_t > ProcessReplayerEventAdd(FVector Location, FVector Rotation, CarlaRecorderActorDescription Description, uint32_t DesiredId, bool bIgnoreHero, bool ReplaySensors, std::unordered_map< uint32_t, uint32_t > &MappedId)
UCarlaEpisode * Episode
Definition FrameData.h:183
void AddEventLightSceneChanged(const UCarlaLight *Light)
bool ProcessReplayerEventParent(uint32_t ChildId, uint32_t ParentId)
CarlaRecorderPlatformTime PlatformTime
Definition FrameData.h:61
void AddAnimWalker(const CarlaRecorderAnimWalker &Walker)
void AddKinematics(const CarlaRecorderKinematics &ActorKinematics)
void AddTrafficLightState(FCarlaActor *CarlaActor)
void Clear()
void AddBoundingBox(const CarlaRecorderActorBoundingBox &ActorBoundingBox)
A simulation episode.
A description of a Carla Actor with all its variation.