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 
424  ACarlaWheeledVehicle* CarlaVehicle = Cast<ACarlaWheeledVehicle>(CarlaActor->GetActor());
425  if (CarlaVehicle == nullptr)
426  return;
427 
428  USkeletalMeshComponent* SkeletalMesh = CarlaVehicle->GetMesh();
429  if (SkeletalMesh == nullptr)
430  return;
431 
432  UVehicleAnimInstance* VehicleAnim = Cast<UVehicleAnimInstance>(SkeletalMesh->GetAnimInstance());
433  if (VehicleAnim == nullptr)
434  return;
435 
436  const UWheeledVehicleMovementComponent* WheeledVehicleMovementComponent = VehicleAnim->GetWheeledVehicleMovementComponent();
437  if (WheeledVehicleMovementComponent == nullptr)
438  return;
439 
441  Record.DatabaseId = CarlaActor->GetActorId();
442  Record.WheelValues.reserve(WheeledVehicleMovementComponent->Wheels.Num());
443 
444  uint8 i = 0;
445  for (auto Wheel : WheeledVehicleMovementComponent->Wheels)
446  {
447  WheelInfo Info;
448  Info.Location = static_cast<EVehicleWheelLocation>(i);
449  Info.SteeringAngle = CarlaVehicle->GetWheelSteerAngle(Info.Location);
450  Info.TireRotation = Wheel->GetRotationAngle();
451  Record.WheelValues.push_back(Info);
452  ++i;
453  }
454 
455  AddAnimVehicleWheels(Record);
456 
457  if (CarlaVehicle->IsTwoWheeledVehicle())
458  {
460  {
461  CarlaActor->GetActorId(),
462  WheeledVehicleMovementComponent->GetForwardSpeed(),
463  WheeledVehicleMovementComponent->GetEngineRotationSpeed() / WheeledVehicleMovementComponent->GetEngineMaxRotationSpeed()
464  });
465  }
466 }
467 
469 {
470  check(CarlaActor != nullptr);
471 
472  if (!CarlaActor->IsPendingKill())
473  {
474  FWalkerControl Control;
475  CarlaActor->GetWalkerControl(Control);
477  {
478  CarlaActor->GetActorId(),
479  Control.Speed
480  });
481  }
482 }
483 
485 {
486  check(CarlaActor != nullptr);
487 
488  ETrafficLightState LightState = CarlaActor->GetTrafficLightState();
489  UTrafficLightController* Controller = CarlaActor->GetTrafficLightController();
490  if (Controller)
491  {
492  ATrafficLightGroup* Group = Controller->GetGroup();
493  if (Group)
494  {
496  {
497  CarlaActor->GetActorId(),
498  Group->IsFrozen(),
499  Controller->GetElapsedTime(),
500  static_cast<char>(LightState)
501  });
502  }
503  }
504 }
505 
507 {
508  check(CarlaActor != nullptr);
509 
510  FVehicleLightState LightState;
511  CarlaActor->GetVehicleLightState(LightState);
512  CarlaRecorderLightVehicle LightVehicle;
513  LightVehicle.DatabaseId = CarlaActor->GetActorId();
514  LightVehicle.State = carla::rpc::VehicleLightState(LightState).light_state;
515  AddLightVehicle(LightVehicle);
516 }
517 
519 {
520  check(CarlaActor != nullptr);
521 
522  FVector Velocity, AngularVelocity;
523  constexpr float TO_METERS = 1e-2;
524  Velocity = TO_METERS* CarlaActor->GetActorVelocity();
525  AngularVelocity = CarlaActor->GetActorAngularVelocity();
526  CarlaRecorderKinematics Kinematic =
527  {
528  CarlaActor->GetActorId(),
529  Velocity,
530  AngularVelocity
531  };
532  AddKinematics(Kinematic);
533 }
534 
536 {
537  check(CarlaActor != nullptr);
538 
539  const auto &Box = CarlaActor->GetActorInfo()->BoundingBox;
541  {
542  CarlaActor->GetActorId(),
543  {Box.Origin, Box.Extent}
544  };
545 
546  AddBoundingBox(BoundingBox);
547 }
548 
550 {
551  TArray<UBoxComponent*> Triggers = TrafficSign.GetTriggerVolumes();
552  if(!Triggers.Num())
553  {
554  return;
555  }
556  UBoxComponent* Trigger = Triggers.Top();
557  auto VolumeOrigin = Trigger->GetComponentLocation();
558  auto VolumeExtent = Trigger->GetScaledBoxExtent();
560  {
562  {VolumeOrigin, VolumeExtent}
563  };
564  TriggerVolumes.Add(TriggerVolume);
565 }
566 
568 {
570  Control.DatabaseId = Episode->GetActorRegistry().FindCarlaActor(&Vehicle)->GetActorId();
572  PhysicsControls.Add(Control);
573 }
574 
576 {
577  auto DatabaseId = Episode->GetActorRegistry().FindCarlaActor(&TrafficLight)->GetActorId();
579  DatabaseId,
580  TrafficLight.GetGreenTime(),
581  TrafficLight.GetYellowTime(),
582  TrafficLight.GetRedTime()
583  };
585 }
586 
588 {
589  Positions.Add(Position);
590 }
591 
593 {
594  EventsAdd.Add(std::move(Event));
595 }
596 
598 {
599  EventsDel.Add(std::move(Event));
600 }
601 
603 {
604  EventsParent.Add(std::move(Event));
605 }
606 
607 void FFrameData::AddCollision(AActor *Actor1, AActor *Actor2)
608 {
610 
611  // // some inits
612  // Collision.Id = NextCollisionId++;
613  // Collision.IsActor1Hero = false;
614  // Collision.IsActor2Hero = false;
615 
616  // // check actor 1
617  // FCarlaActor *FoundActor1 = Episode->GetActorRegistry().FindCarlaActor(Actor1);
618  // if (FoundActor1 != nullptr) {
619  // if (FoundActor1->GetActorInfo() != nullptr)
620  // {
621  // auto Role = FoundActor1->GetActorInfo()->Description.Variations.Find("role_name");
622  // if (Role != nullptr)
623  // Collision.IsActor1Hero = (Role->Value == "hero");
624  // }
625  // Collision.DatabaseId1 = FoundActor1->GetActorId();
626  // }
627  // else {
628  // Collision.DatabaseId1 = uint32_t(-1); // actor1 is not a registered Carla actor
629  // }
630 
631  // // check actor 2
632  // FCarlaActor *FoundActor2 = Episode->GetActorRegistry().FindCarlaActor(Actor2);
633  // if (FoundActor2 != nullptr) {
634  // if (FoundActor2->GetActorInfo() != nullptr)
635  // {
636  // auto Role = FoundActor2->GetActorInfo()->Description.Variations.Find("role_name");
637  // if (Role != nullptr)
638  // Collision.IsActor2Hero = (Role->Value == "hero");
639  // }
640  // Collision.DatabaseId2 = FoundActor2->GetActorId();
641  // }
642  // else {
643  // Collision.DatabaseId2 = uint32_t(-1); // actor2 is not a registered Carla actor
644  // }
645 
646  Collisions.Add(std::move(Collision));
647 }
648 
650 {
651  States.Add(State);
652 }
653 
655 {
656  Vehicles.Add(Vehicle);
657 }
658 
660 {
661  Wheels.Add(VehicleWheels);
662 }
663 
665 {
666  Bikers.Add(Biker);
667 }
668 
670 {
671  Walkers.Add(Walker);
672 }
673 
675 {
676  LightVehicles.Add(LightVehicle);
677 }
678 
679 void FFrameData::AddEventLightSceneChanged(const UCarlaLight* Light)
680 {
681  CarlaRecorderLightScene LightScene =
682  {
683  Light->GetId(),
684  Light->GetLightIntensity(),
685  Light->GetLightColor(),
686  Light->GetLightOn(),
687  static_cast<uint8>(Light->GetLightType())
688  };
689 
690  LightScenes.Add(LightScene);
691 }
692 
694 {
695  Kinematics.Add(ActorKinematics);
696 }
697 
699 {
700  BoundingBoxes.Add(ActorBoundingBox);
701 }
702 
704 {
706 }
707 
708 // create or reuse an actor for replaying
709 std::pair<int, FCarlaActor*> FFrameData::CreateOrReuseActor(
710  FVector &Location,
711  FVector &Rotation,
712  FActorDescription &ActorDesc,
713  uint32_t DesiredId,
714  bool SpawnSensors,
715  std::unordered_map<uint32_t, uint32_t>& MappedId)
716 {
717  check(Episode != nullptr);
718 
719  // check type of actor we need
720  if (ActorDesc.Id.StartsWith("traffic."))
721  {
722  FCarlaActor* CarlaActor = FindTrafficLightAt(Location);
723  if (CarlaActor != nullptr)
724  {
725  // reuse that actor
726  UE_LOG(LogCarla, Log, TEXT("TrafficLight found"));
727  return std::pair<int, FCarlaActor*>(2, CarlaActor);
728  }
729  else
730  {
731  // actor not found
732  UE_LOG(LogCarla, Log, TEXT("TrafficLight not found"));
733  return std::pair<int, FCarlaActor*>(0, nullptr);
734  }
735  }
736  else if (SpawnSensors || !ActorDesc.Id.StartsWith("sensor."))
737  {
738  // check if an actor of that type already exist with same id
739  if (Episode->GetActorRegistry().Contains(DesiredId))
740  {
741  auto* CarlaActor = Episode->FindCarlaActor(DesiredId);
742  const FActorDescription *desc = &CarlaActor->GetActorInfo()->Description;
743  if (desc->Id == ActorDesc.Id)
744  {
745  // we don't need to create, actor of same type already exist
746  // relocate
747  FRotator Rot = FRotator::MakeFromEuler(Rotation);
748  FTransform Trans2(Rot, Location, FVector(1, 1, 1));
749  CarlaActor->SetActorGlobalTransform(Trans2);
750  return std::pair<int, FCarlaActor*>(2, CarlaActor);
751  }
752  }
753  else if (MappedId.find(DesiredId) != MappedId.end() && Episode->GetActorRegistry().Contains(MappedId[DesiredId]))
754  {
755  auto* CarlaActor = Episode->FindCarlaActor(MappedId[DesiredId]);
756  const FActorDescription *desc = &CarlaActor->GetActorInfo()->Description;
757  if (desc->Id == ActorDesc.Id)
758  {
759  // we don't need to create, actor of same type already exist
760  // relocate
761  FRotator Rot = FRotator::MakeFromEuler(Rotation);
762  FTransform Trans2(Rot, Location, FVector(1, 1, 1));
763  CarlaActor->SetActorGlobalTransform(Trans2);
764  return std::pair<int, FCarlaActor*>(2, CarlaActor);
765  }
766  }
767  // create new actor
768  // create the transform
769  FRotator Rot = FRotator::MakeFromEuler(Rotation);
770  FTransform Trans(Rot, FVector(0, 0, 100000), FVector(1, 1, 1));
771  // create as new actor
772  TPair<EActorSpawnResultStatus, FCarlaActor*> Result = Episode->SpawnActorWithInfo(Trans, ActorDesc, DesiredId);
773  if (Result.Key == EActorSpawnResultStatus::Success)
774  {
775  // relocate
776  FTransform Trans2(Rot, Location, FVector(1, 1, 1));
777  Result.Value->SetActorGlobalTransform(Trans2);
778  ALargeMapManager * LargeMapManager = UCarlaStatics::GetLargeMapManager(Episode->GetWorld());
779  if (LargeMapManager)
780  {
781  LargeMapManager->OnActorSpawned(*Result.Value);
782  }
783  return std::pair<int, FCarlaActor*>(1, Result.Value);
784  }
785  else
786  {
787  UE_LOG(LogCarla, Log, TEXT("Actor could't be created"));
788  return std::pair<int, FCarlaActor*>(0, Result.Value);
789  }
790  }
791  else
792  {
793  // actor ignored
794  return std::pair<int, FCarlaActor*>(0, nullptr);
795  }
796 }
797 
798 // replay event for creating actor
799 std::pair<int, uint32_t> FFrameData::ProcessReplayerEventAdd(
800  FVector Location,
801  FVector Rotation,
802  CarlaRecorderActorDescription Description,
803  uint32_t DesiredId,
804  bool bIgnoreHero,
805  bool ReplaySensors,
806  std::unordered_map<uint32_t, uint32_t>& MappedId)
807 {
808  check(Episode != nullptr);
809  FActorDescription ActorDesc;
810  bool IsHero = false;
811 
812  // prepare actor description
813  ActorDesc.UId = Description.UId;
814  ActorDesc.Id = Description.Id;
815  for (const auto &Item : Description.Attributes)
816  {
817  FActorAttribute Attr;
818  Attr.Type = static_cast<EActorAttributeType>(Item.Type);
819  Attr.Id = Item.Id;
820  Attr.Value = Item.Value;
821  ActorDesc.Variations.Add(Attr.Id, std::move(Attr));
822  // check for hero
823  if (Item.Id == "role_name" && Item.Value == "hero")
824  IsHero = true;
825  }
826 
827  auto result = CreateOrReuseActor(
828  Location,
829  Rotation,
830  ActorDesc,
831  DesiredId,
832  ReplaySensors,
833  MappedId);
834 
835  if (result.first != 0)
836  {
837  // disable physics and autopilot on vehicles
838  if (result.second->GetActorType() == FCarlaActor::ActorType::Vehicle)
839  {
840  // ignore hero ?
841  if (!(bIgnoreHero && IsHero))
842  {
843  // disable physics
844  SetActorSimulatePhysics(result.second, false);
845  // disable autopilot
846  // SetActorAutopilot(result.second, false, false);
847  }
848  else
849  {
850  // reenable physics just in case
851  SetActorSimulatePhysics(result.second, true);
852  }
853  }
854  return std::make_pair(result.first, result.second->GetActorId());
855  }
856  return std::make_pair(result.first, 0);
857 }
858 
859 // replay event for removing actor
860 bool FFrameData::ProcessReplayerEventDel(uint32_t DatabaseId)
861 {
862  check(Episode != nullptr);
863  FCarlaActor* CarlaActor = Episode->FindCarlaActor(DatabaseId);
864  if (CarlaActor == nullptr)
865  {
866  UE_LOG(LogCarla, Log, TEXT("Actor %d not found to destroy"), DatabaseId);
867  return false;
868  }
869  Episode->DestroyActor(CarlaActor->GetActorId());
870  return true;
871 }
872 
873 // replay event for parenting actors
874 bool FFrameData::ProcessReplayerEventParent(uint32_t ChildId, uint32_t ParentId)
875 {
876  check(Episode != nullptr);
877  FCarlaActor * Child = Episode->FindCarlaActor(ChildId);
878  FCarlaActor * Parent = Episode->FindCarlaActor(ParentId);
879  if(!Child)
880  {
881  UE_LOG(LogCarla, Log, TEXT("Parenting Child actors not found"));
882  return false;
883  }
884  if(!Parent)
885  {
886  UE_LOG(LogCarla, Log, TEXT("Parenting Parent actors not found"));
887  return false;
888  }
889  Child->SetParent(ParentId);
891  Parent->AddChildren(Child->GetActorId());
892  if(!Parent->IsDormant())
893  {
894  if(!Child->IsDormant())
895  {
897  Child->GetActor(),
898  Parent->GetActor(),
900  }
901  }
902  else
903  {
905  }
906  return true;
907 }
908 
909 // reposition actors
911 {
912  check(Episode != nullptr);
913  FCarlaActor* CarlaActor = Episode->FindCarlaActor(Pos1.DatabaseId);
914  FVector Location;
915  FRotator Rotation;
916  if(CarlaActor)
917  {
918  // check to assign first position or interpolate between both
919  if (Per == 0.0)
920  {
921  // assign position 1
922  Location = FVector(Pos1.Location);
923  Rotation = FRotator::MakeFromEuler(Pos1.Rotation);
924  }
925  else
926  {
927  // interpolate positions
928  Location = FMath::Lerp(FVector(Pos1.Location), FVector(Pos2.Location), Per);
929  Rotation = FMath::Lerp(FRotator::MakeFromEuler(Pos1.Rotation), FRotator::MakeFromEuler(Pos2.Rotation), Per);
930  }
931  // set new transform
932  FTransform Trans(Rotation, Location, FVector(1, 1, 1));
933  CarlaActor->SetActorGlobalTransform(Trans, ETeleportType::None);
934  return true;
935  }
936  return false;
937 }
938 
939 // reposition the camera
940 bool FFrameData::SetCameraPosition(uint32_t Id, FVector Offset, FQuat Rotation)
941 {
942  check(Episode != nullptr);
943 
944  // get the actor to follow
945  FCarlaActor* CarlaActor = Episode->FindCarlaActor(Id);
946  if (!CarlaActor)
947  return false;
948  // get specator pawn
949  APawn *Spectator = Episode->GetSpectatorPawn();
950  if (!Spectator)
951  return false;
952 
953  FCarlaActor* CarlaSpectator = Episode->FindCarlaActor(Spectator);
954  if (!CarlaSpectator)
955  return false;
956 
957  FTransform ActorTransform = CarlaActor->GetActorGlobalTransform();
958  // set the new position
959  FQuat ActorRot = ActorTransform.GetRotation();
960  FVector Pos = ActorTransform.GetTranslation() + (ActorRot.RotateVector(Offset));
961  CarlaSpectator->SetActorGlobalTransform(FTransform(ActorRot * Rotation, Pos, FVector(1,1,1)));
962 
963  return true;
964 }
965 
967 {
968  check(Episode != nullptr);
969  FCarlaActor* CarlaActor = Episode->FindCarlaActor(State.DatabaseId);
970  if(CarlaActor)
971  {
972  CarlaActor->SetTrafficLightState(static_cast<ETrafficLightState>(State.State));
973  UTrafficLightController* Controller = CarlaActor->GetTrafficLightController();
974  if(Controller)
975  {
976  Controller->SetElapsedTime(State.ElapsedTime);
977  ATrafficLightGroup* Group = Controller->GetGroup();
978  if (Group)
979  {
980  Group->SetFrozenGroup(State.IsFrozen);
981  }
982  }
983  return true;
984  }
985  return false;
986 }
987 
988 // set the animation for Vehicles
990 {
991  check(Episode != nullptr);
992  FCarlaActor *CarlaActor = Episode->FindCarlaActor(Vehicle.DatabaseId);
993  if (CarlaActor)
994  {
995  FVehicleControl Control;
996  Control.Throttle = Vehicle.Throttle;
997  Control.Steer = Vehicle.Steering;
998  Control.Brake = Vehicle.Brake;
999  Control.bHandBrake = Vehicle.bHandbrake;
1000  Control.bReverse = (Vehicle.Gear < 0);
1001  Control.Gear = Vehicle.Gear;
1002  Control.bManualGearShift = false;
1003  CarlaActor->ApplyControlToVehicle(Control, EVehicleInputPriority::User);
1004  }
1005 }
1006 
1008 {
1009  check(Episode != nullptr)
1010  FCarlaActor *CarlaActor = Episode->FindCarlaActor(VehicleAnimWheels.DatabaseId);
1011  if (CarlaActor == nullptr)
1012  return;
1013  if (CarlaActor->GetActorType() != FCarlaActor::ActorType::Vehicle)
1014  return;
1015  ACarlaWheeledVehicle* CarlaVehicle = Cast<ACarlaWheeledVehicle>(CarlaActor->GetActor());
1016  check(CarlaVehicle != nullptr)
1017  USkeletalMeshComponent* SkeletalMesh = CarlaVehicle->GetMesh();
1018  check(SkeletalMesh != nullptr)
1019  UVehicleAnimInstance* VehicleAnim = Cast<UVehicleAnimInstance>(SkeletalMesh->GetAnimInstance());
1020  check(VehicleAnim != nullptr)
1021 
1022  for (uint32_t i = 0; i < VehicleAnimWheels.WheelValues.size(); ++i)
1023  {
1024  const WheelInfo& Element = VehicleAnimWheels.WheelValues[i];
1025  VehicleAnim->SetWheelRotYaw(static_cast<uint8>(Element.Location), Element.SteeringAngle);
1026  VehicleAnim->SetWheelPitchAngle(static_cast<uint8>(Element.Location), Element.TireRotation);
1027  }
1028 }
1029 
1030 // set the lights for vehicles
1032 {
1033  check(Episode != nullptr);
1034  FCarlaActor * CarlaActor = Episode->FindCarlaActor(LightVehicle.DatabaseId);
1035  if (CarlaActor)
1036  {
1037  carla::rpc::VehicleLightState LightState(LightVehicle.State);
1038  CarlaActor->SetVehicleLightState(FVehicleLightState(LightState));
1039  }
1040 }
1041 
1043 {
1044  check(Episode != nullptr);
1045  UWorld* World = Episode->GetWorld();
1046  if(World)
1047  {
1048  UCarlaLightSubsystem* CarlaLightSubsystem = World->GetSubsystem<UCarlaLightSubsystem>();
1049  if (!CarlaLightSubsystem)
1050  {
1051  return;
1052  }
1053  auto* CarlaLight = CarlaLightSubsystem->GetLight(LightScene.LightId);
1054  if (CarlaLight)
1055  {
1056  CarlaLight->SetLightIntensity(LightScene.Intensity);
1057  CarlaLight->SetLightColor(LightScene.Color);
1058  CarlaLight->SetLightOn(LightScene.bOn);
1059  CarlaLight->SetLightType(static_cast<ELightType>(LightScene.Type));
1060  }
1061  }
1062 }
1063 
1064 // set the animation for walkers
1066 {
1067  SetWalkerSpeed(Walker.DatabaseId, Walker.Speed);
1068 }
1069 
1071 {
1072  check(Episode != nullptr);
1073  FCarlaActor * CarlaActor = Episode->FindCarlaActor(Biker.DatabaseId);
1074  if (CarlaActor == nullptr)
1075  return;
1076  ACarlaWheeledVehicle* CarlaVehicle = Cast<ACarlaWheeledVehicle>(CarlaActor->GetActor());
1077  check(CarlaVehicle != nullptr)
1078  CarlaVehicle->SetSpeedAnim(Biker.ForwardSpeed);
1079  CarlaVehicle->SetRotationAnim(Biker.EngineRotation);
1080 }
1081 
1082 
1083 // replay finish
1084 bool FFrameData::ProcessReplayerFinish(bool bApplyAutopilot, bool bIgnoreHero, std::unordered_map<uint32_t, bool> &IsHero)
1085 {
1086  // set autopilot and physics to all AI vehicles
1087  const FActorRegistry& Registry = Episode->GetActorRegistry();
1088  for (auto& It : Registry)
1089  {
1090  FCarlaActor* CarlaActor = It.Value.Get();
1091 
1092  // enable physics only on vehicles
1093  switch (CarlaActor->GetActorType())
1094  {
1095 
1096  // vehicles
1098  // check for hero
1099  if (!(bIgnoreHero && IsHero[CarlaActor->GetActorId()]))
1100  {
1101  // stop all vehicles
1102  SetActorSimulatePhysics(CarlaActor, true);
1103  SetActorVelocity(CarlaActor, FVector(0, 0, 0));
1104  FVehicleControl Control;
1105  Control.Throttle = 0.0f;
1106  Control.Steer = 0.0f;
1107  Control.Brake = 0.0f;
1108  Control.bHandBrake = false;
1109  Control.bReverse = false;
1110  Control.Gear = 1;
1111  Control.bManualGearShift = false;
1112  CarlaActor->ApplyControlToVehicle(Control, EVehicleInputPriority::User);
1113  }
1114  break;
1115 
1116  // walkers
1118  // stop walker
1119  SetWalkerSpeed(CarlaActor->GetActorId(), 0.0f);
1120  break;
1121  }
1122  }
1123  return true;
1124 }
1125 
1126 void FFrameData::SetActorVelocity(FCarlaActor *CarlaActor, FVector Velocity)
1127 {
1128  if (!CarlaActor)
1129  {
1130  return;
1131  }
1132  CarlaActor->SetActorTargetVelocity(Velocity);
1133 }
1134 
1135 // set the animation speed for walkers
1136 void FFrameData::SetWalkerSpeed(uint32_t ActorId, float Speed)
1137 {
1138  check(Episode != nullptr);
1139  FCarlaActor * CarlaActor = Episode->FindCarlaActor(ActorId);
1140  if (!CarlaActor)
1141  {
1142  return;
1143  }
1144  FWalkerControl Control;
1145  Control.Speed = Speed;
1146  CarlaActor->ApplyControlToWalker(Control);
1147 }
1148 
1149 // enable / disable physics for an actor
1150 bool FFrameData::SetActorSimulatePhysics(FCarlaActor* CarlaActor, bool bEnabled)
1151 {
1152  if (!CarlaActor)
1153  {
1154  return false;
1155  }
1156  ECarlaServerResponse Response =
1157  CarlaActor->SetActorSimulatePhysics(bEnabled);
1158  if (Response != ECarlaServerResponse::Success)
1159  {
1160  return false;
1161  }
1162  return true;
1163 }
1164 
1166 {
1168 }
1169 
1171 {
1172  check(Episode != nullptr);
1173  auto World = Episode->GetWorld();
1174  check(World != nullptr);
1175 
1176  // get its position (truncated as int's)
1177  int x = static_cast<int>(Location.X);
1178  int y = static_cast<int>(Location.Y);
1179  int z = static_cast<int>(Location.Z);
1180 
1181  const FActorRegistry &Registry = Episode->GetActorRegistry();
1182  // through all actors in registry
1183  for (auto It = Registry.begin(); It != Registry.end(); ++It)
1184  {
1185  FCarlaActor* CarlaActor = It.Value().Get();
1187  {
1188  FVector vec = CarlaActor->GetActorGlobalLocation();
1189  int x2 = static_cast<int>(vec.X);
1190  int y2 = static_cast<int>(vec.Y);
1191  int z2 = static_cast<int>(vec.Z);
1192  if ((x2 == x) && (y2 == y) && (z2 == z))
1193  {
1194  // actor found
1195  return CarlaActor;
1196  }
1197  }
1198  }
1199  // actor not found
1200  return nullptr;
1201 }
1202 
1204 {
1205  // registring all existing actors in first frame
1206  FActorRegistry Registry = Episode->GetActorRegistry();
1207  for (auto& It : Registry)
1208  {
1209  const FCarlaActor* CarlaActor = It.Value.Get();
1210  if (CarlaActor != nullptr)
1211  {
1212  // create event
1214  CarlaActor->GetActorId(),
1215  static_cast<uint8_t>(CarlaActor->GetActorType()),
1216  CarlaActor->GetActorGlobalTransform(),
1217  CarlaActor->GetActorInfo()->Description,
1218  false);
1219  }
1220  }
1221 }
UCarlaLight * GetLight(int Id)
FCarlaActor * FindCarlaActor(FCarlaActor::IdType ActorId)
Find a Carla actor by id.
Definition: CarlaEpisode.h:173
bool ProcessReplayerEventParent(uint32_t ChildId, uint32_t ParentId)
Definition: FrameData.cpp:874
void AddExistingActors(void)
Definition: FrameData.cpp:1203
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:252
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
CarlaRecorderInfo Info
Definition: FrameData.h:44
const std::vector< CarlaRecorderEventAdd > & GetEvents()
void ProcessReplayerAnimVehicleWheels(CarlaRecorderAnimWheels Vehicle)
Definition: FrameData.cpp:1007
virtual ETrafficLightState GetTrafficLightState() const
Definition: CarlaActor.h:353
void AddTriggerVolume(const ATrafficSignBase &TrafficSign)
Definition: FrameData.cpp:549
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:669
void Read(std::istream &InFile)
void Add(const CarlaRecorderAnimWheels &InObj)
void AddEventLightSceneChanged(const UCarlaLight *Light)
Definition: FrameData.cpp:679
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:468
Class which implements the state changing of traffic lights.
CarlaRecorderAnimBikers Bikers
Definition: FrameData.h:55
void AddAnimVehicle(const CarlaRecorderAnimVehicle &Vehicle)
Definition: FrameData.cpp:654
float GetGreenTime() const
void Add(const CarlaRecorderEventAdd &Event)
CarlaRecorderActorBoundingBoxes BoundingBoxes
Definition: FrameData.h:59
void AddBoundingBox(const CarlaRecorderActorBoundingBox &ActorBoundingBox)
Definition: FrameData.cpp:698
void Add(const CarlaRecorderStateTrafficLight &State)
void PutActorToSleep(carla::rpc::ActorId ActorId)
Definition: CarlaEpisode.h:280
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:1065
void AddVehicleLight(FCarlaActor *CarlaActor)
Definition: FrameData.cpp:506
EVehicleWheelLocation Location
CarlaRecorderAnimVehicleWheels Wheels
Definition: FrameData.h:53
void AddAnimVehicleWheels(const CarlaRecorderAnimWheels &VehicleWheels)
Definition: FrameData.cpp:659
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:81
void AddActorPosition(FCarlaActor *CarlaActor)
Definition: FrameData.cpp:379
void AddVehicleWheelsAnimation(FCarlaActor *CarlaActor)
Definition: FrameData.cpp:416
static uint64_t GetFrameCounter()
Definition: CarlaEngine.h:65
void Add(const CarlaRecorderPhysicsControl &InObj)
void Add(const CarlaRecorderLightVehicle &InObj)
geom::Location Location
Definition: rpc/Location.h:14
void SetFrameCounter()
Definition: FrameData.cpp:1165
void Write(std::ostream &OutFile)
CarlaRecorderActorTriggerVolumes TriggerVolumes
Definition: FrameData.h:60
const FActorRegistry & GetActorRegistry() const
Definition: CarlaEpisode.h:155
TMap< FString, FActorAttribute > Variations
User selected variations of the actor.
ECarlaServerResponse
UCarlaEpisode * Episode
Definition: FrameData.h:183
void ProcessReplayerLightVehicle(CarlaRecorderLightVehicle LightVehicle)
Definition: FrameData.cpp:1031
void Add(const CarlaRecorderActorBoundingBox &InObj)
void Add(const CarlaRecorderKinematics &InObj)
A simulation episode.
Definition: CarlaEpisode.h:38
void SetWalkerSpeed(uint32_t ActorId, float Speed)
Definition: FrameData.cpp:1136
void AddPosition(const CarlaRecorderPosition &Position)
Definition: FrameData.cpp:587
void Write(std::ostream &OutFile)
CarlaRecorderEventsDel EventsDel
Definition: FrameData.h:47
void AddLightVehicle(const CarlaRecorderLightVehicle &LightVehicle)
Definition: FrameData.cpp:674
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:1150
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:1170
void AddActorBoundingBox(FCarlaActor *CarlaActor)
Definition: FrameData.cpp:535
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:1070
bool Contains(uint32 Id) const
Definition: ActorRegistry.h:64
CarlaRecorderEventsAdd EventsAdd
Definition: FrameData.h:46
bool ProcessReplayerEventDel(uint32_t DatabaseId)
Definition: FrameData.cpp:860
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:799
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:989
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:693
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:575
void Clear()
Definition: FrameData.cpp:185
float GetRedTime() const
bool ProcessReplayerPosition(CarlaRecorderPosition Pos1, CarlaRecorderPosition Pos2, double Per, double DeltaTime)
Definition: FrameData.cpp:910
float GetYellowTime() const
ECarlaServerResponse SetActorTargetVelocity(const FVector &Velocity)
Definition: CarlaActor.cpp:390
void AddState(const CarlaRecorderStateTrafficLight &State)
Definition: FrameData.cpp:649
void AddCollision(AActor *Actor1, AActor *Actor2)
Definition: FrameData.cpp:607
CarlaRecorderEventsParent EventsParent
Definition: FrameData.h:48
EVehicleWheelLocation
const std::vector< CarlaRecorderAnimVehicle > & GetVehicles()
bool ProcessReplayerStateTrafficLight(CarlaRecorderStateTrafficLight State)
Definition: FrameData.cpp:966
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:144
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:518
void AddAnimBiker(const CarlaRecorderAnimBiker &Biker)
Definition: FrameData.cpp:664
virtual UTrafficLightController * GetTrafficLightController()
Definition: CarlaActor.h:358
void AddTrafficLightState(FCarlaActor *CarlaActor)
Definition: FrameData.cpp:484
bool ProcessReplayerFinish(bool bApplyAutopilot, bool bIgnoreHero, std::unordered_map< uint32_t, bool > &IsHero)
Definition: FrameData.cpp:1084
static ALargeMapManager * GetLargeMapManager(const UObject *WorldContextObject)
Definition: CarlaStatics.h:100
void AddPhysicsControl(const ACarlaWheeledVehicle &Vehicle)
Definition: FrameData.cpp:567
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:1126
void SetRotationAnim(float Rotation)
void ProcessReplayerLightScene(CarlaRecorderLightScene LightScene)
Definition: FrameData.cpp:1042
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:709
void GetFrameCounter()
Definition: FrameData.cpp:703
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:592
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:940
A view over an actor and its properties.
Definition: CarlaActor.h:23
void Write(std::ostream &OutFile) const