CARLA
FrameData.cpp
Go to the documentation of this file.
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"
10 #include "Carla/Game/CarlaEngine.h"
17 
21 
22 
23 void FFrameData::GetFrameData(UCarlaEpisode *ThisEpisode, bool bAdditionalData, bool bIncludeActorsAgain)
24 {
25  Episode = ThisEpisode;
26  // PlatformTime.UpdateTime();
27  const FActorRegistry &Registry = Episode->GetActorRegistry();
28 
29  if (bIncludeActorsAgain)
30  {
32  }
33 
34  // through all actors in registry
35  for (auto It = Registry.begin(); It != Registry.end(); ++It)
36  {
37  FCarlaActor* View = It.Value().Get();
38 
39  switch (View->GetActorType())
40  {
41  // save the transform for props
44  AddActorPosition(View);
45  break;
46 
47  // save the transform of all vehicles
49  AddActorPosition(View);
50  AddVehicleAnimation(View);
51  AddVehicleLight(View);
53  if (bAdditionalData)
54  {
55  AddActorKinematics(View);
56  }
57  break;
58 
59  // save the transform of all walkers
61  AddActorPosition(View);
62  AddWalkerAnimation(View);
63  if (bAdditionalData)
64  {
65  AddActorKinematics(View);
66  }
67  break;
68 
69  // save the state of each traffic light
72  break;
73  }
74  }
76 }
77 
79  UCarlaEpisode *ThisEpisode,
80  std::unordered_map<uint32_t, uint32_t>& MappedId)
81 {
82 
84  {
85  uint32_t OldId = EventAdd.DatabaseId;
86  // Todo: check memory corruption of EventAdd.DatabaseId
87  auto Result = ProcessReplayerEventAdd(
88  EventAdd.Location,
89  EventAdd.Rotation,
90  EventAdd.Description,
91  EventAdd.DatabaseId,
92  false,
93  true,
94  MappedId);
95  switch (Result.first)
96  {
97  // actor not created
98  case 0:
99  UE_LOG(LogCarla, Log, TEXT("actor could not be created"));
100  break;
101 
102  // actor created but with different id
103  case 1:
104  // mapping id (recorded Id is a new Id in replayer)
105  MappedId[OldId] = Result.second;
106  UE_LOG(LogCarla, Log, TEXT("actor created"));
107  break;
108 
109  // actor reused from existing
110  case 2:
111  // mapping id (say desired Id is mapped to what)
112  MappedId[OldId] = Result.second;
113  UE_LOG(LogCarla, Log, TEXT("actor reused"));
114  break;
115  }
116  }
117 
119  {
120  ProcessReplayerEventDel(MappedId[EventDel.DatabaseId]);
121  MappedId.erase(EventDel.DatabaseId);
122  }
123 
125  {
127  auto NewId = MappedId.find(Pos.DatabaseId);
128  if (NewId != MappedId.end())
129  {
130  Pos.DatabaseId = NewId->second;
131  ProcessReplayerPosition(Pos, Pos, 0.0, 0.0);
132  }
133  }
134 
136  {
137  CarlaRecorderStateTrafficLight StateTrafficLight = State;
138  StateTrafficLight.DatabaseId = MappedId[StateTrafficLight.DatabaseId];
139  ProcessReplayerStateTrafficLight(StateTrafficLight);
140  }
141 
143  {
145  Vehicle.DatabaseId = MappedId[Vehicle.DatabaseId];
147  }
148 
149  for (const CarlaRecorderAnimWheels &AnimWheel : Wheels.GetVehicleWheels())
150  {
151  CarlaRecorderAnimWheels Wheels = AnimWheel;
152  Wheels.DatabaseId = MappedId[Wheels.DatabaseId];
154  }
155 
157  {
159  Walker.DatabaseId = MappedId[Walker.DatabaseId];
161  }
162 
164  {
166  Biker.DatabaseId = MappedId[Biker.DatabaseId];
168  }
169 
170  for (const CarlaRecorderLightVehicle &LightVehicle : LightVehicles.GetLightVehicles())
171  {
172  CarlaRecorderLightVehicle Light = LightVehicle;
173  Light.DatabaseId = MappedId[Light.DatabaseId];
175  }
176 
177  for (const CarlaRecorderLightScene &Light : LightScenes.GetLights())
178  {
180  }
181 
182  SetFrameCounter();
183 }
184 
186 {
187  EventsAdd.Clear();
188  EventsDel.Clear();
190  Collisions.Clear();
191  Positions.Clear();
192  States.Clear();
193  Vehicles.Clear();
194  Wheels.Clear();
195  Walkers.Clear();
196  Bikers.Clear();
198  LightScenes.Clear();
199  Kinematics.Clear();
205 }
206 
207 void FFrameData::Write(std::ostream& OutStream)
208 {
209  EventsAdd.Write(OutStream);
210  EventsDel.Write(OutStream);
211  EventsParent.Write(OutStream);
212  Positions.Write(OutStream);
213  States.Write(OutStream);
214  Vehicles.Write(OutStream);
215  Wheels.Write(OutStream);
216  Walkers.Write(OutStream);
217  Bikers.Write(OutStream);
218  LightVehicles.Write(OutStream);
219  LightScenes.Write(OutStream);
220  TrafficLightTimes.Write(OutStream);
221  FrameCounter.Write(OutStream);
222 }
223 
224 void FFrameData::Read(std::istream& InStream)
225 {
226  Clear();
227  while(!InStream.eof())
228  {
229  Header header;
230  ReadValue<char>(InStream, header.Id);
231  ReadValue<uint32_t>(InStream, header.Size);
232  switch (header.Id)
233  {
234  // events add
235  case static_cast<char>(CarlaRecorderPacketId::EventAdd):
236  EventsAdd.Read(InStream);
237  break;
238 
239  // events del
240  case static_cast<char>(CarlaRecorderPacketId::EventDel):
241  EventsDel.Read(InStream);
242  break;
243 
244  // events parent
245  case static_cast<char>(CarlaRecorderPacketId::EventParent):
246  EventsParent.Read(InStream);
247  break;
248 
249  // positions
250  case static_cast<char>(CarlaRecorderPacketId::Position):
251  Positions.Read(InStream);
252  break;
253 
254  // states
255  case static_cast<char>(CarlaRecorderPacketId::State):
256  States.Read(InStream);
257  break;
258 
259  // vehicle animation
260  case static_cast<char>(CarlaRecorderPacketId::AnimVehicle):
261  Vehicles.Read(InStream);
262  break;
263 
264  // walker animation
265  case static_cast<char>(CarlaRecorderPacketId::AnimWalker):
266  Walkers.Read(InStream);
267  break;
268 
269  // walker animation
270  case static_cast<char>(CarlaRecorderPacketId::AnimVehicleWheels):
271  Wheels.Read(InStream);
272  break;
273 
274  // walker animation
275  case static_cast<char>(CarlaRecorderPacketId::AnimBiker):
276  Bikers.Read(InStream);
277  break;
278 
279  // vehicle light animation
280  case static_cast<char>(CarlaRecorderPacketId::VehicleLight):
281  LightVehicles.Read(InStream);
282  break;
283 
284  // scene lights animation
285  case static_cast<char>(CarlaRecorderPacketId::SceneLight):
286  LightScenes.Read(InStream);
287  break;
288 
289  case static_cast<char>(CarlaRecorderPacketId::FrameCounter):
290  FrameCounter.Read(InStream);
291  break;
292 
293  // unknown packet, just skip
294  default:
295  // skip packet
296  InStream.seekg(header.Size, std::ios::cur);
297  break;
298 
299  }
300  }
301 }
302 
304  uint32_t DatabaseId,
305  uint8_t Type,
306  const FTransform &Transform,
307  FActorDescription ActorDescription,
308  bool bAddOtherRelatedInfo)
309 {
310  CarlaRecorderActorDescription Description;
311  Description.UId = ActorDescription.UId;
312  Description.Id = ActorDescription.Id;
313 
314  // attributes
315  Description.Attributes.reserve(ActorDescription.Variations.Num());
316  for (const auto &item : ActorDescription.Variations)
317  {
319  Attr.Type = static_cast<uint8_t>(item.Value.Type);
320  Attr.Id = item.Value.Id;
321  Attr.Value = item.Value.Value;
322  // check for empty attributes
323  if (!Attr.Id.IsEmpty())
324  {
325  Description.Attributes.emplace_back(std::move(Attr));
326  }
327  }
328 
329  // recorder event
330  CarlaRecorderEventAdd RecEvent
331  {
332  DatabaseId,
333  Type,
334  Transform.GetTranslation(),
335  Transform.GetRotation().Euler(),
336  std::move(Description)
337  };
338  AddEvent(std::move(RecEvent));
339 
340  if (!bAddOtherRelatedInfo)
341  {
342  return;
343  }
344 
345  // Other events related to spawning actors
346  FCarlaActor* CarlaActor = Episode->FindCarlaActor(DatabaseId);
347  if (!CarlaActor)
348  {
349  return;
350  }
351 
352  // check if it is a vehicle to get initial physics control
353  ACarlaWheeledVehicle* Vehicle = Cast<ACarlaWheeledVehicle>(CarlaActor->GetActor());
354  if (Vehicle)
355  {
356  AddPhysicsControl(*Vehicle);
357  }
358 
359  ATrafficLightBase* TrafficLight = Cast<ATrafficLightBase>(CarlaActor->GetActor());
360  if (TrafficLight)
361  {
362  AddTrafficLightTime(*TrafficLight);
363  }
364 
365  ATrafficSignBase* TrafficSign = Cast<ATrafficSignBase>(CarlaActor->GetActor());
366  if (TrafficSign)
367  {
368  // Trigger volume in global coordinates
369  AddTriggerVolume(*TrafficSign);
370  }
371  else
372  {
373  // Bounding box in local coordinates
374  AddActorBoundingBox(CarlaActor);
375  }
376 }
377 
378 
380 {
381  check(CarlaActor != nullptr);
382 
383  FTransform Transform = CarlaActor->GetActorGlobalTransform();
384  // get position of the vehicle
386  {
387  CarlaActor->GetActorId(),
388  Transform.GetLocation(),
389  Transform.GetRotation().Euler()
390  });
391 }
392 
394 {
395  check(CarlaActor != nullptr);
396 
397  if (CarlaActor->IsPendingKill())
398  {
399  return;
400  }
401 
402  FVehicleControl Control;
403  CarlaActor->GetVehicleControl(Control);
404 
405  // save
407  Record.DatabaseId = CarlaActor->GetActorId();
408  Record.Steering = Control.Steer;
409  Record.Throttle = Control.Throttle;
410  Record.Brake = Control.Brake;
411  Record.bHandbrake = Control.bHandBrake;
412  Record.Gear = Control.Gear;
413  AddAnimVehicle(Record);
414 }
415 
417 {
418  check(CarlaActor != nullptr)
419  if (CarlaActor->IsPendingKill())
420  return;
421  if (CarlaActor->GetActorType() != FCarlaActor::ActorType::Vehicle)
422  return;
423  ACarlaWheeledVehicle* CarlaVehicle = Cast<ACarlaWheeledVehicle>(CarlaActor->GetActor());
424  check(CarlaVehicle != nullptr)
425  USkeletalMeshComponent* SkeletalMesh = CarlaVehicle->GetMesh();
426  check(SkeletalMesh != nullptr)
427  UVehicleAnimInstance* VehicleAnim = Cast<UVehicleAnimInstance>(SkeletalMesh->GetAnimInstance());
428  check(VehicleAnim != nullptr)
429  const UWheeledVehicleMovementComponent* WheeledVehicleMovementComponent = VehicleAnim->GetWheeledVehicleMovementComponent();
430  check(WheeledVehicleMovementComponent != nullptr)
431 
433  Record.DatabaseId = CarlaActor->GetActorId();
434 
435  WheelInfo FL;
437  FL.SteeringAngle = CarlaVehicle->GetWheelSteerAngle(FL.Location);
438  FL.TireRotation = WheeledVehicleMovementComponent->Wheels[static_cast<uint8>(FL.Location)]->GetRotationAngle();
439 
440  WheelInfo FR;
442  FR.SteeringAngle = CarlaVehicle->GetWheelSteerAngle(FR.Location);
443  FR.TireRotation = WheeledVehicleMovementComponent->Wheels[static_cast<uint8>(FR.Location)]->GetRotationAngle();
444 
445  WheelInfo BL;
447  BL.SteeringAngle = CarlaVehicle->GetWheelSteerAngle(BL.Location);
448  BL.TireRotation = WheeledVehicleMovementComponent->Wheels[static_cast<uint8>(BL.Location)]->GetRotationAngle();
449 
450  WheelInfo BR;
452  BR.SteeringAngle = CarlaVehicle->GetWheelSteerAngle(BR.Location);
453  BR.TireRotation = WheeledVehicleMovementComponent->Wheels[static_cast<uint8>(BR.Location)]->GetRotationAngle();
454 
455  Record.WheelValues.reserve(4);
456  Record.WheelValues.push_back(FL);
457  Record.WheelValues.push_back(FR);
458  Record.WheelValues.push_back(BL);
459  Record.WheelValues.push_back(BR);
460 
461  AddAnimVehicleWheels(Record);
462 
463  if (CarlaVehicle->IsTwoWheeledVehicle())
464  {
466  {
467  CarlaActor->GetActorId(),
468  WheeledVehicleMovementComponent->GetForwardSpeed(),
469  WheeledVehicleMovementComponent->GetEngineRotationSpeed() / WheeledVehicleMovementComponent->GetEngineMaxRotationSpeed()
470  });
471  }
472 }
473 
475 {
476  check(CarlaActor != nullptr);
477 
478  if (!CarlaActor->IsPendingKill())
479  {
480  FWalkerControl Control;
481  CarlaActor->GetWalkerControl(Control);
483  {
484  CarlaActor->GetActorId(),
485  Control.Speed
486  });
487  }
488 }
489 
491 {
492  check(CarlaActor != nullptr);
493 
494  ETrafficLightState LightState = CarlaActor->GetTrafficLightState();
495  UTrafficLightController* Controller = CarlaActor->GetTrafficLightController();
496  if (Controller)
497  {
498  ATrafficLightGroup* Group = Controller->GetGroup();
499  if (Group)
500  {
502  {
503  CarlaActor->GetActorId(),
504  Group->IsFrozen(),
505  Controller->GetElapsedTime(),
506  static_cast<char>(LightState)
507  });
508  }
509  }
510 }
511 
513 {
514  check(CarlaActor != nullptr);
515 
516  FVehicleLightState LightState;
517  CarlaActor->GetVehicleLightState(LightState);
518  CarlaRecorderLightVehicle LightVehicle;
519  LightVehicle.DatabaseId = CarlaActor->GetActorId();
520  LightVehicle.State = carla::rpc::VehicleLightState(LightState).light_state;
521  AddLightVehicle(LightVehicle);
522 }
523 
525 {
526  check(CarlaActor != nullptr);
527 
528  FVector Velocity, AngularVelocity;
529  constexpr float TO_METERS = 1e-2;
530  Velocity = TO_METERS* CarlaActor->GetActorVelocity();
531  AngularVelocity = CarlaActor->GetActorAngularVelocity();
532  CarlaRecorderKinematics Kinematic =
533  {
534  CarlaActor->GetActorId(),
535  Velocity,
536  AngularVelocity
537  };
538  AddKinematics(Kinematic);
539 }
540 
542 {
543  check(CarlaActor != nullptr);
544 
545  const auto &Box = CarlaActor->GetActorInfo()->BoundingBox;
547  {
548  CarlaActor->GetActorId(),
549  {Box.Origin, Box.Extent}
550  };
551 
552  AddBoundingBox(BoundingBox);
553 }
554 
556 {
557  TArray<UBoxComponent*> Triggers = TrafficSign.GetTriggerVolumes();
558  if(!Triggers.Num())
559  {
560  return;
561  }
562  UBoxComponent* Trigger = Triggers.Top();
563  auto VolumeOrigin = Trigger->GetComponentLocation();
564  auto VolumeExtent = Trigger->GetScaledBoxExtent();
566  {
568  {VolumeOrigin, VolumeExtent}
569  };
570  TriggerVolumes.Add(TriggerVolume);
571 }
572 
574 {
576  Control.DatabaseId = Episode->GetActorRegistry().FindCarlaActor(&Vehicle)->GetActorId();
578  PhysicsControls.Add(Control);
579 }
580 
582 {
583  auto DatabaseId = Episode->GetActorRegistry().FindCarlaActor(&TrafficLight)->GetActorId();
585  DatabaseId,
586  TrafficLight.GetGreenTime(),
587  TrafficLight.GetYellowTime(),
588  TrafficLight.GetRedTime()
589  };
591 }
592 
594 {
595  Positions.Add(Position);
596 }
597 
599 {
600  EventsAdd.Add(std::move(Event));
601 }
602 
604 {
605  EventsDel.Add(std::move(Event));
606 }
607 
609 {
610  EventsParent.Add(std::move(Event));
611 }
612 
613 void FFrameData::AddCollision(AActor *Actor1, AActor *Actor2)
614 {
616 
617  // // some inits
618  // Collision.Id = NextCollisionId++;
619  // Collision.IsActor1Hero = false;
620  // Collision.IsActor2Hero = false;
621 
622  // // check actor 1
623  // FCarlaActor *FoundActor1 = Episode->GetActorRegistry().FindCarlaActor(Actor1);
624  // if (FoundActor1 != nullptr) {
625  // if (FoundActor1->GetActorInfo() != nullptr)
626  // {
627  // auto Role = FoundActor1->GetActorInfo()->Description.Variations.Find("role_name");
628  // if (Role != nullptr)
629  // Collision.IsActor1Hero = (Role->Value == "hero");
630  // }
631  // Collision.DatabaseId1 = FoundActor1->GetActorId();
632  // }
633  // else {
634  // Collision.DatabaseId1 = uint32_t(-1); // actor1 is not a registered Carla actor
635  // }
636 
637  // // check actor 2
638  // FCarlaActor *FoundActor2 = Episode->GetActorRegistry().FindCarlaActor(Actor2);
639  // if (FoundActor2 != nullptr) {
640  // if (FoundActor2->GetActorInfo() != nullptr)
641  // {
642  // auto Role = FoundActor2->GetActorInfo()->Description.Variations.Find("role_name");
643  // if (Role != nullptr)
644  // Collision.IsActor2Hero = (Role->Value == "hero");
645  // }
646  // Collision.DatabaseId2 = FoundActor2->GetActorId();
647  // }
648  // else {
649  // Collision.DatabaseId2 = uint32_t(-1); // actor2 is not a registered Carla actor
650  // }
651 
652  Collisions.Add(std::move(Collision));
653 }
654 
656 {
657  States.Add(State);
658 }
659 
661 {
662  Vehicles.Add(Vehicle);
663 }
664 
666 {
667  Wheels.Add(VehicleWheels);
668 }
669 
671 {
672  Bikers.Add(Biker);
673 }
674 
676 {
677  Walkers.Add(Walker);
678 }
679 
681 {
682  LightVehicles.Add(LightVehicle);
683 }
684 
685 void FFrameData::AddEventLightSceneChanged(const UCarlaLight* Light)
686 {
687  CarlaRecorderLightScene LightScene =
688  {
689  Light->GetId(),
690  Light->GetLightIntensity(),
691  Light->GetLightColor(),
692  Light->GetLightOn(),
693  static_cast<uint8>(Light->GetLightType())
694  };
695 
696  LightScenes.Add(LightScene);
697 }
698 
700 {
701  Kinematics.Add(ActorKinematics);
702 }
703 
705 {
706  BoundingBoxes.Add(ActorBoundingBox);
707 }
708 
710 {
712 }
713 
714 // create or reuse an actor for replaying
715 std::pair<int, FCarlaActor*> FFrameData::CreateOrReuseActor(
716  FVector &Location,
717  FVector &Rotation,
718  FActorDescription &ActorDesc,
719  uint32_t DesiredId,
720  bool SpawnSensors,
721  std::unordered_map<uint32_t, uint32_t>& MappedId)
722 {
723  check(Episode != nullptr);
724 
725  // check type of actor we need
726  if (ActorDesc.Id.StartsWith("traffic."))
727  {
728  FCarlaActor* CarlaActor = FindTrafficLightAt(Location);
729  if (CarlaActor != nullptr)
730  {
731  // reuse that actor
732  UE_LOG(LogCarla, Log, TEXT("TrafficLight found"));
733  return std::pair<int, FCarlaActor*>(2, CarlaActor);
734  }
735  else
736  {
737  // actor not found
738  UE_LOG(LogCarla, Log, TEXT("TrafficLight not found"));
739  return std::pair<int, FCarlaActor*>(0, nullptr);
740  }
741  }
742  else if (SpawnSensors || !ActorDesc.Id.StartsWith("sensor."))
743  {
744  // check if an actor of that type already exist with same id
745  if (Episode->GetActorRegistry().Contains(DesiredId))
746  {
747  auto* CarlaActor = Episode->FindCarlaActor(DesiredId);
748  const FActorDescription *desc = &CarlaActor->GetActorInfo()->Description;
749  if (desc->Id == ActorDesc.Id)
750  {
751  // we don't need to create, actor of same type already exist
752  // relocate
753  FRotator Rot = FRotator::MakeFromEuler(Rotation);
754  FTransform Trans2(Rot, Location, FVector(1, 1, 1));
755  CarlaActor->SetActorGlobalTransform(Trans2);
756  return std::pair<int, FCarlaActor*>(2, CarlaActor);
757  }
758  }
759  else if (MappedId.find(DesiredId) != MappedId.end() && Episode->GetActorRegistry().Contains(MappedId[DesiredId]))
760  {
761  auto* CarlaActor = Episode->FindCarlaActor(MappedId[DesiredId]);
762  const FActorDescription *desc = &CarlaActor->GetActorInfo()->Description;
763  if (desc->Id == ActorDesc.Id)
764  {
765  // we don't need to create, actor of same type already exist
766  // relocate
767  FRotator Rot = FRotator::MakeFromEuler(Rotation);
768  FTransform Trans2(Rot, Location, FVector(1, 1, 1));
769  CarlaActor->SetActorGlobalTransform(Trans2);
770  return std::pair<int, FCarlaActor*>(2, CarlaActor);
771  }
772  }
773  // create new actor
774  // create the transform
775  FRotator Rot = FRotator::MakeFromEuler(Rotation);
776  FTransform Trans(Rot, FVector(0, 0, 100000), FVector(1, 1, 1));
777  // create as new actor
778  TPair<EActorSpawnResultStatus, FCarlaActor*> Result = Episode->SpawnActorWithInfo(Trans, ActorDesc, DesiredId);
779  if (Result.Key == EActorSpawnResultStatus::Success)
780  {
781  // relocate
782  FTransform Trans2(Rot, Location, FVector(1, 1, 1));
783  Result.Value->SetActorGlobalTransform(Trans2);
784  ALargeMapManager * LargeMapManager = UCarlaStatics::GetLargeMapManager(Episode->GetWorld());
785  if (LargeMapManager)
786  {
787  LargeMapManager->OnActorSpawned(*Result.Value);
788  }
789  return std::pair<int, FCarlaActor*>(1, Result.Value);
790  }
791  else
792  {
793  UE_LOG(LogCarla, Log, TEXT("Actor could't be created"));
794  return std::pair<int, FCarlaActor*>(0, Result.Value);
795  }
796  }
797  else
798  {
799  // actor ignored
800  return std::pair<int, FCarlaActor*>(0, nullptr);
801  }
802 }
803 
804 // replay event for creating actor
805 std::pair<int, uint32_t> FFrameData::ProcessReplayerEventAdd(
806  FVector Location,
807  FVector Rotation,
808  CarlaRecorderActorDescription Description,
809  uint32_t DesiredId,
810  bool bIgnoreHero,
811  bool ReplaySensors,
812  std::unordered_map<uint32_t, uint32_t>& MappedId)
813 {
814  check(Episode != nullptr);
815  FActorDescription ActorDesc;
816  bool IsHero = false;
817 
818  // prepare actor description
819  ActorDesc.UId = Description.UId;
820  ActorDesc.Id = Description.Id;
821  for (const auto &Item : Description.Attributes)
822  {
823  FActorAttribute Attr;
824  Attr.Type = static_cast<EActorAttributeType>(Item.Type);
825  Attr.Id = Item.Id;
826  Attr.Value = Item.Value;
827  ActorDesc.Variations.Add(Attr.Id, std::move(Attr));
828  // check for hero
829  if (Item.Id == "role_name" && Item.Value == "hero")
830  IsHero = true;
831  }
832 
833  auto result = CreateOrReuseActor(
834  Location,
835  Rotation,
836  ActorDesc,
837  DesiredId,
838  ReplaySensors,
839  MappedId);
840 
841  if (result.first != 0)
842  {
843  // disable physics and autopilot on vehicles
844  if (result.second->GetActorType() == FCarlaActor::ActorType::Vehicle)
845  {
846  // ignore hero ?
847  if (!(bIgnoreHero && IsHero))
848  {
849  // disable physics
850  SetActorSimulatePhysics(result.second, false);
851  // disable autopilot
852  // SetActorAutopilot(result.second, false, false);
853  }
854  else
855  {
856  // reenable physics just in case
857  SetActorSimulatePhysics(result.second, true);
858  }
859  }
860  return std::make_pair(result.first, result.second->GetActorId());
861  }
862  return std::make_pair(result.first, 0);
863 }
864 
865 // replay event for removing actor
866 bool FFrameData::ProcessReplayerEventDel(uint32_t DatabaseId)
867 {
868  check(Episode != nullptr);
869  FCarlaActor* CarlaActor = Episode->FindCarlaActor(DatabaseId);
870  if (CarlaActor == nullptr)
871  {
872  UE_LOG(LogCarla, Log, TEXT("Actor %d not found to destroy"), DatabaseId);
873  return false;
874  }
875  Episode->DestroyActor(CarlaActor->GetActorId());
876  return true;
877 }
878 
879 // replay event for parenting actors
880 bool FFrameData::ProcessReplayerEventParent(uint32_t ChildId, uint32_t ParentId)
881 {
882  check(Episode != nullptr);
883  FCarlaActor * Child = Episode->FindCarlaActor(ChildId);
884  FCarlaActor * Parent = Episode->FindCarlaActor(ParentId);
885  if(!Child)
886  {
887  UE_LOG(LogCarla, Log, TEXT("Parenting Child actors not found"));
888  return false;
889  }
890  if(!Parent)
891  {
892  UE_LOG(LogCarla, Log, TEXT("Parenting Parent actors not found"));
893  return false;
894  }
895  Child->SetParent(ParentId);
897  Parent->AddChildren(Child->GetActorId());
898  if(!Parent->IsDormant())
899  {
900  if(!Child->IsDormant())
901  {
903  Child->GetActor(),
904  Parent->GetActor(),
906  }
907  }
908  else
909  {
911  }
912  return true;
913 }
914 
915 // reposition actors
917 {
918  check(Episode != nullptr);
919  FCarlaActor* CarlaActor = Episode->FindCarlaActor(Pos1.DatabaseId);
920  FVector Location;
921  FRotator Rotation;
922  if(CarlaActor)
923  {
924  // check to assign first position or interpolate between both
925  if (Per == 0.0)
926  {
927  // assign position 1
928  Location = FVector(Pos1.Location);
929  Rotation = FRotator::MakeFromEuler(Pos1.Rotation);
930  }
931  else
932  {
933  // interpolate positions
934  Location = FMath::Lerp(FVector(Pos1.Location), FVector(Pos2.Location), Per);
935  Rotation = FMath::Lerp(FRotator::MakeFromEuler(Pos1.Rotation), FRotator::MakeFromEuler(Pos2.Rotation), Per);
936  }
937  // set new transform
938  FTransform Trans(Rotation, Location, FVector(1, 1, 1));
939  CarlaActor->SetActorGlobalTransform(Trans, ETeleportType::None);
940  return true;
941  }
942  return false;
943 }
944 
945 // reposition the camera
946 bool FFrameData::SetCameraPosition(uint32_t Id, FVector Offset, FQuat Rotation)
947 {
948  check(Episode != nullptr);
949 
950  // get the actor to follow
951  FCarlaActor* CarlaActor = Episode->FindCarlaActor(Id);
952  if (!CarlaActor)
953  return false;
954  // get specator pawn
955  APawn *Spectator = Episode->GetSpectatorPawn();
956  if (!Spectator)
957  return false;
958 
959  FCarlaActor* CarlaSpectator = Episode->FindCarlaActor(Spectator);
960  if (!CarlaSpectator)
961  return false;
962 
963  FTransform ActorTransform = CarlaActor->GetActorGlobalTransform();
964  // set the new position
965  FQuat ActorRot = ActorTransform.GetRotation();
966  FVector Pos = ActorTransform.GetTranslation() + (ActorRot.RotateVector(Offset));
967  CarlaSpectator->SetActorGlobalTransform(FTransform(ActorRot * Rotation, Pos, FVector(1,1,1)));
968 
969  return true;
970 }
971 
973 {
974  check(Episode != nullptr);
975  FCarlaActor* CarlaActor = Episode->FindCarlaActor(State.DatabaseId);
976  if(CarlaActor)
977  {
978  CarlaActor->SetTrafficLightState(static_cast<ETrafficLightState>(State.State));
979  UTrafficLightController* Controller = CarlaActor->GetTrafficLightController();
980  if(Controller)
981  {
982  Controller->SetElapsedTime(State.ElapsedTime);
983  ATrafficLightGroup* Group = Controller->GetGroup();
984  if (Group)
985  {
986  Group->SetFrozenGroup(State.IsFrozen);
987  }
988  }
989  return true;
990  }
991  return false;
992 }
993 
994 // set the animation for Vehicles
996 {
997  check(Episode != nullptr);
998  FCarlaActor *CarlaActor = Episode->FindCarlaActor(Vehicle.DatabaseId);
999  if (CarlaActor)
1000  {
1001  FVehicleControl Control;
1002  Control.Throttle = Vehicle.Throttle;
1003  Control.Steer = Vehicle.Steering;
1004  Control.Brake = Vehicle.Brake;
1005  Control.bHandBrake = Vehicle.bHandbrake;
1006  Control.bReverse = (Vehicle.Gear < 0);
1007  Control.Gear = Vehicle.Gear;
1008  Control.bManualGearShift = false;
1009  CarlaActor->ApplyControlToVehicle(Control, EVehicleInputPriority::User);
1010  }
1011 }
1012 
1014 {
1015  check(Episode != nullptr)
1016  FCarlaActor *CarlaActor = Episode->FindCarlaActor(VehicleAnimWheels.DatabaseId);
1017  if (CarlaActor == nullptr)
1018  return;
1019  if (CarlaActor->GetActorType() != FCarlaActor::ActorType::Vehicle)
1020  return;
1021  ACarlaWheeledVehicle* CarlaVehicle = Cast<ACarlaWheeledVehicle>(CarlaActor->GetActor());
1022  check(CarlaVehicle != nullptr)
1023  USkeletalMeshComponent* SkeletalMesh = CarlaVehicle->GetMesh();
1024  check(SkeletalMesh != nullptr)
1025  UVehicleAnimInstance* VehicleAnim = Cast<UVehicleAnimInstance>(SkeletalMesh->GetAnimInstance());
1026  check(VehicleAnim != nullptr)
1027 
1028  for (uint32_t i = 0; i < VehicleAnimWheels.WheelValues.size(); ++i)
1029  {
1030  const WheelInfo& Element = VehicleAnimWheels.WheelValues[i];
1031  VehicleAnim->SetWheelRotYaw(static_cast<uint8>(Element.Location), Element.SteeringAngle);
1032  VehicleAnim->SetWheelPitchAngle(static_cast<uint8>(Element.Location), Element.TireRotation);
1033  }
1034 }
1035 
1036 // set the lights for vehicles
1038 {
1039  check(Episode != nullptr);
1040  FCarlaActor * CarlaActor = Episode->FindCarlaActor(LightVehicle.DatabaseId);
1041  if (CarlaActor)
1042  {
1043  carla::rpc::VehicleLightState LightState(LightVehicle.State);
1044  CarlaActor->SetVehicleLightState(FVehicleLightState(LightState));
1045  }
1046 }
1047 
1049 {
1050  check(Episode != nullptr);
1051  UWorld* World = Episode->GetWorld();
1052  if(World)
1053  {
1054  UCarlaLightSubsystem* CarlaLightSubsystem = World->GetSubsystem<UCarlaLightSubsystem>();
1055  if (!CarlaLightSubsystem)
1056  {
1057  return;
1058  }
1059  auto* CarlaLight = CarlaLightSubsystem->GetLight(LightScene.LightId);
1060  if (CarlaLight)
1061  {
1062  CarlaLight->SetLightIntensity(LightScene.Intensity);
1063  CarlaLight->SetLightColor(LightScene.Color);
1064  CarlaLight->SetLightOn(LightScene.bOn);
1065  CarlaLight->SetLightType(static_cast<ELightType>(LightScene.Type));
1066  }
1067  }
1068 }
1069 
1070 // set the animation for walkers
1072 {
1073  SetWalkerSpeed(Walker.DatabaseId, Walker.Speed);
1074 }
1075 
1077 {
1078  check(Episode != nullptr);
1079  FCarlaActor * CarlaActor = Episode->FindCarlaActor(Biker.DatabaseId);
1080  if (CarlaActor == nullptr)
1081  return;
1082  ACarlaWheeledVehicle* CarlaVehicle = Cast<ACarlaWheeledVehicle>(CarlaActor->GetActor());
1083  check(CarlaVehicle != nullptr)
1084  CarlaVehicle->SetSpeedAnim(Biker.ForwardSpeed);
1085  CarlaVehicle->SetRotationAnim(Biker.EngineRotation);
1086 }
1087 
1088 
1089 // replay finish
1090 bool FFrameData::ProcessReplayerFinish(bool bApplyAutopilot, bool bIgnoreHero, std::unordered_map<uint32_t, bool> &IsHero)
1091 {
1092  // set autopilot and physics to all AI vehicles
1093  const FActorRegistry& Registry = Episode->GetActorRegistry();
1094  for (auto& It : Registry)
1095  {
1096  FCarlaActor* CarlaActor = It.Value.Get();
1097 
1098  // enable physics only on vehicles
1099  switch (CarlaActor->GetActorType())
1100  {
1101 
1102  // vehicles
1104  // check for hero
1105  if (!(bIgnoreHero && IsHero[CarlaActor->GetActorId()]))
1106  {
1107  // stop all vehicles
1108  SetActorSimulatePhysics(CarlaActor, true);
1109  SetActorVelocity(CarlaActor, FVector(0, 0, 0));
1110  FVehicleControl Control;
1111  Control.Throttle = 0.0f;
1112  Control.Steer = 0.0f;
1113  Control.Brake = 0.0f;
1114  Control.bHandBrake = false;
1115  Control.bReverse = false;
1116  Control.Gear = 1;
1117  Control.bManualGearShift = false;
1118  CarlaActor->ApplyControlToVehicle(Control, EVehicleInputPriority::User);
1119  }
1120  break;
1121 
1122  // walkers
1124  // stop walker
1125  SetWalkerSpeed(CarlaActor->GetActorId(), 0.0f);
1126  break;
1127  }
1128  }
1129  return true;
1130 }
1131 
1132 void FFrameData::SetActorVelocity(FCarlaActor *CarlaActor, FVector Velocity)
1133 {
1134  if (!CarlaActor)
1135  {
1136  return;
1137  }
1138  CarlaActor->SetActorTargetVelocity(Velocity);
1139 }
1140 
1141 // set the animation speed for walkers
1142 void FFrameData::SetWalkerSpeed(uint32_t ActorId, float Speed)
1143 {
1144  check(Episode != nullptr);
1145  FCarlaActor * CarlaActor = Episode->FindCarlaActor(ActorId);
1146  if (!CarlaActor)
1147  {
1148  return;
1149  }
1150  FWalkerControl Control;
1151  Control.Speed = Speed;
1152  CarlaActor->ApplyControlToWalker(Control);
1153 }
1154 
1155 // enable / disable physics for an actor
1156 bool FFrameData::SetActorSimulatePhysics(FCarlaActor* CarlaActor, bool bEnabled)
1157 {
1158  if (!CarlaActor)
1159  {
1160  return false;
1161  }
1162  ECarlaServerResponse Response =
1163  CarlaActor->SetActorSimulatePhysics(bEnabled);
1164  if (Response != ECarlaServerResponse::Success)
1165  {
1166  return false;
1167  }
1168  return true;
1169 }
1170 
1172 {
1174 }
1175 
1177 {
1178  check(Episode != nullptr);
1179  auto World = Episode->GetWorld();
1180  check(World != nullptr);
1181 
1182  // get its position (truncated as int's)
1183  int x = static_cast<int>(Location.X);
1184  int y = static_cast<int>(Location.Y);
1185  int z = static_cast<int>(Location.Z);
1186 
1187  const FActorRegistry &Registry = Episode->GetActorRegistry();
1188  // through all actors in registry
1189  for (auto It = Registry.begin(); It != Registry.end(); ++It)
1190  {
1191  FCarlaActor* CarlaActor = It.Value().Get();
1193  {
1194  FVector vec = CarlaActor->GetActorGlobalLocation();
1195  int x2 = static_cast<int>(vec.X);
1196  int y2 = static_cast<int>(vec.Y);
1197  int z2 = static_cast<int>(vec.Z);
1198  if ((x2 == x) && (y2 == y) && (z2 == z))
1199  {
1200  // actor found
1201  return CarlaActor;
1202  }
1203  }
1204  }
1205  // actor not found
1206  return nullptr;
1207 }
1208 
1210 {
1211  // registring all existing actors in first frame
1212  FActorRegistry Registry = Episode->GetActorRegistry();
1213  for (auto& It : Registry)
1214  {
1215  const FCarlaActor* CarlaActor = It.Value.Get();
1216  if (CarlaActor != nullptr)
1217  {
1218  // create event
1220  CarlaActor->GetActorId(),
1221  static_cast<uint8_t>(CarlaActor->GetActorType()),
1222  CarlaActor->GetActorGlobalTransform(),
1223  CarlaActor->GetActorInfo()->Description,
1224  false);
1225  }
1226  }
1227 }
UCarlaLight * GetLight(int Id)
FCarlaActor * FindCarlaActor(FCarlaActor::IdType ActorId)
Find a Carla actor by id.
Definition: CarlaEpisode.h:172
bool ProcessReplayerEventParent(uint32_t ChildId, uint32_t ParentId)
Definition: FrameData.cpp:880
void AddExistingActors(void)
Definition: FrameData.cpp:1209
void Add(const CarlaRecorderAnimVehicle &InObj)
virtual ECarlaServerResponse SetVehicleLightState(const FVehicleLightState &)
Definition: CarlaActor.h:273
void Read(std::istream &InFile)
void Read(std::istream &InFile)
auto end() const noexcept
void AddVehicleAnimation(FCarlaActor *CarlaActor)
Definition: FrameData.cpp:393
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderAnimBiker &InObj)
A registry of all the Carla actors.
Definition: ActorRegistry.h:20
void SetSpeedAnim(float Speed)
void Add(const CarlaRecorderPosition &InObj)
bool DestroyActor(AActor *Actor)
Definition: CarlaEpisode.h:251
CarlaRecorderPhysicsControls PhysicsControls
Definition: FrameData.h:62
void Write(std::ostream &OutFile)
FVehiclePhysicsControl GetVehiclePhysicsControl() const
TArray< UBoxComponent * > GetTriggerVolumes() const
FVector GetActorAngularVelocity() const
Definition: CarlaActor.cpp:372
const std::vector< CarlaRecorderEventAdd > & GetEvents()
void ProcessReplayerAnimVehicleWheels(CarlaRecorderAnimWheels Vehicle)
Definition: FrameData.cpp:1013
virtual ETrafficLightState GetTrafficLightState() const
Definition: CarlaActor.h:353
void AddTriggerVolume(const ATrafficSignBase &TrafficSign)
Definition: FrameData.cpp:555
virtual ECarlaServerResponse GetWalkerControl(FWalkerControl &)
Definition: CarlaActor.h:393
void Write(std::ostream &OutFile)
const std::vector< CarlaRecorderEventDel > & GetEvents()
void SetElapsedTime(float InElapsedTime)
EActorAttributeType
List of valid types for actor attributes.
AActor * GetActor()
Definition: CarlaActor.h:90
void Add(const CarlaRecorderCollision &Collision)
const std::vector< CarlaRecorderLightScene > & GetLights()
const std::vector< CarlaRecorderAnimWalker > & GetWalkers()
EAttachmentType
Definition: ActorAttacher.h:20
void AddAnimWalker(const CarlaRecorderAnimWalker &Walker)
Definition: FrameData.cpp:675
void Read(std::istream &InFile)
void Add(const CarlaRecorderAnimWheels &InObj)
void AddEventLightSceneChanged(const UCarlaLight *Light)
Definition: FrameData.cpp:685
void Add(const CarlaRecorderLightScene &InObj)
void Add(const CarlaRecorderTrafficLightTime &InObj)
auto begin() const noexcept
CarlaRecorderTrafficLightTimes TrafficLightTimes
Definition: FrameData.h:63
void AddWalkerAnimation(FCarlaActor *CarlaActor)
Definition: FrameData.cpp:474
Class which implements the state changing of traffic lights.
CarlaRecorderAnimBikers Bikers
Definition: FrameData.h:55
void AddAnimVehicle(const CarlaRecorderAnimVehicle &Vehicle)
Definition: FrameData.cpp:660
float GetGreenTime() const
void Add(const CarlaRecorderEventAdd &Event)
CarlaRecorderActorBoundingBoxes BoundingBoxes
Definition: FrameData.h:59
void AddBoundingBox(const CarlaRecorderActorBoundingBox &ActorBoundingBox)
Definition: FrameData.cpp:704
void Add(const CarlaRecorderStateTrafficLight &State)
void PutActorToSleep(carla::rpc::ActorId ActorId)
Definition: CarlaEpisode.h:279
CarlaRecorderActorsKinematics Kinematics
Definition: FrameData.h:58
const std::vector< CarlaRecorderAnimBiker > & GetBikers()
void OnActorSpawned(const FCarlaActor &CarlaActor)
virtual ECarlaServerResponse ApplyControlToVehicle(const FVehicleControl &, const EVehicleInputPriority &)
Definition: CarlaActor.h:288
void ProcessReplayerAnimWalker(CarlaRecorderAnimWalker Walker)
Definition: FrameData.cpp:1071
void AddVehicleLight(FCarlaActor *CarlaActor)
Definition: FrameData.cpp:512
EVehicleWheelLocation Location
CarlaRecorderAnimVehicleWheels Wheels
Definition: FrameData.h:53
void AddAnimVehicleWheels(const CarlaRecorderAnimWheels &VehicleWheels)
Definition: FrameData.cpp:665
void Write(std::ostream &OutFile)
const std::vector< CarlaRecorderPosition > & GetPositions()
void Write(std::ostream &OutStream)
Definition: FrameData.cpp:207
bg::model::box< Point3D > Box
Definition: InMemoryMap.h:52
virtual ECarlaServerResponse SetTrafficLightState(const ETrafficLightState &)
Definition: CarlaActor.h:348
static void ResetFrameCounter(uint64_t Value=0)
Definition: CarlaEngine.h:75
void AddActorPosition(FCarlaActor *CarlaActor)
Definition: FrameData.cpp:379
void AddVehicleWheelsAnimation(FCarlaActor *CarlaActor)
Definition: FrameData.cpp:416
static uint64_t GetFrameCounter()
Definition: CarlaEngine.h:64
void Add(const CarlaRecorderPhysicsControl &InObj)
void Add(const CarlaRecorderLightVehicle &InObj)
geom::Location Location
Definition: rpc/Location.h:14
void SetFrameCounter()
Definition: FrameData.cpp:1171
void Write(std::ostream &OutFile)
CarlaRecorderActorTriggerVolumes TriggerVolumes
Definition: FrameData.h:60
const FActorRegistry & GetActorRegistry() const
Definition: CarlaEpisode.h:154
TMap< FString, FActorAttribute > Variations
User selected variations of the actor.
ECarlaServerResponse
UCarlaEpisode * Episode
Definition: FrameData.h:183
void ProcessReplayerLightVehicle(CarlaRecorderLightVehicle LightVehicle)
Definition: FrameData.cpp:1037
void Add(const CarlaRecorderActorBoundingBox &InObj)
void Add(const CarlaRecorderKinematics &InObj)
A simulation episode.
Definition: CarlaEpisode.h:37
void SetWalkerSpeed(uint32_t ActorId, float Speed)
Definition: FrameData.cpp:1142
void AddPosition(const CarlaRecorderPosition &Position)
Definition: FrameData.cpp:593
void Write(std::ostream &OutFile)
CarlaRecorderEventsDel EventsDel
Definition: FrameData.h:47
void AddLightVehicle(const CarlaRecorderLightVehicle &LightVehicle)
Definition: FrameData.cpp:680
TPair< EActorSpawnResultStatus, FCarlaActor * > SpawnActorWithInfo(const FTransform &Transform, FActorDescription thisActorDescription, FCarlaActor::IdType DesiredId=0)
Spawns an actor based on ActorDescription at Transform.
bool SetActorSimulatePhysics(FCarlaActor *CarlaActor, bool bEnabled)
Definition: FrameData.cpp:1156
void Write(std::ostream &OutFile)
void SetAttachmentType(carla::rpc::AttachmentType InAttachmentType)
Definition: CarlaActor.h:140
CarlaRecorderLightScenes LightScenes
Definition: FrameData.h:57
FCarlaActor * FindTrafficLightAt(FVector Location)
Definition: FrameData.cpp:1176
void AddActorBoundingBox(FCarlaActor *CarlaActor)
Definition: FrameData.cpp:541
const std::vector< CarlaRecorderStateTrafficLight > & GetStates()
void GetFrameData(UCarlaEpisode *ThisEpisode, bool bAdditionalData=false, bool bIncludeActorsAgain=false)
Definition: FrameData.cpp:23
virtual ECarlaServerResponse ApplyControlToWalker(const FWalkerControl &)
Definition: CarlaActor.h:388
std::vector< CarlaRecorderActorAttribute > Attributes
void ProcessReplayerAnimBiker(CarlaRecorderAnimBiker Biker)
Definition: FrameData.cpp:1076
bool Contains(uint32 Id) const
Definition: ActorRegistry.h:64
CarlaRecorderEventsAdd EventsAdd
Definition: FrameData.h:46
bool ProcessReplayerEventDel(uint32_t DatabaseId)
Definition: FrameData.cpp:866
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)
Definition: FrameData.cpp:805
void Read(std::istream &InFile)
void Read(std::istream &InFile)
float GetWheelSteerAngle(EVehicleWheelLocation WheelLocation)
A description of a Carla Actor with all its variation.
void ProcessReplayerAnimVehicle(CarlaRecorderAnimVehicle Vehicle)
Definition: FrameData.cpp:995
FVector GetActorVelocity() const
Definition: CarlaActor.cpp:360
FActorDescription Description
Definition: ActorInfo.h:26
void Write(std::ostream &OutFile)
CarlaRecorderLightVehicles LightVehicles
Definition: FrameData.h:56
uint32_t ActorId
Definition: ActorId.h:14
void AddKinematics(const CarlaRecorderKinematics &ActorKinematics)
Definition: FrameData.cpp:699
const FActorInfo * GetActorInfo() const
Definition: CarlaActor.h:100
FBoundingBox BoundingBox
Definition: ActorInfo.h:30
bool IsPendingKill() const
Definition: CarlaActor.h:75
CarlaRecorderPositions Positions
Definition: FrameData.h:50
void AddTrafficLightTime(const ATrafficLightBase &TrafficLight)
Definition: FrameData.cpp:581
void Clear()
Definition: FrameData.cpp:185
float GetRedTime() const
bool ProcessReplayerPosition(CarlaRecorderPosition Pos1, CarlaRecorderPosition Pos2, double Per, double DeltaTime)
Definition: FrameData.cpp:916
float GetYellowTime() const
ECarlaServerResponse SetActorTargetVelocity(const FVector &Velocity)
Definition: CarlaActor.cpp:390
void AddState(const CarlaRecorderStateTrafficLight &State)
Definition: FrameData.cpp:655
void AddCollision(AActor *Actor1, AActor *Actor2)
Definition: FrameData.cpp:613
CarlaRecorderEventsParent EventsParent
Definition: FrameData.h:48
const std::vector< CarlaRecorderAnimVehicle > & GetVehicles()
bool ProcessReplayerStateTrafficLight(CarlaRecorderStateTrafficLight State)
Definition: FrameData.cpp:972
CarlaRecorderAnimWalkers Walkers
Definition: FrameData.h:54
geom::Rotation Rotation
Definition: rpc/Transform.h:14
CarlaRecorderCollisions Collisions
Definition: FrameData.h:49
APawn * GetSpectatorPawn() const
Definition: CarlaEpisode.h:143
void AttachActors(AActor *Child, AActor *Parent, EAttachmentType InAttachmentType=EAttachmentType::Rigid)
Attach Child to Parent.
void AddChildren(IdType ChildId)
Definition: CarlaActor.h:125
void AddActorKinematics(FCarlaActor *CarlaActor)
Definition: FrameData.cpp:524
void AddAnimBiker(const CarlaRecorderAnimBiker &Biker)
Definition: FrameData.cpp:670
virtual UTrafficLightController * GetTrafficLightController()
Definition: CarlaActor.h:358
void AddTrafficLightState(FCarlaActor *CarlaActor)
Definition: FrameData.cpp:490
bool ProcessReplayerFinish(bool bApplyAutopilot, bool bIgnoreHero, std::unordered_map< uint32_t, bool > &IsHero)
Definition: FrameData.cpp:1090
static ALargeMapManager * GetLargeMapManager(const UObject *WorldContextObject)
Definition: CarlaStatics.h:100
void AddPhysicsControl(const ACarlaWheeledVehicle &Vehicle)
Definition: FrameData.cpp:573
void Read(std::istream &InFile)
FTransform GetActorGlobalTransform() const
Definition: CarlaActor.cpp:199
void Read(std::istream &InStream)
Definition: FrameData.cpp:224
uint32 UId
UId of the definition in which this description was based.
void SetFrozenGroup(bool InFreeze)
const std::vector< CarlaRecorderLightVehicle > & GetLightVehicles()
bool IsDormant() const
Definition: CarlaActor.h:70
CarlaRecorderStates States
Definition: FrameData.h:51
virtual ECarlaServerResponse SetActorSimulatePhysics(bool bEnabled)
Definition: CarlaActor.cpp:560
void Read(std::istream &InFile)
virtual ECarlaServerResponse GetVehicleLightState(FVehicleLightState &)
Definition: CarlaActor.h:253
void SetParent(IdType InParentId)
Definition: CarlaActor.h:115
virtual ECarlaServerResponse GetVehicleControl(FVehicleControl &)
Definition: CarlaActor.h:300
IdType GetActorId() const
Definition: CarlaActor.h:80
void PlayFrameData(UCarlaEpisode *ThisEpisode, std::unordered_map< uint32_t, uint32_t > &MappedId)
Definition: FrameData.cpp:78
void Add(const CarlaRecorderEventParent &Event)
void Add(const CarlaRecorderAnimWalker &InObj)
FCarlaActor * FindCarlaActor(IdType Id)
Definition: ActorRegistry.h:69
void SetActorVelocity(FCarlaActor *CarlaActor, FVector Velocity)
Definition: FrameData.cpp:1132
void SetRotationAnim(float Rotation)
void ProcessReplayerLightScene(CarlaRecorderLightScene LightScene)
Definition: FrameData.cpp:1048
ATrafficLightGroup * GetGroup()
void Read(std::istream &InFile)
const std::vector< CarlaRecorderAnimWheels > & GetVehicleWheels()
std::vector< WheelInfo > WheelValues
void Read(std::istream &InFile)
void CreateRecorderEventAdd(uint32_t DatabaseId, uint8_t Type, const FTransform &Transform, FActorDescription ActorDescription, bool bAddOtherRelatedInfo=true)
Definition: FrameData.cpp:303
void Add(const CarlaRecorderActorBoundingBox &InObj)
void Add(const CarlaRecorderEventDel &Event)
flag_type light_state
Lights state flag, all turned off by default.
void Read(std::istream &InFile)
Base class for CARLA wheeled vehicles.
Maps a controller from OpenDrive.
void Read(std::istream &InFile)
Defines the physical appearance of a vehicle whitch is obtained by the sensors.
CarlaRecorderAnimVehicles Vehicles
Definition: FrameData.h:52
void Write(std::ostream &OutFile)
An actor attribute, may be an intrinsic (non-modifiable) attribute of the actor or an user-defined ac...
std::pair< int, FCarlaActor * > CreateOrReuseActor(FVector &Location, FVector &Rotation, FActorDescription &ActorDesc, uint32_t DesiredId, bool SpawnSensors, std::unordered_map< uint32_t, uint32_t > &MappedId)
Definition: FrameData.cpp:715
void GetFrameCounter()
Definition: FrameData.cpp:709
void SetActorGlobalTransform(const FTransform &Transform, ETeleportType Teleport=ETeleportType::TeleportPhysics)
Definition: CarlaActor.cpp:333
void Write(std::ostream &OutFile)
void AddEvent(const CarlaRecorderEventAdd &Event)
Definition: FrameData.cpp:598
geom::Transform Transform
Definition: rpc/Transform.h:16
FVehiclePhysicsControl VehiclePhysicsControl
CarlaRecorderFrameCounter FrameCounter
Definition: FrameData.h:64
FVector GetActorGlobalLocation() const
Definition: CarlaActor.cpp:240
ActorType GetActorType() const
Definition: CarlaActor.h:85
bool SetCameraPosition(uint32_t Id, FVector Offset, FQuat Rotation)
Definition: FrameData.cpp:946
A view over an actor and its properties.
Definition: CarlaActor.h:23
void Write(std::ostream &OutFile) const