CARLA
 
载入中...
搜索中...
未找到
CarlaRecorder.h
浏览该文件的文档.
1// Copyright (c) 2017 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
9// #include "GameFramework/Actor.h"
10#include <fstream>
11
13
29#include "CarlaRecorderFrames.h"
30#include "CarlaRecorderInfo.h"
32#include "CarlaRecorderQuery.h"
33#include "CarlaRecorderState.h"
37#include "CarlaReplayer.h"
39
40#include "CarlaRecorder.generated.h"
41
42class AActor;
43class UCarlaEpisode;
45class UCarlaLight;
48
76
77/// Recorder for the simulation
78UCLASS()
79class CARLA_API ACarlaRecorder : public AActor
80{
81 GENERATED_BODY()
82
83public:
84
85 ACarlaRecorder(void);
86 ACarlaRecorder(const FObjectInitializer &InObjectInitializer);
87
88 // enable / disable
89 bool IsEnabled(void)
90 {
91 return Enabled;
92 }
93 void Enable(void);
94
95 void Disable(void);
96
97 // start / stop
98 std::string Start(std::string Name, FString MapName, bool AdditionalData = false);
99
100 void Stop(void);
101
102 void Clear(void);
103
104 void Write(double DeltaSeconds);
105
106 // events
107 void AddEvent(const CarlaRecorderEventAdd &Event);
108
109 void AddEvent(const CarlaRecorderEventDel &Event);
110
111 void AddEvent(const CarlaRecorderEventParent &Event);
112
113 void AddCollision(AActor *Actor1, AActor *Actor2);
114
115 void AddPosition(const CarlaRecorderPosition &Position);
116
117 void AddState(const CarlaRecorderStateTrafficLight &State);
118
119 void AddAnimVehicle(const CarlaRecorderAnimVehicle &Vehicle);
120
121 void AddAnimVehicleWheels(const CarlaRecorderAnimWheels &VehicleWheels);
122
123 void AddAnimWalker(const CarlaRecorderAnimWalker &Walker);
124
125 void AddAnimBiker(const CarlaRecorderAnimBiker &Biker);
126
127 void AddLightVehicle(const CarlaRecorderLightVehicle &LightVehicle);
128
129 void AddEventLightSceneChanged(const UCarlaLight* Light);
130
131 void AddKinematics(const CarlaRecorderKinematics &ActorKinematics);
132
133 void AddBoundingBox(const CarlaRecorderActorBoundingBox &ActorBoundingBox);
134
135 void AddTriggerVolume(const ATrafficSignBase &TrafficSign);
136
137 void AddPhysicsControl(const ACarlaWheeledVehicle& Vehicle);
138
139 void AddTrafficLightTime(const ATrafficLightBase& TrafficLight);
140
141 void AddActorBones(FCarlaActor *CarlaActor);
142
143 void AddVehicleDoor(const ACarlaWheeledVehicle& Vehicle, const EVehicleDoor SDoors, bool bIsOpen);
144
145 void AddDoorVehicle(const CarlaRecorderDoorVehicle &DoorVehicle);
146
147 // set episode
148 void SetEpisode(UCarlaEpisode *ThisEpisode)
149 {
150 Episode = ThisEpisode;
151 Replayer.SetEpisode(ThisEpisode);
152 }
153
154 void CreateRecorderEventAdd(
155 uint32_t DatabaseId,
156 uint8_t Type,
157 const FTransform &Transform,
158 FActorDescription ActorDescription);
159
160 // replayer
162 {
163 return &Replayer;
164 }
165
166 // queries
167 std::string ShowFileInfo(std::string Name, bool bShowAll = false);
168 std::string ShowFileCollisions(std::string Name, char Type1, char Type2);
169 std::string ShowFileActorsBlocked(std::string Name, double MinTime = 30, double MinDistance = 10);
170
171 // replayer
172 std::string ReplayFile(std::string Name, double TimeStart, double Duration,
173 uint32_t FollowId, bool ReplaySensors);
174 void SetReplayerTimeFactor(double TimeFactor);
175 void SetReplayerIgnoreHero(bool IgnoreHero);
176 void SetReplayerIgnoreSpectator(bool IgnoreSpectator);
177 void StopReplayer(bool KeepActors = false);
178
179 void Ticking(float DeltaSeconds);
180
181private:
182
183 bool Enabled; // enabled or not
184
185 // enabling this records additional data (kinematics, bounding boxes, etc)
186 bool bAdditionalData = false;
187
188 uint32_t NextCollisionId = 0;
189
190 // files
191 std::ofstream File;
192
193 UCarlaEpisode *Episode = nullptr;
194
195 // structures
219
220 // replayer
222
223 // query tools
225
226 void AddExistingActors(void);
227 void AddActorPosition(FCarlaActor *CarlaActor);
228 void AddWalkerAnimation(FCarlaActor *CarlaActor);
230 void AddVehicleAnimation(FCarlaActor *CarlaActor);
231 void AddVehicleWheelsAnimation(FCarlaActor *CarlaActor);
232 void AddTrafficLightState(FCarlaActor *CarlaActor);
233 void AddVehicleLight(FCarlaActor *CarlaActor);
234 void AddActorKinematics(FCarlaActor *CarlaActor);
235 void AddActorBoundingBox(FCarlaActor *CarlaActor);
236};
CarlaRecorderPacketId
EVehicleDoor
Type of door to open/close
Recorder for the simulation
CarlaRecorderEventsAdd EventsAdd
bool IsEnabled(void)
CarlaRecorderTrafficLightTimes TrafficLightTimes
CarlaRecorderPhysicsControls PhysicsControls
CarlaRecorderLightScenes LightScenes
CarlaRecorderAnimBikers Bikers
void AddBikerAnimation(FCarlaActor *CarlaActor)
CarlaRecorderActorBoundingBoxes BoundingBoxes
CarlaReplayer * GetReplayer(void)
CarlaRecorderLightVehicles LightVehicles
CarlaRecorderVisualTime VisualTime
CarlaRecorderPlatformTime PlatformTime
CarlaRecorderActorTriggerVolumes TriggerVolumes
CarlaReplayer Replayer
CarlaRecorderInfo Info
CarlaRecorderWalkersBones WalkersBones
CarlaRecorderQuery Query
std::ofstream File
CarlaRecorderEventsParent EventsParent
CarlaRecorderCollisions Collisions
CarlaRecorderActorsKinematics Kinematics
CarlaRecorderPositions Positions
CarlaRecorderAnimWalkers Walkers
CarlaRecorderAnimVehicleWheels Wheels
CarlaRecorderStates States
CarlaRecorderEventsDel EventsDel
void SetEpisode(UCarlaEpisode *ThisEpisode)
CarlaRecorderFrames Frames
CarlaRecorderAnimVehicles Vehicles
CarlaRecorderDoorVehicles DoorVehicles
Base class for CARLA wheeled vehicles.
A view over an actor and its properties.
Definition CarlaActor.h:25
A simulation episode.
A description of a Carla Actor with all its variation.