CARLA
 
载入中...
搜索中...
未找到
FrameData.cpp
浏览该文件的文档.
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#include "FrameData.h" // 包含FFrameData类的头文件,定义了帧数据的结构和操作
8#include "Carla/Game/CarlaEpisode.h" // 包含Carla游戏环节的头文件,表示仿真会话
9#include "Carla/Actor/CarlaActor.h" // 包含Carla Actor的头文件,表示仿真中的Actor
10#include "Carla/Game/CarlaEngine.h" // 包含Carla游戏引擎的头文件,管理Carla仿真的核心组件
11#include "Carla/Traffic/TrafficLightController.h" // 包含交通灯控制器的头文件,管理交通灯的行为
12#include "Carla/Traffic/TrafficLightGroup.h" // 包含交通灯组的头文件,表示一组交通灯
13#include "Carla/MapGen/LargeMapManager.h" // 包含大地图管理器的头文件,管理大型开放世界地图
14#include "Carla/Game/CarlaStatics.h" // 包含Carla静态变量和函数的头文件,提供全局访问点
15#include "Carla/Settings/CarlaSettings.h" // 包含Carla设置的头文件,定义仿真的配置参数
16#include "Carla/Lights/CarlaLightSubsystem.h" // 包含Carla灯光子系统的头文件,管理游戏世界的灯光
17
18#include <compiler/disable-ue4-macros.h> // 禁用Unreal Engine的宏,防止与Carla代码冲突
19#include "carla/rpc/VehicleLightState.h" // 包含Carla RPC车辆灯光状态的头文件,定义车辆灯光状态的RPC结构
20#include <compiler/enable-ue4-macros.h> // 启用Unreal Engine的宏
21
22// FFrameData::GetFrameData函数,用于收集当前帧的数据
23void FFrameData::GetFrameData(UCarlaEpisode *ThisEpisode, bool bAdditionalData, bool bIncludeActorsAgain)
24{
25 Episode = ThisEpisode; // 将传入的游戏环节赋值给成员变量Episode
26 // PlatformTime.UpdateTime(); // 更新平台时间,此行代码被注释,可能用于性能监测
27 const FActorRegistry &Registry = Episode->GetActorRegistry(); // 获取游戏环节中的Actor注册表
28
29 if (bIncludeActorsAgain) // 如果需要再次包括Actor
30 {
31 AddExistingActors(); // 添加已存在的Actor到帧数据中
32 }
33
34 // 遍历Actor注册表中的所有Actor
35 for (auto It = Registry.begin(); It != Registry.end(); ++It)
36 {
37 FCarlaActor* View = It.Value().Get(); // 获取Actor的指针
38
39 // 根据Actor的类型进行不同的数据处理
40 switch (View->GetActorType())
41 {
42 // 对于其他类型和传感器Actor,保存其位置变换
45 AddActorPosition(View); // 添加Actor的位置到帧数据
46 break;
47
48 // 对于车辆Actor,保存其位置变换、动画、灯光和车轮动画
50 AddActorPosition(View); // 添加Actor的位置
51 AddVehicleAnimation(View); // 添加车辆动画
52 AddVehicleLight(View); // 添加车辆灯光状态
53 AddVehicleWheelsAnimation(View); // 添加车辆车轮动画
54 if (bAdditionalData) // 如果需要额外的数据
55 {
56 AddActorKinematics(View); // 添加Actor的运动学数据
57 }
58 break;
59
60 // 对于行人Actor,保存其位置变换和动画
62 AddActorPosition(View); // 添加Actor的位置
63 AddWalkerAnimation(View); // 添加行人动画
64 if (bAdditionalData) // 如果需要额外的数据
65 {
66 AddActorKinematics(View); // 添加Actor的运动学数据
67 }
68 break;
69
70 // 对于交通灯Actor,保存其状态
72 AddTrafficLightState(View); // 添加交通灯状态
73 break;
74 }
75 }
76 GetFrameCounter(); // 获取当前帧计数器的值
77}
78
79// FFrameData::PlayFrameData函数,用于播放存储的帧数据
81 UCarlaEpisode *ThisEpisode,
82 std::unordered_map<uint32_t, uint32_t>& MappedId)
83{
84 // 此函数的具体实现未提供,可能包含将帧数据应用到游戏环节的逻辑
85 // ThisEpisode参数可能用于访问游戏环节的状态和功能
86 // MappedId参数可能用于处理Actor ID的映射,以确保数据的正确应用
87}
88
89
90 for(const CarlaRecorderEventAdd &EventAdd : EventsAdd.GetEvents())
91 {
92 uint32_t OldId = EventAdd.DatabaseId;
93 // Todo: 检查 EventAdd.DatabaseId 的内存损坏
94 auto Result = ProcessReplayerEventAdd(
95 EventAdd.Location,
96 EventAdd.Rotation,
97 EventAdd.Description,
98 EventAdd.DatabaseId,
99 false,
100 true,
101 MappedId);
102 switch (Result.first)
103 {
104 //未创建角色
105 case 0:
106 UE_LOG(LogCarla, Log, TEXT("actor could not be created"));
107 break;
108
109 // 已创建 Actor 但具有不同的 ID
110 case 1:
111 // mapping id (记录的 Id 是 replayer 中的新 Id)
112 MappedId[OldId] = Result.second;
113 UE_LOG(LogCarla, Log, TEXT("actor created"));
114 break;
115
116 // 从现有 actor 重用
117 case 2:
118 // 映射 ID(假设所需的 Id 映射到什么)
119 MappedId[OldId] = Result.second;
120 UE_LOG(LogCarla, Log, TEXT("actor reused"));
121 break;
122 }
123 }
124
125 for (const CarlaRecorderEventDel &EventDel : EventsDel.GetEvents())
126 {
127 ProcessReplayerEventDel(MappedId[EventDel.DatabaseId]);
128 MappedId.erase(EventDel.DatabaseId);
129 }
130
131 for (const CarlaRecorderPosition &Position : Positions.GetPositions())
132 {
134 auto NewId = MappedId.find(Pos.DatabaseId);
135 if (NewId != MappedId.end())
136 {
137 Pos.DatabaseId = NewId->second;
138 ProcessReplayerPosition(Pos, Pos, 0.0, 0.0);
139 }
140 }
141
142 for (const CarlaRecorderStateTrafficLight &State : States.GetStates())
143 {
144 CarlaRecorderStateTrafficLight StateTrafficLight = State;
145 StateTrafficLight.DatabaseId = MappedId[StateTrafficLight.DatabaseId];
146 ProcessReplayerStateTrafficLight(StateTrafficLight);
147 }
148
149 for (const CarlaRecorderAnimVehicle &AnimVehicle : Vehicles.GetVehicles())
150 {
152 Vehicle.DatabaseId = MappedId[Vehicle.DatabaseId];
153 ProcessReplayerAnimVehicle(Vehicle);
154 }
155
156 for (const CarlaRecorderAnimWheels &AnimWheel : Wheels.GetVehicleWheels())
157 {
158 CarlaRecorderAnimWheels Wheels = AnimWheel;
159 Wheels.DatabaseId = MappedId[Wheels.DatabaseId];
160 ProcessReplayerAnimVehicleWheels(Wheels);
161 }
162
163 for (const CarlaRecorderAnimWalker &AnimWalker : Walkers.GetWalkers())
164 {
166 Walker.DatabaseId = MappedId[Walker.DatabaseId];
167 ProcessReplayerAnimWalker(Walker);
168 }
169
170 for (const CarlaRecorderAnimBiker &AnimBiker : Bikers.GetBikers())
171 {
173 Biker.DatabaseId = MappedId[Biker.DatabaseId];
174 ProcessReplayerAnimBiker(Biker);
175 }
176
177 for (const CarlaRecorderLightVehicle &LightVehicle : LightVehicles.GetLightVehicles())
178 {
179 CarlaRecorderLightVehicle Light = LightVehicle;
180 Light.DatabaseId = MappedId[Light.DatabaseId];
181 ProcessReplayerLightVehicle(Light);
182 }
183
184 for (const CarlaRecorderLightScene &Light : LightScenes.GetLights())
185 {
186 ProcessReplayerLightScene(Light);
187 }
188
190}
191
213
214void FFrameData::Write(std::ostream& OutStream)
215{
216 EventsAdd.Write(OutStream);
217 EventsDel.Write(OutStream);
218 EventsParent.Write(OutStream);
219 Positions.Write(OutStream);
220 States.Write(OutStream);
221 Vehicles.Write(OutStream);
222 Wheels.Write(OutStream);
223 Walkers.Write(OutStream);
224 Bikers.Write(OutStream);
225 LightVehicles.Write(OutStream);
226 LightScenes.Write(OutStream);
227 TrafficLightTimes.Write(OutStream);
228 FrameCounter.Write(OutStream);
229}
230
231void FFrameData::Read(std::istream& InStream)
232{
233 Clear();
234 while(!InStream.eof())
235 {
236 Header header;
237 ReadValue<char>(InStream, header.Id);
238 ReadValue<uint32_t>(InStream, header.Size);
239 switch (header.Id)
240 {
241 // 事件添加
242 case static_cast<char>(CarlaRecorderPacketId::EventAdd):
243 EventsAdd.Read(InStream);
244 break;
245
246 // 事件删除
247 case static_cast<char>(CarlaRecorderPacketId::EventDel):
248 EventsDel.Read(InStream);
249 break;
250
251 // 事件父级
252 case static_cast<char>(CarlaRecorderPacketId::EventParent):
253 EventsParent.Read(InStream);
254 break;
255
256 // 位置
257 case static_cast<char>(CarlaRecorderPacketId::Position):
258 Positions.Read(InStream);
259 break;
260
261 // states
262 case static_cast<char>(CarlaRecorderPacketId::State):
263 States.Read(InStream);
264 break;
265
266 // StatesVehicle 动画
267 case static_cast<char>(CarlaRecorderPacketId::AnimVehicle):
268 Vehicles.Read(InStream);
269 break;
270
271 // walker动画
272 case static_cast<char>(CarlaRecorderPacketId::AnimWalker):
273 Walkers.Read(InStream);
274 break;
275
276 // walker animation
277 case static_cast<char>(CarlaRecorderPacketId::AnimVehicleWheels):
278 Wheels.Read(InStream);
279 break;
280
281 // walker 动画
282 case static_cast<char>(CarlaRecorderPacketId::AnimBiker):
283 Bikers.Read(InStream);
284 break;
285
286 //Vehicle Light 动画
287 case static_cast<char>(CarlaRecorderPacketId::VehicleLight):
288 LightVehicles.Read(InStream);
289 break;
290
291 // 场景灯光动画
292 case static_cast<char>(CarlaRecorderPacketId::SceneLight):
293 LightScenes.Read(InStream);
294 break;
295
296 case static_cast<char>(CarlaRecorderPacketId::FrameCounter):
297 FrameCounter.Read(InStream);
298 break;
299
300 // 未知数据包,只需跳过
301 default:
302 // 跳过数据包
303 InStream.seekg(header.Size, std::ios::cur);
304 break;
305
306 }
307 }
308}
309
311 uint32_t DatabaseId,
312 uint8_t Type,
313 const FTransform &Transform,
314 FActorDescription ActorDescription,
315 bool bAddOtherRelatedInfo)
316{
318 Description.UId = ActorDescription.UId;
319 Description.Id = ActorDescription.Id;
320
321 //属性
322 Description.Attributes.reserve(ActorDescription.Variations.Num());
323 for (const auto &item : ActorDescription.Variations)
324 {
326 Attr.Type = static_cast<uint8_t>(item.Value.Type);
327 Attr.Id = item.Value.Id;
328 Attr.Value = item.Value.Value;
329 //检查空属性
330 if (!Attr.Id.IsEmpty())
331 {
332 Description.Attributes.emplace_back(std::move(Attr));
333 }
334 }
335
336 // 记录器事件
337 CarlaRecorderEventAdd RecEvent
338 {
339 DatabaseId,
340 Type,
341 Transform.GetTranslation(),
342 Transform.GetRotation().Euler(),
343 std::move(Description)
344 };
345 AddEvent(std::move(RecEvent));
346
347 if (!bAddOtherRelatedInfo)
348 {
349 return;
350 }
351
352 // 与生成 Actor 相关的其他事件
353 FCarlaActor* CarlaActor = Episode->FindCarlaActor(DatabaseId);
354 if (!CarlaActor)
355 {
356 return;
357 }
358
359 //检查它是否是获得初始物理控制的车辆
360 ACarlaWheeledVehicle* Vehicle = Cast<ACarlaWheeledVehicle>(CarlaActor->GetActor());
361 if (Vehicle)
362 {
364 }
365
366 ATrafficLightBase* TrafficLight = Cast<ATrafficLightBase>(CarlaActor->GetActor());
367 if (TrafficLight)
368 {
370 }
371
372 ATrafficSignBase* TrafficSign = Cast<ATrafficSignBase>(CarlaActor->GetActor());
373 if (TrafficSign)
374 {
375 // 在全局坐标中触发体积
376 AddTriggerVolume(*TrafficSign);
377 }
378 else
379 {
380 // 本地坐标中的边界框
381 AddActorBoundingBox(CarlaActor);
382 }
383}
384
385
387{
388 check(CarlaActor != nullptr);
389
390 FTransform Transform = CarlaActor->GetActorGlobalTransform();
391 // 获取车辆的位置
393 {
394 CarlaActor->GetActorId(),
395 Transform.GetLocation(),
396 Transform.GetRotation().Euler()
397 });
398}
399
401{
402 check(CarlaActor != nullptr);
403
404 if (CarlaActor->IsPendingKill())
405 {
406 return;
407 }
408
410 CarlaActor->GetVehicleControl(Control);
411
412 // save
414 Record.DatabaseId = CarlaActor->GetActorId();
415 Record.Steering = Control.Steer;
416 Record.Throttle = Control.Throttle;
417 Record.Brake = Control.Brake;
419 Record.Gear = Control.Gear;
420 AddAnimVehicle(Record);
421}
422
424{
425 check(CarlaActor != nullptr)
426 if (CarlaActor->IsPendingKill())
427 return;
429 return;
430
431 ACarlaWheeledVehicle* CarlaVehicle = Cast<ACarlaWheeledVehicle>(CarlaActor->GetActor());
432 if (CarlaVehicle == nullptr)
433 return;
434
435 USkeletalMeshComponent* SkeletalMesh = CarlaVehicle->GetMesh();
436 if (SkeletalMesh == nullptr)
437 return;
438
439 UVehicleAnimInstance* VehicleAnim = Cast<UVehicleAnimInstance>(SkeletalMesh->GetAnimInstance());
440 if (VehicleAnim == nullptr)
441 return;
442
443 const UWheeledVehicleMovementComponent* WheeledVehicleMovementComponent = VehicleAnim->GetWheeledVehicleMovementComponent();
444 if (WheeledVehicleMovementComponent == nullptr)
445 return;
446
448 Record.DatabaseId = CarlaActor->GetActorId();
449 Record.WheelValues.reserve(WheeledVehicleMovementComponent->Wheels.Num());
450
451 uint8 i = 0;
452 for (auto Wheel : WheeledVehicleMovementComponent->Wheels)
453 {
455 Info.Location = static_cast<EVehicleWheelLocation>(i);
456 Info.SteeringAngle = CarlaVehicle->GetWheelSteerAngle(Info.Location);
457 Info.TireRotation = Wheel->GetRotationAngle();
458 Record.WheelValues.push_back(Info);
459 ++i;
460 }
461
462 AddAnimVehicleWheels(Record);
463
464 if (CarlaVehicle->IsTwoWheeledVehicle())
465 {
467 {
468 CarlaActor->GetActorId(),
469 WheeledVehicleMovementComponent->GetForwardSpeed(),
470 WheeledVehicleMovementComponent->GetEngineRotationSpeed() / WheeledVehicleMovementComponent->GetEngineMaxRotationSpeed()
471 });
472 }
473}
474
476{
477 check(CarlaActor != nullptr);
478
479 if (!CarlaActor->IsPendingKill())
480 {
482 CarlaActor->GetWalkerControl(Control);
484 {
485 CarlaActor->GetActorId(),
486 Control.Speed
487 });
488 }
489}
490
492{
493 check(CarlaActor != nullptr);
494
496 UTrafficLightController* Controller = CarlaActor->GetTrafficLightController();
497 if (Controller)
498 {
499 ATrafficLightGroup* Group = Controller->GetGroup();
500 if (Group)
501 {
503 {
504 CarlaActor->GetActorId(),
505 Group->IsFrozen(),
506 Controller->GetElapsedTime(),
507 static_cast<char>(LightState)
508 });
509 }
510 }
511}
512
514{
515 check(CarlaActor != nullptr);
516
518 CarlaActor->GetVehicleLightState(LightState);
519 CarlaRecorderLightVehicle LightVehicle;
520 LightVehicle.DatabaseId = CarlaActor->GetActorId();
522 AddLightVehicle(LightVehicle);
523}
524
526{
527 check(CarlaActor != nullptr);
528
529 FVector Velocity, AngularVelocity;
530 constexpr float TO_METERS = 1e-2;
531 Velocity = TO_METERS* CarlaActor->GetActorVelocity();
532 AngularVelocity = CarlaActor->GetActorAngularVelocity();
533 CarlaRecorderKinematics Kinematic =
534 {
535 CarlaActor->GetActorId(),
536 Velocity,
537 AngularVelocity
538 };
539 AddKinematics(Kinematic);
540}
541
543{
544 check(CarlaActor != nullptr);
545
546 const auto &Box = CarlaActor->GetActorInfo()->BoundingBox;
548 {
549 CarlaActor->GetActorId(),
550 {Box.Origin, Box.Extent}
551 };
552
554}
555
557{
558 TArray<UBoxComponent*> Triggers = TrafficSign.GetTriggerVolumes();
559 if(!Triggers.Num())
560 {
561 return;
562 }
563 UBoxComponent* Trigger = Triggers.Top();
564 auto VolumeOrigin = Trigger->GetComponentLocation();
565 auto VolumeExtent = Trigger->GetScaledBoxExtent();
567 {
568 Episode->GetActorRegistry().FindCarlaActor(&TrafficSign)->GetActorId(),
569 {VolumeOrigin, VolumeExtent}
570 };
572}
573
575{
577 Control.DatabaseId = Episode->GetActorRegistry().FindCarlaActor(&Vehicle)->GetActorId();
578 Control.VehiclePhysicsControl = Vehicle.GetVehiclePhysicsControl();
580}
581
583{
584 auto DatabaseId = Episode->GetActorRegistry().FindCarlaActor(&TrafficLight)->GetActorId();
586 DatabaseId,
587 TrafficLight.GetGreenTime(),
588 TrafficLight.GetYellowTime(),
589 TrafficLight.GetRedTime()
590 };
592}
593
598
600{
601 EventsAdd.Add(std::move(Event));
602}
603
605{
606 EventsDel.Add(std::move(Event));
607}
608
610{
611 EventsParent.Add(std::move(Event));
612}
613
615{
617
618 // // some inits
619 // Collision.Id = NextCollisionId++;
620 // Collision.IsActor1Hero = false;
621 // Collision.IsActor2Hero = false;
622
623 // // check actor 1
624 // FCarlaActor *FoundActor1 = Episode->GetActorRegistry().FindCarlaActor(Actor1);
625 // if (FoundActor1 != nullptr) {
626 // if (FoundActor1->GetActorInfo() != nullptr)
627 // {
628 // auto Role = FoundActor1->GetActorInfo()->Description.Variations.Find("role_name");
629 // if (Role != nullptr)
630 // Collision.IsActor1Hero = (Role->Value == "hero");
631 // }
632 // Collision.DatabaseId1 = FoundActor1->GetActorId();
633 // }
634 // else {
635 // Collision.DatabaseId1 = uint32_t(-1); // actor1 is not a registered Carla actor
636 // }
637
638 // // check actor 2
639 // FCarlaActor *FoundActor2 = Episode->GetActorRegistry().FindCarlaActor(Actor2);
640 // if (FoundActor2 != nullptr) {
641 // if (FoundActor2->GetActorInfo() != nullptr)
642 // {
643 // auto Role = FoundActor2->GetActorInfo()->Description.Variations.Find("role_name");
644 // if (Role != nullptr)
645 // Collision.IsActor2Hero = (Role->Value == "hero");
646 // }
647 // Collision.DatabaseId2 = FoundActor2->GetActorId();
648 // }
649 // else {
650 // Collision.DatabaseId2 = uint32_t(-1); // actor2 is not a registered Carla actor
651 // }
652
653 Collisions.Add(std::move(Collision));
654}
655
660
665
667{
668 Wheels.Add(VehicleWheels);
669}
670
672{
673 Bikers.Add(Biker);
674}
675
677{
678 Walkers.Add(Walker);
679}
680
682{
683 LightVehicles.Add(LightVehicle);
684}
685
686void FFrameData::AddEventLightSceneChanged(const UCarlaLight* Light)
687{
688 CarlaRecorderLightScene LightScene =
689 {
690 Light->GetId(),
691 Light->GetLightIntensity(),
692 Light->GetLightColor(),
693 Light->GetLightOn(),
694 static_cast<uint8>(Light->GetLightType())
695 };
696
697 LightScenes.Add(LightScene);
698}
699
701{
702 Kinematics.Add(ActorKinematics);
703}
704
706{
707 BoundingBoxes.Add(ActorBoundingBox);
708}
709
714
715// create or reuse an actor for replaying
716std::pair<int, FCarlaActor*> FFrameData::CreateOrReuseActor(
717 FVector &Location,
718 FVector &Rotation,
719 FActorDescription &ActorDesc,
720 uint32_t DesiredId,
721 bool SpawnSensors,
722 std::unordered_map<uint32_t, uint32_t>& MappedId)
723{
724 check(Episode != nullptr);
725
726 // 检查我们需要的 actor 类型
727 if (ActorDesc.Id.StartsWith("traffic."))
728 {
729 FCarlaActor* CarlaActor = FindTrafficLightAt(Location);
730 if (CarlaActor != nullptr)
731 {
732 // 重用该 Actor
733 UE_LOG(LogCarla, Log, TEXT("TrafficLight found"));
734 return std::pair<int, FCarlaActor*>(2, CarlaActor);
735 }
736 else
737 {
738 // 未找到执行组件
739 UE_LOG(LogCarla, Log, TEXT("TrafficLight not found"));
740 return std::pair<int, FCarlaActor*>(0, nullptr);
741 }
742 }
743 else if (SpawnSensors || !ActorDesc.Id.StartsWith("sensor."))
744 {
745 // 检查是否已经存在具有相同 ID 的该类型的 Actor
746 if (Episode->GetActorRegistry().Contains(DesiredId))
747 {
748 auto* CarlaActor = Episode->FindCarlaActor(DesiredId);
749 const FActorDescription *desc = &CarlaActor->GetActorInfo()->Description;
750 if (desc->Id == ActorDesc.Id)
751 {
752 // 我们不需要创建,相同类型的 Actor 已经存在
753 //搬迁
754 FRotator Rot = FRotator::MakeFromEuler(Rotation);
755 FTransform Trans2(Rot, Location, FVector(1, 1, 1));
756 CarlaActor->SetActorGlobalTransform(Trans2);
757 return std::pair<int, FCarlaActor*>(2, CarlaActor);
758 }
759 }
760 else if (MappedId.find(DesiredId) != MappedId.end() && Episode->GetActorRegistry().Contains(MappedId[DesiredId]))
761 {
762 auto* CarlaActor = Episode->FindCarlaActor(MappedId[DesiredId]);
763 const FActorDescription *desc = &CarlaActor->GetActorInfo()->Description;
764 if (desc->Id == ActorDesc.Id)
765 {
766 // 我们不需要创建,相同类型的 Actor 已经存在
767 //搬迁
768 FRotator Rot = FRotator::MakeFromEuler(Rotation);
769 FTransform Trans2(Rot, Location, FVector(1, 1, 1));
770 CarlaActor->SetActorGlobalTransform(Trans2);
771 return std::pair<int, FCarlaActor*>(2, CarlaActor);
772 }
773 }
774 // 创建新角色
775 // 创建转换
776 FRotator Rot = FRotator::MakeFromEuler(Rotation);
777 FTransform Trans(Rot, FVector(0, 0, 100000), FVector(1, 1, 1));
778 // 创建新角色
779 TPair<EActorSpawnResultStatus, FCarlaActor*> Result = Episode->SpawnActorWithInfo(Trans, ActorDesc, DesiredId);
780 if (Result.Key == EActorSpawnResultStatus::Success)
781 {
782 // 搬迁
783 FTransform Trans2(Rot, Location, FVector(1, 1, 1));
784 Result.Value->SetActorGlobalTransform(Trans2);
785 ALargeMapManager * LargeMapManager = UCarlaStatics::GetLargeMapManager(Episode->GetWorld());
786 if (LargeMapManager)
787 {
788 LargeMapManager->OnActorSpawned(*Result.Value);
789 }
790 return std::pair<int, FCarlaActor*>(1, Result.Value);
791 }
792 else
793 {
794 UE_LOG(LogCarla, Log, TEXT("Actor could't be created"));
795 return std::pair<int, FCarlaActor*>(0, Result.Value);
796 }
797 }
798 else
799 {
800 // Actor 已忽略
801 return std::pair<int, FCarlaActor*>(0, nullptr);
802 }
803}
804
805// 用于创建 Actor 的 Replay 事件
806std::pair<int, uint32_t> FFrameData::ProcessReplayerEventAdd(
807 FVector Location,
808 FVector Rotation,
810 uint32_t DesiredId,
811 bool bIgnoreHero,
812 bool ReplaySensors,
813 std::unordered_map<uint32_t, uint32_t>& MappedId)
814{
815 check(Episode != nullptr);
816 FActorDescription ActorDesc;
817 bool IsHero = false;
818
819 //准备角色描述
820 ActorDesc.UId = Description.UId;
821 ActorDesc.Id = Description.Id;
822 for (const auto &Item : Description.Attributes)
823 {
824 FActorAttribute Attr;
825 Attr.Type = static_cast<EActorAttributeType>(Item.Type);
826 Attr.Id = Item.Id;
827 Attr.Value = Item.Value;
828 ActorDesc.Variations.Add(Attr.Id, std::move(Attr));
829 // check for hero
830 if (Item.Id == "role_name" && Item.Value == "hero")
831 IsHero = true;
832 }
833
834 auto result = CreateOrReuseActor(
835 Location,
836 Rotation,
837 ActorDesc,
838 DesiredId,
839 ReplaySensors,
840 MappedId);
841
842 if (result.first != 0)
843 {
844 //在车辆上禁用 Physics 和 Autopilot
845 if (result.second->GetActorType() == FCarlaActor::ActorType::Vehicle)
846 {
847 // ignore hero ?
848 if (!(bIgnoreHero && IsHero))
849 {
850 // disable physics
851 SetActorSimulatePhysics(result.second, false);
852 // disable autopilot
853 // SetActorAutopilot(result.second, false, false);
854 }
855 else
856 {
857 // 重新启用物理学以防万一
858 SetActorSimulatePhysics(result.second, true);
859 }
860 }
861 return std::make_pair(result.first, result.second->GetActorId());
862 }
863 return std::make_pair(result.first, 0);
864}
865
866//用于删除 Actor 的 replay 事件
867bool FFrameData::ProcessReplayerEventDel(uint32_t DatabaseId)
868{
869 check(Episode != nullptr);
870 FCarlaActor* CarlaActor = Episode->FindCarlaActor(DatabaseId);
871 if (CarlaActor == nullptr)
872 {
873 UE_LOG(LogCarla, Log, TEXT("Actor %d not found to destroy"), DatabaseId);
874 return false;
875 }
876 Episode->DestroyActor(CarlaActor->GetActorId());
877 return true;
878}
879
880// Replay 事件
881bool FFrameData::ProcessReplayerEventParent(uint32_t ChildId, uint32_t ParentId)
882{
883 check(Episode != nullptr);
884 FCarlaActor * Child = Episode->FindCarlaActor(ChildId);
885 FCarlaActor * Parent = Episode->FindCarlaActor(ParentId);
886 if(!Child)
887 {
888 UE_LOG(LogCarla, Log, TEXT("Parenting Child actors not found"));
889 return false;
890 }
891 if(!Parent)
892 {
893 UE_LOG(LogCarla, Log, TEXT("Parenting Parent actors not found"));
894 return false;
895 }
896 Child->SetParent(ParentId);
898 Parent->AddChildren(Child->GetActorId());
899 if(!Parent->IsDormant())
900 {
901 if(!Child->IsDormant())
902 {
903 Episode->AttachActors(
904 Child->GetActor(),
905 Parent->GetActor(),
907 }
908 }
909 else
910 {
911 Episode->PutActorToSleep(Child->GetActorId());
912 }
913 return true;
914}
915
916// reposition actors
918{
919 check(Episode != nullptr);
920 FCarlaActor* CarlaActor = Episode->FindCarlaActor(Pos1.DatabaseId);
921 FVector Location;
922 FRotator Rotation;
923 if(CarlaActor)
924 {
925 // check to assign first position or interpolate between both
926 if (Per == 0.0)
927 {
928 // assign position 1
929 Location = FVector(Pos1.Location);
930 Rotation = FRotator::MakeFromEuler(Pos1.Rotation);
931 }
932 else
933 {
934 // interpolate positions
935 Location = FMath::Lerp(FVector(Pos1.Location), FVector(Pos2.Location), Per);
936 Rotation = FMath::Lerp(FRotator::MakeFromEuler(Pos1.Rotation), FRotator::MakeFromEuler(Pos2.Rotation), Per);
937 }
938 // set new transform
939 FTransform Trans(Rotation, Location, FVector(1, 1, 1));
940 CarlaActor->SetActorGlobalTransform(Trans, ETeleportType::None);
941 return true;
942 }
943 return false;
944}
945
946// reposition the camera
947bool FFrameData::SetCameraPosition(uint32_t Id, FVector Offset, FQuat Rotation)
948{
949 check(Episode != nullptr);
950
951 // get the actor to follow
952 FCarlaActor* CarlaActor = Episode->FindCarlaActor(Id);
953 if (!CarlaActor)
954 return false;
955 // get specator pawn
956 APawn *Spectator = Episode->GetSpectatorPawn();
957 if (!Spectator)
958 return false;
959
960 FCarlaActor* CarlaSpectator = Episode->FindCarlaActor(Spectator);
961 if (!CarlaSpectator)
962 return false;
963
964 FTransform ActorTransform = CarlaActor->GetActorGlobalTransform();
965 // set the new position
966 FQuat ActorRot = ActorTransform.GetRotation();
967 FVector Pos = ActorTransform.GetTranslation() + (ActorRot.RotateVector(Offset));
968 CarlaSpectator->SetActorGlobalTransform(FTransform(ActorRot * Rotation, Pos, FVector(1,1,1)));
969
970 return true;
971}
972
974{
975 check(Episode != nullptr);
976 FCarlaActor* CarlaActor = Episode->FindCarlaActor(State.DatabaseId);
977 if(CarlaActor)
978 {
979 CarlaActor->SetTrafficLightState(static_cast<ETrafficLightState>(State.State));
980 UTrafficLightController* Controller = CarlaActor->GetTrafficLightController();
981 if(Controller)
982 {
983 Controller->SetElapsedTime(State.ElapsedTime);
984 ATrafficLightGroup* Group = Controller->GetGroup();
985 if (Group)
986 {
987 Group->SetFrozenGroup(State.IsFrozen);
988 }
989 }
990 return true;
991 }
992 return false;
993}
994
995// set the animation for Vehicles
997{
998 check(Episode != nullptr);
999 FCarlaActor *CarlaActor = Episode->FindCarlaActor(Vehicle.DatabaseId);
1000 if (CarlaActor)
1001 {
1003 Control.Throttle = Vehicle.Throttle;
1004 Control.Steer = Vehicle.Steering;
1005 Control.Brake = Vehicle.Brake;
1006 Control.bHandBrake = Vehicle.bHandbrake;
1007 Control.bReverse = (Vehicle.Gear < 0);
1008 Control.Gear = Vehicle.Gear;
1009 Control.bManualGearShift = false;
1010 CarlaActor->ApplyControlToVehicle(Control, EVehicleInputPriority::User);
1011 }
1012}
1013
1015{
1016 check(Episode != nullptr)
1017 FCarlaActor *CarlaActor = Episode->FindCarlaActor(VehicleAnimWheels.DatabaseId);
1018 if (CarlaActor == nullptr)
1019 return;
1020 if (CarlaActor->GetActorType() != FCarlaActor::ActorType::Vehicle)
1021 return;
1022 ACarlaWheeledVehicle* CarlaVehicle = Cast<ACarlaWheeledVehicle>(CarlaActor->GetActor());
1023 check(CarlaVehicle != nullptr)
1024 USkeletalMeshComponent* SkeletalMesh = CarlaVehicle->GetMesh();
1025 check(SkeletalMesh != nullptr)
1026 UVehicleAnimInstance* VehicleAnim = Cast<UVehicleAnimInstance>(SkeletalMesh->GetAnimInstance());
1027 check(VehicleAnim != nullptr)
1028
1029 for (uint32_t i = 0; i < VehicleAnimWheels.WheelValues.size(); ++i)
1030 {
1031 const WheelInfo& Element = VehicleAnimWheels.WheelValues[i];
1032 VehicleAnim->SetWheelRotYaw(static_cast<uint8>(Element.Location), Element.SteeringAngle);
1033 VehicleAnim->SetWheelPitchAngle(static_cast<uint8>(Element.Location), Element.TireRotation);
1034 }
1035}
1036
1037// 为车辆设置灯光
1039{
1040 check(Episode != nullptr);
1041 FCarlaActor * CarlaActor = Episode->FindCarlaActor(LightVehicle.DatabaseId);
1042 if (CarlaActor)
1043 {
1046 }
1047}
1048
1050{
1051 check(Episode != nullptr);
1052 UWorld* World = Episode->GetWorld();
1053 if(World)
1054 {
1055 UCarlaLightSubsystem* CarlaLightSubsystem = World->GetSubsystem<UCarlaLightSubsystem>();
1056 if (!CarlaLightSubsystem)
1057 {
1058 return;
1059 }
1060 auto* CarlaLight = CarlaLightSubsystem->GetLight(LightScene.LightId);
1061 if (CarlaLight)
1062 {
1063 CarlaLight->SetLightIntensity(LightScene.Intensity);
1064 CarlaLight->SetLightColor(LightScene.Color);
1065 CarlaLight->SetLightOn(LightScene.bOn);
1066 CarlaLight->SetLightType(static_cast<ELightType>(LightScene.Type));
1067 }
1068 }
1069}
1070
1071// 设置行走者的动画
1076
1078{
1079 check(Episode != nullptr);
1080 FCarlaActor * CarlaActor = Episode->FindCarlaActor(Biker.DatabaseId);
1081 if (CarlaActor == nullptr)
1082 return;
1083 ACarlaWheeledVehicle* CarlaVehicle = Cast<ACarlaWheeledVehicle>(CarlaActor->GetActor());
1084 check(CarlaVehicle != nullptr)
1085 CarlaVehicle->SetSpeedAnim(Biker.ForwardSpeed);
1086 CarlaVehicle->SetRotationAnim(Biker.EngineRotation);
1087}
1088
1089
1090//重播结束
1091bool FFrameData::ProcessReplayerFinish(bool bApplyAutopilot, bool bIgnoreHero, std::unordered_map<uint32_t, bool> &IsHero)
1092{
1093 // 为所有 AI 车辆设置 Autopilot 和 Physics
1094 const FActorRegistry& Registry = Episode->GetActorRegistry();
1095 for (auto& It : Registry)
1096 {
1097 FCarlaActor* CarlaActor = It.Value.Get();
1098
1099 //仅在载具上启用物理
1100 switch (CarlaActor->GetActorType())
1101 {
1102
1103 // vehicles
1105 // check for hero
1106 if (!(bIgnoreHero && IsHero[CarlaActor->GetActorId()]))
1107 {
1108 // stop all vehicles
1109 SetActorSimulatePhysics(CarlaActor, true);
1110 SetActorVelocity(CarlaActor, FVector(0, 0, 0));
1112 Control.Throttle = 0.0f;
1113 Control.Steer = 0.0f;
1114 Control.Brake = 0.0f;
1115 Control.bHandBrake = false;
1116 Control.bReverse = false;
1117 Control.Gear = 1;
1118 Control.bManualGearShift = false;
1119 CarlaActor->ApplyControlToVehicle(Control, EVehicleInputPriority::User);
1120 }
1121 break;
1122
1123 // walkers
1125 // stop walker
1126 SetWalkerSpeed(CarlaActor->GetActorId(), 0.0f);
1127 break;
1128 }
1129 }
1130 return true;
1131}
1132
1133void FFrameData::SetActorVelocity(FCarlaActor *CarlaActor, FVector Velocity)
1134{
1135 if (!CarlaActor)
1136 {
1137 return;
1138 }
1139 CarlaActor->SetActorTargetVelocity(Velocity);
1140}
1141
1142//设置行走者的动画速度
1143void FFrameData::SetWalkerSpeed(uint32_t ActorId, float Speed)
1144{
1145 check(Episode != nullptr);
1146 FCarlaActor * CarlaActor = Episode->FindCarlaActor(ActorId);
1147 if (!CarlaActor)
1148 {
1149 return;
1150 }
1152 Control.Speed = Speed;
1153 CarlaActor->ApplyControlToWalker(Control);
1154}
1155
1156// 启用/禁用 Actor 的物理特性)
1157bool FFrameData::SetActorSimulatePhysics(FCarlaActor* CarlaActor, bool bEnabled)
1158{
1159 if (!CarlaActor)
1160 {
1161 return false;
1162 }
1163 ECarlaServerResponse Response =
1164 CarlaActor->SetActorSimulatePhysics(bEnabled);
1165 if (Response != ECarlaServerResponse::Success)
1166 {
1167 return false;
1168 }
1169 return true;
1170}
1171
1176
1178{
1179 check(Episode != nullptr);
1180 auto World = Episode->GetWorld();
1181 check(World != nullptr);
1182
1183 // 获取其位置 (截断为 int)
1184 int x = static_cast<int>(Location.X);
1185 int y = static_cast<int>(Location.Y);
1186 int z = static_cast<int>(Location.Z);
1187
1188 const FActorRegistry &Registry = Episode->GetActorRegistry();
1189 // 通过 Registry 中的所有参与者
1190 for (auto It = Registry.begin(); It != Registry.end(); ++It)
1191 {
1192 FCarlaActor* CarlaActor = It.Value().Get();
1194 {
1195 FVector vec = CarlaActor->GetActorGlobalLocation();
1196 int x2 = static_cast<int>(vec.X);
1197 int y2 = static_cast<int>(vec.Y);
1198 int z2 = static_cast<int>(vec.Z);
1199 if ((x2 == x) && (y2 == y) && (z2 == z))
1200 {
1201 // 找到actor
1202 return CarlaActor;
1203 }
1204 }
1205 }
1206 // 丢失actor
1207 return nullptr;
1208}
1209
1211{
1212 // reginstring 第一帧中的所有现有 Actor
1213 FActorRegistry Registry = Episode->GetActorRegistry();
1214 for (auto& It : Registry)
1215 {
1216 const FCarlaActor* CarlaActor = It.Value.Get();
1217 if (CarlaActor != nullptr)
1218 {
1219 // 创建事件
1221 CarlaActor->GetActorId(),
1222 static_cast<uint8_t>(CarlaActor->GetActorType()),
1223 CarlaActor->GetActorGlobalTransform(),
1224 CarlaActor->GetActorInfo()->Description,
1225 false);
1226 }
1227 }
1228}
EAttachmentType
FVehicleLightState LightState
Definition ActorData.h:131
FVehicleControl Control
Definition ActorData.h:119
UE_LOG(LogCarla, Log, TEXT("UActorDispatcher::Destroying actor: '%s' %x"), *Id, Actor)
TSharedPtr< const FActorInfo > carla::rpc::ActorState UWorld * World
ELightType
Definition CarlaLight.h:25
ECarlaServerResponse
EVehicleWheelLocation
SetFrameCounter()
EActorAttributeType
List of valid types for actor attributes.(角色属性有效类型的列表)
Base class for CARLA wheeled vehicles.
float GetWheelSteerAngle(EVehicleWheelLocation WheelLocation)
void SetRotationAnim(float Rotation)
void SetSpeedAnim(float Speed)
void OnActorSpawned(const FCarlaActor &CarlaActor)
如果你的类继承自UObject,你的类名上方需要加入 UCLASS() 宏 实现交通信号灯状态改变的类
void SetFrozenGroup(bool InFreeze)
TArray< UBoxComponent * > GetTriggerVolumes() const
void Add(const CarlaRecorderActorBoundingBox &InObj)
void Add(const CarlaRecorderActorBoundingBox &InObj)
void Add(const CarlaRecorderKinematics &InObj)
void Write(std::ostream &OutFile) const
void Add(const CarlaRecorderAnimBiker &InObj)
void Read(std::istream &InFile)
void Add(const CarlaRecorderAnimWheels &InObj)
void Write(std::ostream &OutFile)
void Read(std::istream &InFile)
void Add(const CarlaRecorderAnimVehicle &InObj)
void Add(const CarlaRecorderAnimWalker &InObj)
void Read(std::istream &InFile)
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderCollision &Collision)
void Add(const CarlaRecorderEventAdd &Event)
void Read(std::istream &InFile)
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderEventDel &Event)
void Write(std::ostream &OutFile)
void Read(std::istream &InFile)
void Write(std::ostream &OutFile)
void Read(std::istream &InFile)
void Add(const CarlaRecorderEventParent &Event)
void Add(const CarlaRecorderPhysicsControl &InObj)
void Add(const CarlaRecorderPosition &InObj)
void Read(std::istream &InFile)
void Write(std::ostream &OutFile)
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderStateTrafficLight &State)
void Read(std::istream &InFile)
void Add(const CarlaRecorderTrafficLightTime &InObj)
所有Carla角色的注册表
查看一个参与者和它的属性
Definition CarlaActor.h:23
ActorType GetActorType() const
Definition CarlaActor.h:71
bool IsDormant() const
Definition CarlaActor.h:59
AActor * GetActor()
Definition CarlaActor.h:75
virtual ECarlaServerResponse SetVehicleLightState(const FVehicleLightState &)
Definition CarlaActor.h:234
virtual ECarlaServerResponse ApplyControlToVehicle(const FVehicleControl &, const EVehicleInputPriority &)
Definition CarlaActor.h:249
FVector GetActorAngularVelocity() const
void SetParent(IdType InParentId)
Definition CarlaActor.h:95
void SetAttachmentType(carla::rpc::AttachmentType InAttachmentType)
Definition CarlaActor.h:116
virtual ECarlaServerResponse GetVehicleLightState(FVehicleLightState &)
Definition CarlaActor.h:214
FTransform GetActorGlobalTransform() const
FVector GetActorVelocity() const
void SetActorGlobalTransform(const FTransform &Transform, ETeleportType Teleport=ETeleportType::TeleportPhysics)
virtual ECarlaServerResponse ApplyControlToWalker(const FWalkerControl &)
Definition CarlaActor.h:359
virtual ECarlaServerResponse GetVehicleControl(FVehicleControl &)
Definition CarlaActor.h:261
FVector GetActorGlobalLocation() const
bool IsPendingKill() const
Definition CarlaActor.h:63
void AddChildren(IdType ChildId)
Definition CarlaActor.h:103
virtual ETrafficLightState GetTrafficLightState() const
Definition CarlaActor.h:324
virtual UTrafficLightController * GetTrafficLightController()
Definition CarlaActor.h:329
virtual ECarlaServerResponse GetWalkerControl(FWalkerControl &)
Definition CarlaActor.h:364
const FActorInfo * GetActorInfo() const
Definition CarlaActor.h:83
IdType GetActorId() const
Definition CarlaActor.h:67
ECarlaServerResponse SetActorTargetVelocity(const FVector &Velocity)
virtual ECarlaServerResponse SetActorSimulatePhysics(bool bEnabled)
virtual ECarlaServerResponse SetTrafficLightState(const ETrafficLightState &)
Definition CarlaActor.h:319
static uint64_t GetFrameCounter()
Definition CarlaEngine.h:68
static void ResetFrameCounter(uint64_t Value=0)
Definition CarlaEngine.h:86
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 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)
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:80
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 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)
void AddAnimWalker(const CarlaRecorderAnimWalker &Walker)
void AddKinematics(const CarlaRecorderKinematics &ActorKinematics)
void AddTrafficLightState(FCarlaActor *CarlaActor)
void Clear()
void AddBoundingBox(const CarlaRecorderActorBoundingBox &ActorBoundingBox)
UCarlaLight * GetLight(int Id)
static ALargeMapManager * GetLargeMapManager(const UObject *WorldContextObject)
从 OpenDrive 映射一个控制器。控制相关交通信号灯并包含其循环
void SetElapsedTime(float InElapsedTime)
ATrafficLightGroup * GetGroup()
定义车辆的物理外观,通过传感器获取
flag_type light_state
灯光状态标志,默认情况下全部关闭
std::vector< CarlaRecorderActorAttribute > Attributes
void Write(std::ostream &OutFile)
void Read(std::istream &InFile)
void Read(std::istream &InFile)
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderLightScene &InObj)
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderLightVehicle &InObj)
An actor attribute, may be an intrinsic (non-modifiable) attribute of the actor or an user-defined ac...
TMap< FString, FActorAttribute > Variations
用户选择了参与者的变化版本。请注意,此时是 由不可修改的属性表示
FBoundingBox BoundingBox
Definition ActorInfo.h:37
FActorDescription Description
Definition ActorInfo.h:31
EVehicleWheelLocation Location