28#include <util/ue-header-guard-begin.h>
29#include "GameFramework/Character.h"
30#include "GameFramework/CharacterMovementComponent.h"
31#include <util/ue-header-guard-end.h>
39 if (bIncludeActorsAgain)
45 for (
auto It = Registry.
begin(); It != Registry.
end(); ++It)
62 const auto *Root = Cast<UPrimitiveComponent>(View->
GetActor()->GetRootComponent());
63 if ((Root !=
nullptr) && Root->IsSimulatingPhysics())
122 if (Appearances.size() >
static_cast<size_t>(Registry.
Num()))
124 for (
auto It = Appearances.begin(); It != Appearances.end();)
126 It = Registry.
Contains(It->first) ? std::next(It) : Appearances.erase(It);
156 std::vector<uint64_t> FFrameData_SortedIds(
const TSet<uint64> &Ids)
158 std::vector<uint64_t> Sorted;
159 Sorted.reserve(Ids.Num());
160 for (
const uint64 Id : Ids)
162 Sorted.push_back(Id);
164 std::sort(Sorted.begin(), Sorted.end());
168 TSet<uint64> FFrameData_IdSet(
const std::vector<uint64_t> &Ids)
171 Set.Reserve(
static_cast<int32
>(Ids.size()));
172 for (
const uint64_t Id : Ids)
203 if (Actor ==
nullptr)
208 Appearance.
bCollisions = Actor->GetActorEnableCollision();
209 Appearance.
bHidden = Actor->IsHidden();
210 Appearance.
Scale = Actor->GetActorScale3D();
212 const auto It = Sent.find(CarlaActor->
GetActorId());
213 if (!bFullResync && (It != Sent.end()) && (It->second == Appearance))
222 Record.
scale = std::array<double, 3>{Appearance.
Scale.X, Appearance.
Scale.Y, Appearance.
Scale.Z};
229 UWorld *World =
Episode->GetWorld();
244 if (GameMode !=
nullptr)
249 if (LightSubsystem !=
nullptr)
254#if defined(WITH_ROS2)
256 if (ROS2 && ROS2->IsEnabled())
263 if ((GameMode !=
nullptr) &&
272 if (LightSubsystem !=
nullptr)
276 for (
const auto &Light : LightSubsystem->
GetLights())
288 UCarlaLight *Light = LightSubsystem->
GetLight(LightId);
302 template <
typename MapT>
303 std::optional<uint32_t> FindMirror(
const MapT &MappedId, uint32_t PrimaryId)
305 const auto It = MappedId.find(PrimaryId);
306 return (It != MappedId.end()) ? std::optional<uint32_t>(It->second) :
std::nullopt;
312 std::unordered_map<uint32_t, uint32_t>& MappedId,
314 TFunctionRef<
void(uint32_t, uint32_t,
bool)> OnActorAdded,
315 TFunctionRef<
void(uint32_t)> OnActorRemoved)
319 std::unordered_set<uint32_t> AddedIds;
326 uint32_t OldId =
EventAdd.DatabaseId;
335 switch (Result.first)
339 UE_LOG(LogCarla, Log, TEXT(
"actor could not be created"));
345 MappedId[OldId] = Result.second;
348 UE_LOG(LogCarla, Log, TEXT(
"actor created"));
349 OnActorAdded(OldId, Result.second,
true);
355 MappedId[OldId] = Result.second;
357 UE_LOG(LogCarla, Log, TEXT(
"actor reused"));
358 OnActorAdded(OldId, Result.second,
false);
361 AddedIds.insert(OldId);
366 std::vector<std::pair<uint32_t, uint32_t>> Parents = std::move(MirrorState.
PendingParents);
372 for (
const auto &Parent : Parents)
381 std::unordered_set<uint32_t> RemovedIds;
384 if (
const std::optional<uint32_t> Local = FindMirror(MappedId,
EventDel.DatabaseId))
388 MappedId.erase(
EventDel.DatabaseId);
390 RemovedIds.insert(
EventDel.DatabaseId);
391 OnActorRemoved(
EventDel.DatabaseId);
399 for (
auto It = MappedId.begin(); It != MappedId.end();)
401 const uint32_t PrimaryId = It->first;
402 const uint32_t LocalId = It->second;
403 if ((AddedIds.count(PrimaryId) == 0u) && (MirrorState.
CreatedIds.count(LocalId) != 0u))
407 It = MappedId.erase(It);
408 RemovedIds.insert(PrimaryId);
409 OnActorRemoved(PrimaryId);
417 if (!RemovedIds.empty() || bFullResync)
421 Pending.erase(std::remove_if(Pending.begin(), Pending.end(), [&](
const auto &Parent)
423 const auto Gone = [&](uint32_t Id)
425 return (RemovedIds.count(Id) != 0u) || (bFullResync && (AddedIds.count(Id) == 0u));
427 return Gone(Parent.first) || Gone(Parent.second);
432 PlayAppearances(MappedId);
433 PlayPositions(MappedId, MirrorState);
434 PlayKinematics(MappedId);
438 const std::optional<uint32_t> Local = FindMirror(MappedId, Time.DatabaseId);
439 FCarlaActor *CarlaActor = Local ? Episode->FindCarlaActor(*Local) :
nullptr;
461 if (
const std::optional<uint32_t> Local = FindMirror(MappedId,
State.DatabaseId))
465 ProcessReplayerStateTrafficLight(StateTrafficLight);
471 PlayVehicleParts(MappedId);
475 if (
const std::optional<uint32_t> Local = FindMirror(MappedId,
AnimVehicle.DatabaseId))
479 ProcessReplayerAnimVehicle(
Vehicle);
485 if (
const std::optional<uint32_t> Local = FindMirror(MappedId,
AnimWalker.DatabaseId))
489 ProcessReplayerAnimWalker(Walker);
495 if (
const std::optional<uint32_t> Local = FindMirror(MappedId,
AnimBiker.DatabaseId))
499 ProcessReplayerAnimBiker(Biker);
505 if (
const std::optional<uint32_t> Local = FindMirror(MappedId, LightVehicle.DatabaseId))
509 ProcessReplayerLightVehicle(Light);
515 PlayWorldState(MirrorState);
519 ProcessReplayerLightScene(Light);
524 const auto FindSensor = [&](uint32_t PrimaryId) ->
ASensor *
526 const std::optional<uint32_t> Local = FindMirror(MappedId, PrimaryId);
527 FCarlaActor *CarlaActor = Local ? Episode->FindCarlaActor(*Local) :
nullptr;
528 return CarlaActor ? Cast<ASensor>(CarlaActor->
GetActor()) : nullptr;
534 Sensor->SetMirrorState(
State);
539 if (
ASensor *Sensor = FindSensor(Tick.actor_id))
541 Sensor->SetPrimaryTick(Tick.delta_seconds);
558 if (Diff.first != 0u)
562 if (Diff.second != 0u)
572 const std::optional<uint32_t> Local = FindMirror(MappedId, Appearance.actor_id);
575 if (Actor ==
nullptr)
579 if (Appearance.collisions && (Actor->GetActorEnableCollision() != *Appearance.collisions))
581 Actor->SetActorEnableCollision(*Appearance.collisions);
583 if (Appearance.hidden && (Actor->IsHidden() != *Appearance.hidden))
585 Actor->SetActorHiddenInGame(*Appearance.hidden);
587 if (Appearance.scale)
589 const FVector Scale((*Appearance.scale)[0], (*Appearance.scale)[1], (*Appearance.scale)[2]);
590 if (!Actor->GetActorScale3D().Equals(Scale, 0.0))
592 USceneComponent *Root = Actor->GetRootComponent();
593 if ((Root !=
nullptr) && (Root->GetMobility() != EComponentMobility::Movable))
595 Root->SetMobility(EComponentMobility::Movable);
597 Actor->SetActorScale3D(Scale);
605 UWorld *World =
Episode->GetWorld();
612 if (GameMode !=
nullptr)
621#if defined(WITH_ROS2)
623 if (ROS2 && ROS2->IsEnabled() && (ROS2->GetPublishTF() != Globals.
publish_tf))
634 Weather->ApplyWeather(FFrameData_FromRecord(Record));
652 bool bApplyObjects =
false;
656 bApplyObjects =
true;
664 if (!Diff.second.empty())
668 if (!Diff.first.empty())
676 const std::unordered_map<uint32_t, uint32_t>& MappedId,
685 if (
const std::optional<uint32_t> Local = FindMirror(MappedId,
Position.DatabaseId))
695 std::vector<uint32_t> LocalIds;
696 std::unordered_map<uint32_t, FTransform> Poses;
697 std::unordered_map<uint32_t, uint32_t> Parents;
701 const std::optional<uint32_t> Local = FindMirror(MappedId,
Position.id);
703 if (CarlaActor ==
nullptr)
707 LocalIds.push_back(*Local);
708 Poses.emplace(*Local, FTransform(
713 Parents.emplace(*Local, CarlaActor->
GetParent());
721 const FTransform &Pose = Poses[LocalId];
723 MirrorState.
PlayedPoses.emplace_back(LocalId, Pose);
736 if (
auto *
Vehicle = Cast<ACarlaWheeledVehicle>(Actor))
738 Vehicle->SetMirroredMotion(Velocity, FVector::DotProduct(Velocity,
Vehicle->GetActorForwardVector()));
740 else if (
auto *
Character = Cast<ACharacter>(Actor))
742 if (UCharacterMovementComponent *Movement =
Character->GetCharacterMovement())
744 Movement->Velocity = Velocity;
747 if (USceneComponent *Root = Actor->GetRootComponent())
749 Root->ComponentVelocity = Velocity;
758 const std::optional<uint32_t> Local = FindMirror(MappedId, Kinematic.DatabaseId);
760 if (CarlaActor !=
nullptr)
768 for (
const auto &Mapped : MappedId)
786 Transform.SetScale3D(Data->Scale);
792 if (Actor ==
nullptr)
797 Transform.SetScale3D(Actor->GetActorScale3D());
798 USceneComponent *Root = Actor->GetRootComponent();
799 if ((Root !=
nullptr) && (Root->GetMobility() != EComponentMobility::Movable))
806 Root->SetMobility(EComponentMobility::Movable);
814 if (CarlaActor ==
nullptr)
835 if (
auto *Root = Cast<UPrimitiveComponent>(CarlaActor->
GetActor()->GetRootComponent()))
837 if (Root->IsSimulatingPhysics())
839 Root->SetSimulatePhysics(
false);
883 "packet ids are fixed: see LibCarla/source/carla/multigpu");
886 "packet ids are fixed: see LibCarla/source/carla/multigpu");
889 "packet ids are fixed: see LibCarla/source/carla/multigpu");
892 "packet ids are fixed: see LibCarla/source/carla/multigpu");
895 "packet ids are fixed: see LibCarla/source/carla/multigpu");
898 "packet ids are fixed: see LibCarla/source/carla/multigpu");
901 "packet ids are fixed: see LibCarla/source/carla/multigpu");
904 "packet ids are fixed: see LibCarla/source/carla/multigpu");
950 "the frame data codec reads the frame counter itself");
956 [
this](uint8_t Id, std::istream &InStream, uint32_t PacketSize)
1006 if (Globals.
Read(InStream, PacketSize))
1008 MirrorWorldGlobals = Globals;
1032 if (Time.
Read(InStream, PacketSize))
1093 uint32_t DatabaseId,
1095 const FTransform &Transform,
1097 bool bAddOtherRelatedInfo)
1100 Description.
UId = ActorDescription.
UId;
1101 Description.
Id = ActorDescription.
Id;
1105 for (
const auto &item : ActorDescription.
Variations)
1108 Attr.
Type =
static_cast<uint8_t
>(item.Value.Type);
1109 Attr.
Id = item.Value.Id;
1110 Attr.
Value = item.Value.Value;
1112 if (!Attr.
Id.IsEmpty())
1114 Description.
Attributes.emplace_back(std::move(Attr));
1123 Transform.GetTranslation(),
1124 Transform.GetRotation().Euler(),
1125 std::move(Description)
1129 if (!bAddOtherRelatedInfo)
1170 check(CarlaActor !=
nullptr);
1174 const FVector Location = Transform.GetLocation();
1175 const FQuat Rotation = Transform.GetRotation();
1190 check(CarlaActor !=
nullptr);
1213 check(CarlaActor !=
nullptr)
1220 if (CarlaVehicle ==
nullptr)
1224 if (Movement ==
nullptr)
1229 Parts.
wheels.reserve(Movement->WheelSetups.Num());
1232 for (int32 i = 0; CarlaVehicle->
HasWheel(i); ++i)
1236 static_cast<float>(Pose.RotOffset.Yaw),
1237 static_cast<float>(Pose.RotOffset.Pitch),
1242 const auto *Root = Cast<UPrimitiveComponent>(CarlaVehicle->GetRootComponent());
1244 for (
const TPair<int32, FTransform> &Door : CarlaVehicle->
GetOpenDoorPoses())
1247 Pose.
door =
static_cast<uint8_t
>(Door.Key);
1248 const FVector Location = Door.Value.GetLocation();
1249 const FQuat Rotation = Door.Value.GetRotation();
1250 Pose.
location = {Location.X, Location.Y, Location.Z};
1251 Pose.
rotation = {Rotation.X, Rotation.Y, Rotation.Z, Rotation.W};
1261 Movement->GetForwardSpeed(),
1262 Movement->GetEngineRotationSpeed() / Movement->GetEngineMaxRotationSpeed()
1269 check(CarlaActor !=
nullptr);
1285 check(CarlaActor !=
nullptr);
1299 static_cast<char>(LightState)
1307 check(CarlaActor !=
nullptr);
1319 check(CarlaActor !=
nullptr);
1334 check(CarlaActor !=
nullptr);
1355 check(CarlaActor !=
nullptr);
1361 {Box.Origin, Box.Extent}
1379 UBoxComponent* Trigger = Triggers.Top();
1380 auto VolumeOrigin = Trigger->GetComponentLocation();
1381 auto VolumeExtent = Trigger->GetScaledBoxExtent();
1385 {VolumeOrigin, VolumeExtent}
1517 Light->GetLightIntensity(),
1518 Light->GetLightColor(),
1519 Light->GetLightOn(),
1520 static_cast<uint8
>(Light->GetLightType())
1544 class FReplayedActorLookup
1548 : Episode(InEpisode), Description(InDescription), Location(InLocation) {}
1550 bool IsSameKind(uint32_t LocalId)
const
1553 return (Info !=
nullptr) && (Info->
Description.
Id == Description.Id);
1556 std::optional<uint32_t> FindMapActor()
const
1558 if (Description.Id == TEXT(
"spectator"))
1560 APawn *Spectator = Episode.GetSpectatorPawn();
1561 const FCarlaActor *CarlaActor = (Spectator !=
nullptr) ? Episode.FindCarlaActor(Spectator) :
nullptr;
1562 return (CarlaActor !=
nullptr) ? std::optional<uint32_t>(CarlaActor->
GetActorId()) :
std::nullopt;
1564 if (Description.Id != TEXT(
"static.prop.mesh"))
1566 return std::nullopt;
1569 const FIntVector Cell(
static_cast<int32
>(
Location.X),
static_cast<int32
>(
Location.Y),
static_cast<int32
>(
Location.Z));
1570 for (
auto It = Episode.GetActorRegistry().begin(); It != Episode.GetActorRegistry().end(); ++It)
1573 if ((CarlaActor ==
nullptr) || !IsMapActorLike(CarlaActor->
GetActorId()))
1578 if (Cell == FIntVector(
static_cast<int32
>(
Other.X),
static_cast<int32
>(
Other.Y),
static_cast<int32
>(
Other.Z)))
1583 return std::nullopt;
1589 bool IsMapActorLike(uint32_t LocalId)
const
1592 if ((Info ==
nullptr) || (Info->
Description.
Id != Description.Id))
1596 if (Description.Id == TEXT(
"spectator"))
1600 if (Description.Id != TEXT(
"static.prop.mesh"))
1604 const FActorAttribute *Mesh = Description.Variations.Find(TEXT(
"mesh_path"));
1606 return (Mesh !=
nullptr) && (OtherMesh !=
nullptr) && (Mesh->
Value == OtherMesh->
Value);
1609 bool Contains(uint32_t LocalId)
const
1611 return Episode.GetActorRegistry().Contains(LocalId);
1615 const FActorInfo *FindInfo(uint32_t LocalId)
const
1617 const FCarlaActor *CarlaActor = Episode.FindCarlaActor(LocalId);
1618 return (CarlaActor !=
nullptr) ? CarlaActor->
GetActorInfo() :
nullptr;
1634 std::unordered_map<uint32_t, uint32_t>& MappedId)
1639 if (ActorDesc.
Id.StartsWith(
"traffic."))
1642 if (CarlaActor !=
nullptr)
1645 UE_LOG(LogCarla, Log, TEXT(
"TrafficLight found"));
1646 return std::pair<int, FCarlaActor*>(2, CarlaActor);
1651 UE_LOG(LogCarla, Log, TEXT(
"TrafficLight not found"));
1652 return std::pair<int, FCarlaActor*>(0,
nullptr);
1655 else if (SpawnSensors || !ActorDesc.
Id.StartsWith(
"sensor."))
1658 MappedId, DesiredId, FReplayedActorLookup(*
Episode, ActorDesc, Location));
1662 FRotator Rot = FRotator::MakeFromEuler(Rotation);
1663 PlaceMirror(*CarlaActor, FTransform(Rot, Location));
1664 return std::pair<int, FCarlaActor*>(2, CarlaActor);
1668 FRotator Rot = FRotator::MakeFromEuler(Rotation);
1669 FTransform Trans(Rot, FVector(0, 0, 100000), FVector(1, 1, 1));
1672 if (Result.Key == EActorSpawnResultStatus::Success)
1676 PlaceMirror(*Result.Value, FTransform(Rot, Location));
1678 if (LargeMapManager)
1682 return std::pair<int, FCarlaActor*>(1, Result.Value);
1686 UE_LOG(LogCarla, Log, TEXT(
"Actor could't be created"));
1687 return std::pair<int, FCarlaActor*>(0, Result.Value);
1693 return std::pair<int, FCarlaActor*>(0,
nullptr);
1705 std::unordered_map<uint32_t, uint32_t>& MappedId)
1709 bool IsHero =
false;
1712 ActorDesc.
UId = Description.
UId;
1713 ActorDesc.
Id = Description.
Id;
1714 for (
const auto &Item : Description.
Attributes)
1719 Attr.
Value = Item.Value;
1722 if (Item.Id ==
"role_name" && Item.Value ==
"hero")
1734 if (result.first != 0)
1740 if (!(bIgnoreHero && IsHero))
1753 return std::make_pair(result.first, result.second->GetActorId());
1755 return std::make_pair(result.first, 0);
1763 if (CarlaActor ==
nullptr)
1765 UE_LOG(LogCarla, Log, TEXT(
"Actor %d not found to destroy"), DatabaseId);
1776 const std::unordered_map<uint32_t, uint32_t>& MappedId)
1779 const std::optional<uint32_t> LocalChild = FindMirror(MappedId, ChildId);
1780 const std::optional<uint32_t> LocalParent = FindMirror(MappedId, ParentId);
1783 if ((Child ==
nullptr) || (Parent ==
nullptr))
1807 if (ChildActor->GetAttachParentActor() != ParentActor)
1809 ChildActor->AttachToActor(ParentActor, FAttachmentTransformRules::KeepWorldTransform);
1813 if (ChildActor->GetOwner() != ParentActor)
1815 ChildActor->SetOwner(ParentActor);
1839 Rotation = FRotator::MakeFromEuler(Pos1.
Rotation);
1844 Location = FMath::Lerp(FVector(Pos1.
Location), FVector(Pos2.
Location), Per);
1845 Rotation = FMath::Lerp(FRotator::MakeFromEuler(Pos1.
Rotation), FRotator::MakeFromEuler(Pos2.
Rotation), Per);
1848 FTransform Trans(Rotation, Location, FVector(1, 1, 1));
1870 if (!CarlaSpectator)
1875 FQuat ActorRot = ActorTransform.GetRotation();
1876 FVector Pos = ActorTransform.GetTranslation() + (ActorRot.RotateVector(Offset));
1918 const auto *CarlaVehicle = Cast<ACarlaWheeledVehicle>(CarlaActor->
GetActor());
1919 Control.
bManualGearShift = (CarlaVehicle !=
nullptr) && CarlaVehicle->GetMirroredManualGearShift();
1928 const std::optional<uint32_t> Local = FindMirror(MappedId, Parts.actor_id);
1930 auto *CarlaVehicle = ((CarlaActor !=
nullptr) && !CarlaActor->
IsDormant()) ?
1931 Cast<ACarlaWheeledVehicle>(CarlaActor->
GetActor()) :
nullptr;
1932 if (CarlaVehicle ==
nullptr)
1937 if (CarlaVehicle->HasCarlaVehicleAnimation())
1939 if (!CarlaVehicle->IsWheelAnimationOverridden())
1941 CarlaVehicle->SetWheelAnimationOverride(
true);
1943 for (int32 i = 0; (i < static_cast<int32>(Parts.wheels.size())) && CarlaVehicle->HasWheel(i); ++i)
1946 CarlaVehicle->SetWheelSteerDirection(Location, Parts.wheels[i].steer);
1947 CarlaVehicle->SetWheelPitchAngle(Location, Parts.wheels[i].spin);
1948 CarlaVehicle->SetWheelSuspensionOffset(Location, Parts.wheels[i].suspension_offset);
1951 if (Parts.current_gear)
1953 CarlaVehicle->SetMirroredDrivetrain(*Parts.current_gear, Parts.manual_gear_shift, Parts.simulating_physics);
1955 TArray<TPair<int32, FTransform>> OpenDoors;
1958 OpenDoors.Emplace(Door.door, FTransform(
1959 FQuat(Door.rotation[0], Door.rotation[1], Door.rotation[2], Door.rotation[3]),
1960 FVector(Door.location[0], Door.location[1], Door.location[2])));
1962 CarlaVehicle->SetMirroredDoorPoses(OpenDoors);
1981 UWorld* World =
Episode->GetWorld();
1985 if (!CarlaLightSubsystem)
1995 CarlaLight->SetLightState(
2014 if (CarlaActor ==
nullptr)
2017 check(CarlaVehicle !=
nullptr)
2028 for (
auto& It : Registry)
2039 if (!(bIgnoreHero && IsHero[CarlaActor->
GetActorId()]))
2043 if (
auto* CarlaVehicle = Cast<ACarlaWheeledVehicle>(CarlaActor->
GetActor()))
2045 CarlaVehicle->SetWheelAnimationOverride(
false);
2050 Control.
Steer = 0.0f;
2051 Control.
Brake = 0.0f;
2089 Control.
Speed = Speed;
2117 auto World =
Episode->GetWorld();
2118 check(World !=
nullptr);
2121 int x =
static_cast<int>(Location.X);
2122 int y =
static_cast<int>(Location.Y);
2123 int z =
static_cast<int>(Location.Z);
2127 for (
auto It = Registry.
begin(); It != Registry.
end(); ++It)
2133 int x2 =
static_cast<int>(vec.X);
2134 int y2 =
static_cast<int>(vec.Y);
2135 int z2 =
static_cast<int>(vec.Z);
2136 if ((x2 ==
x) && (y2 ==
y) && (z2 ==
z))
2151 for (
auto& It : Registry)
2154 if (CarlaActor !=
nullptr)
2166 for (
auto& It : Registry)
2169 if ((CarlaActor !=
nullptr) && (CarlaActor->
GetParent() != 0u) &&
@ MultiGpuActorAppearance
static void FFrameData_SetMirroredMotion(FCarlaActor &CarlaActor, const FVector &Velocity)
What the engine reads when no CARLA code asks the episode: the mirror's movement component,...
void FrameTimeFromSettings(const FEpisodeSettings &Settings, carla::multigpu::FrameTime &Time)
Copies the episode settings into a FrameTime and back.
void SettingsFromFrameTime(const carla::multigpu::FrameTime &Time, FEpisodeSettings &Settings)
static bool IsValid(const ACarlaWheeledVehicle *Vehicle)
EActorAttributeType
List of valid types for actor attributes.
Base class for the CARLA Game Mode.
void UnLoadMapLayer(int32 MapLayers)
uint64 GetEnvironmentObjectsRegistrations() const
How many times the environment objects were registered (on every map layer streamed in or out).
void EnableEnvironmentObjects(const TSet< uint64 > &EnvObjectIds, bool Enable)
float IMUSensorGravity
Gravitational acceleration used by IMU sensors.
void LoadMapLayer(int32 MapLayers)
uint64 GetEnvironmentObjectsSerial() const
const TSet< uint64 > & GetDisabledEnvironmentObjects() const
The registered environment objects disabled now, and a count of the changes to that set: Multi-GPU se...
int32 GetLoadedMapLayers() const
rpc::MapLayer bits of the layers loaded now.
Base class for CARLA wheeled vehicles.
bool IsTwoWheeledVehicle()
UChaosWheeledVehicleMovementComponent * GetChaosWheeledVehicleMovementComponent() const
Get chaos wheeled vehicle movement component casted.
int32 GetVehicleCurrentGear() const
Active gear of the vehicle.
FVector GetWheelSuspensionAxis(int32 WheelIndex) const
Unit vector, component space, along which the wheel's suspension drops.
const FVehicleControl & GetVehicleControl() const
Vehicle control currently applied to this vehicle.
FWheelAnimationData GetDrawnWheelPose(int32 WheelIndex) const
Wheel pose the animation instance drew this frame (else GetWheelPose); what secondaries must draw.
bool HasWheel(int32 WheelIndex) const
void SetRotationAnim(float Rotation)
void SetSpeedAnim(float Speed)
TArray< TPair< int32, FTransform > > GetOpenDoorPoses() const
Every door open now (a physics body of its own while open), by door index, with its pose relative to ...
void OnActorSpawned(const FCarlaActor &CarlaActor)
bool IsReadyToTick() const
virtual void GetMirrorState(carla::multigpu::SensorState &State) const
Multi-GPU: the runtime state this sensor starts its next tick from (noise generator,...
float GetReadyToTickDeltaSeconds() const
Class which implements the state changing of traffic lights.
void SetFrozenGroup(bool InFreeze)
TArray< UBoxComponent * > GetTriggerVolumes() const
void Add(const CarlaRecorderActorBoundingBox &InObj)
void Add(const CarlaRecorderActorBoundingBox &InObj)
const std::vector< CarlaRecorderKinematics > & GetKinematics() const
void Read(std::istream &InFile)
void Add(const CarlaRecorderKinematics &InObj)
void Write(std::ostream &OutFile)
void Write(std::ostream &OutFile) const
void Add(const CarlaRecorderAnimBiker &InObj)
void Read(std::istream &InFile)
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)
const std::vector< CarlaRecorderEventAdd > & GetEvents()
void Add(const CarlaRecorderEventDel &Event)
const std::vector< CarlaRecorderEventDel > & GetEvents()
void Write(std::ostream &OutFile)
void Read(std::istream &InFile)
const std::vector< CarlaRecorderEventParent > & GetEvents()
void Write(std::ostream &OutFile)
void Read(std::istream &InFile)
void Add(const CarlaRecorderEventParent &Event)
void Add(const CarlaRecorderPhysicsControl &InObj)
const std::vector< CarlaRecorderPosition > & GetPositions()
void Add(const CarlaRecorderPosition &InObj)
void Read(std::istream &InFile)
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderStateTrafficLight &State)
void Read(std::istream &InFile)
void Add(const CarlaRecorderTrafficLightTime &InObj)
void Write(std::ostream &OutFile)
void Read(std::istream &InFile)
void Read(std::istream &InFile)
const std::vector< CarlaRecorderWeather > & GetWeathers() const
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderWeather &InObj)
A registry of all the Carla actors.
bool Contains(uint32 Id) const
auto begin() const noexcept
FCarlaActor * FindCarlaActor(IdType Id)
auto end() const noexcept
A view over an actor and its properties.
void SetMirroredKinematics(const FVector &Velocity, const FVector &AngularVelocityRadians, uint64 Frame)
Multi-GPU secondary: the primary's velocities of the actor this one mirrors, in the world frame (cm/s...
ActorType GetActorType() const
void ClearMirroredKinematics()
virtual ECarlaServerResponse SetVehicleLightState(const FVehicleLightState &)
bool HasMirroredKinematics() const
virtual ECarlaServerResponse ApplyControlToVehicle(const FVehicleControl &, const EVehicleInputPriority &)
FVector GetActorAngularVelocity() const
void SetParent(IdType InParentId)
void SetAttachmentType(carla::rpc::AttachmentType InAttachmentType)
uint64 GetMirroredKinematicsFrame() const
void SetPrimaryActorId(IdType InPrimaryActorId)
Multi-GPU secondary: the id the primary gave the actor this one mirrors.
virtual ECarlaServerResponse GetVehicleLightState(FVehicleLightState &)
FTransform GetActorGlobalTransform() const
virtual FVector GetActorVelocity() const
void SetActorGlobalTransform(const FTransform &Transform, ETeleportType Teleport=ETeleportType::TeleportPhysics)
virtual ECarlaServerResponse ApplyControlToWalker(const FWalkerControl &)
virtual ECarlaServerResponse GetVehicleControl(FVehicleControl &)
FActorData * GetActorData()
FVector GetActorGlobalLocation() const
bool IsPendingKill() const
void AddChildren(IdType ChildId)
virtual ETrafficLightState GetTrafficLightState() const
virtual UTrafficLightController * GetTrafficLightController()
virtual ECarlaServerResponse GetWalkerControl(FWalkerControl &)
const FActorInfo * GetActorInfo() const
IdType GetActorId() const
ECarlaServerResponse SetActorTargetVelocity(const FVector &Velocity)
virtual ECarlaServerResponse SetActorSimulatePhysics(bool bEnabled)
virtual ECarlaServerResponse SetTrafficLightState(const ETrafficLightState &)
static uint64_t GetFrameCounter()
static void ResetFrameCounter(uint64_t Value=0)
void AddPhysicsControl(const ACarlaWheeledVehicle &Vehicle)
void AddAnimVehicle(const CarlaRecorderAnimVehicle &Vehicle)
CarlaRecorderEventsDel EventsDel
void ProcessReplayerLightVehicle(CarlaRecorderLightVehicle LightVehicle)
bool ProcessReplayerEventDel(uint32_t DatabaseId)
CarlaRecorderLightVehicles LightVehicles
void GetFrameData(UCarlaEpisode *ThisEpisode, bool bAdditionalData=false, bool bIncludeActorsAgain=false)
CarlaRecorderCollisions Collisions
CarlaRecorderWeathers Weathers
std::pair< int, FCarlaActor * > CreateOrReuseActor(FVector &Location, FVector &Rotation, FActorDescription &ActorDesc, uint32_t DesiredId, bool SpawnSensors, std::unordered_map< uint32_t, uint32_t > &MappedId)
void SetActorVelocity(FCarlaActor *CarlaActor, FVector Velocity)
carla::multigpu::MirroredVehicleParts MirrorVehicleParts
bool ProcessReplayerStateTrafficLight(CarlaRecorderStateTrafficLight State)
CarlaRecorderEventsParent EventsParent
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 PlaceMirror(FCarlaActor &CarlaActor, FTransform Transform)
void Write(std::ostream &OutStream)
void ProcessReplayerLightScene(CarlaRecorderLightScene LightScene)
void AddExistingActors(void)
void AddAnimBiker(const CarlaRecorderAnimBiker &Biker)
CarlaRecorderLightScenes LightScenes
void AddVehicleParts(FCarlaActor *CarlaActor)
CarlaRecorderActorTriggerVolumes TriggerVolumes
carla::multigpu::MirroredPositions MirrorPositions
void PlayKinematics(const std::unordered_map< uint32_t, uint32_t > &MappedId)
void PlayWorldState(FMirrorState &MirrorState)
CarlaRecorderAnimBikers Bikers
bool SetActorSimulatePhysics(FCarlaActor *CarlaActor, bool bEnabled)
void AddState(const CarlaRecorderStateTrafficLight &State)
void ProcessReplayerAnimVehicle(CarlaRecorderAnimVehicle Vehicle)
CarlaRecorderActorBoundingBoxes BoundingBoxes
void AddCollision(AActor *Actor1, AActor *Actor2)
void AddLightVehicle(const CarlaRecorderLightVehicle &LightVehicle)
void AddVehicleAnimation(FCarlaActor *CarlaActor)
void AddVehicleLight(FCarlaActor *CarlaActor)
CarlaRecorderTrafficLightTimes TrafficLightTimes
void AddTriggerVolume(const ATrafficSignBase &TrafficSign)
CarlaRecorderAnimVehicles Vehicles
void AddSensorTick(FCarlaActor *CarlaActor)
void PlayAppearances(const std::unordered_map< uint32_t, uint32_t > &MappedId)
void ProcessReplayerAnimBiker(CarlaRecorderAnimBiker Biker)
CarlaRecorderFrameCounter FrameCounter
CarlaRecorderEventsAdd EventsAdd
bool ProcessReplayerEventParent(uint32_t ChildId, uint32_t ParentId, const std::unordered_map< uint32_t, uint32_t > &MappedId)
carla::multigpu::WorldObjects MirrorWorldObjects
void AddActorPosition(FCarlaActor *CarlaActor)
std::optional< carla::multigpu::FrameTime > MultiGpuFrameTime
void AddWalkerAnimation(FCarlaActor *CarlaActor)
void AddActorAppearance(FCarlaActor *CarlaActor, bool bFullResync)
bool SetCameraPosition(uint32_t Id, FVector Offset, FQuat Rotation)
carla::multigpu::SensorStates MirrorSensorStates
void AddTrafficLightTime(const ATrafficLightBase &TrafficLight)
void AddPosition(const CarlaRecorderPosition &Position)
void SetWalkerSpeed(uint32_t ActorId, float Speed)
CarlaRecorderPositions Positions
void PrepareMirroredActor(FCarlaActor *CarlaActor, uint32_t PrimaryActorId)
void AddActorKinematics(FCarlaActor *CarlaActor)
CarlaRecorderPhysicsControls PhysicsControls
carla::multigpu::FrameDataReadResult Read(const uint8_t *Data, size_t Size)
Parses one SEND_FRAME payload.
CarlaRecorderStates States
void ProcessReplayerAnimWalker(CarlaRecorderAnimWalker Walker)
CarlaRecorderActorsKinematics Kinematics
void AddEvent(const CarlaRecorderEventAdd &Event)
FCarlaActor * FindTrafficSignAt(FVector Location)
CarlaRecorderAnimWalkers Walkers
carla::multigpu::ActorAppearances MirrorAppearances
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)
void AddWorldState(bool bFullResync)
void PlayPositions(const std::unordered_map< uint32_t, uint32_t > &MappedId, FMirrorState &MirrorState)
std::optional< carla::multigpu::WorldGlobals > MirrorWorldGlobals
void AddEventLightSceneChanged(const UCarlaLight *Light)
void AddAnimWalker(const CarlaRecorderAnimWalker &Walker)
void AddKinematics(const CarlaRecorderKinematics &ActorKinematics)
void PlayVehicleParts(const std::unordered_map< uint32_t, uint32_t > &MappedId)
void AddTrafficLightState(FCarlaActor *CarlaActor)
carla::multigpu::SensorTicks MirrorSensorTicks
void PlayFrameData(UCarlaEpisode *ThisEpisode, std::unordered_map< uint32_t, uint32_t > &MappedId, FMirrorState &MirrorState, TFunctionRef< void(uint32_t, uint32_t, bool)> OnActorAdded, TFunctionRef< void(uint32_t)> OnActorRemoved)
OnActorAdded receives (primary actor id, local actor id, whether it was just created rather than reus...
void AddBoundingBox(const CarlaRecorderActorBoundingBox &ActorBoundingBox)
FPrimaryWorldState & GetMultiGpuWorldState()
Multi-GPU primary: the world state the frames sent so far carried.
void PutActorToSleep(carla::rpc::ActorId ActorId)
FCarlaActor * FindCarlaActor(FCarlaActor::IdType ActorId)
Find a Carla actor by id.
AWeather * GetWeather() const
TPair< EActorSpawnResultStatus, FCarlaActor * > SpawnActorWithInfo(const FTransform &Transform, FActorDescription thisActorDescription, FCarlaActor::IdType DesiredId=0)
Spawns an actor based on ActorDescription at Transform.
APawn * GetSpectatorPawn() const
void AddRosParentNames(FCarlaActor &Child)
ROS 2: registers the ros_name of each of Child's ancestors as one of its parent frames.
const FActorRegistry & GetActorRegistry() const
bool DestroyActor(AActor *Actor)
std::vector< carla::rpc::LightState > GetLights(FString Client)
bool GetDayTimeState(bool &bOutIsDay) const
The day/night state last broadcast, if any.
void NotifyDayTimeChange(bool bIsDay)
Broadcast a day/night change and then re-apply the UE4->UE5 component intensity conversion on every r...
bool GetDayNightCycle() const
void SetDayNightCycle(const bool active)
UCarlaLight * GetLight(int Id)
static ALargeMapManager * GetLargeMapManager(const UObject *WorldContextObject)
static ACarlaGameModeBase * GetGameMode(const UObject *WorldContextObject)
Maps a controller from OpenDrive.
void SetElapsedTime(float InElapsedTime)
ATrafficLightGroup * GetGroup()
float GetElapsedTime() const
static std::shared_ptr< ROS2 > GetInstance()
Defines the physical appearance of a vehicle whitch is obtained by the sensors.
flag_type light_state
Lights state flag, all turned off by default.
@ Inconsistent
Packets that contradict each other (set by the reader's owner, e.g.
FrameDataReadResult ReadFrameData(const uint8_t *data, std::size_t size, ReadPacket &&read_packet)
Walks the packets of one frame.
ReplayedActorPlan PlanReplayedActor(const MirroredActorMap &mirrors, uint32_t primary_id, const LocalActors &local)
Where a secondary replays the add event of primary actor primary_id.
std::pair< std::vector< uint64_t >, std::vector< uint64_t > > DiffSortedIds(const std::vector< uint64_t > ¤t, const std::vector< uint64_t > &desired)
Ids in desired and not in current (first), and the other way round (second).
constexpr uint8_t kFrameCounterPacketId
Id of the frame counter packet, the last packet of every complete frame.
std::pair< uint16_t, uint16_t > ComputeMapLayerDiff(uint16_t current, uint16_t desired)
The map layers to load and to unload to go from current to desired.
std::vector< uint32_t > OrderParentsFirst(const std::vector< uint32_t > &ids, const std::unordered_map< uint32_t, uint32_t > &parents)
Order in which to place actors so that every parent is placed before its children: by attachment dept...
std::vector< CarlaRecorderActorAttribute > Attributes
void Write(std::ostream &OutFile)
void Read(std::istream &InFile)
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderLightScene &InObj)
VehicleLightStateType State
void Read(std::istream &InFile)
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderLightVehicle &InObj)
FVehiclePhysicsControl VehiclePhysicsControl
float RayleighScatteringScale
float ScatteringIntensity
float PrecipitationDeposits
An actor attribute, may be an intrinsic (non-modifiable) attribute of the actor or an user-defined ac...
A description of a Carla Actor with all its variation.
TMap< FString, FActorAttribute > Variations
User selected variations of the actor.
uint32 UId
UId of the definition in which this description was based.
FString Id
Display ID that identifies the actor.
A view over an actor and its properties.
FActorDescription Description
bool bDeterministicRagdolls
bool bAdjustSignsHeightToGround
float TileStreamingDistance
float ActorActiveDistance
double MaxSubstepDeltaTime
TOptional< double > FixedDeltaSeconds
What a Multi-GPU secondary keeps between the primary frames it plays.
uint64 DisabledObjectsRegistrations
std::vector< std::pair< uint32_t, FTransform > > PlayedPoses
The poses the last frame played set, by local id, to check before the capture that nothing moved a mi...
std::optional< std::vector< uint64_t > > DisabledObjects
The environment objects the primary has disabled (sorted), once a frame said so, and the registration...
std::vector< std::pair< uint32_t, uint32_t > > PendingParents
Attachments not replayed yet, as (child, parent) primary ids: one of the two is not mirrored yet.
std::unordered_set< uint32_t > CreatedIds
Local ids of the mirrors this secondary spawned, as opposed to map actors it reused (traffic lights,...
An actor's appearance, as a Multi-GPU primary last sent it.
What a Multi-GPU primary remembers between the frames it sends, to send the world state only when it ...
uint64 WeatherSerial
AWeather::GetApplySerial() of the weather last sent.
TSet< int32 > ChangedLights
The scene lights changed since the last frame sent, by light id.
uint64 EnvironmentObjectsSerial
ACarlaGameModeBase::GetEnvironmentObjectsSerial() of the set last sent.
std::unordered_map< uint32_t, FMirroredAppearance > Appearances
The appearance last sent, by actor id.
An actor's appearance on the primary that a mirror does not get from its spawn attributes or pose.
std::optional< bool > hidden
std::optional< std::array< double, 3 > > scale
std::optional< bool > collisions
std::vector< ActorAppearance > actors
bool Read(std::istream &in, uint32_t size)
void Write(std::ostream &out) const
static constexpr uint8_t kPacketId
An open door, which on the primary is a physics body of its own: its pose relative to the vehicle,...
std::array< double, 3 > location
std::array< double, 4 > rotation
bool IsComplete() const
Only a complete frame may be played.
std::optional< uint64_t > frame
Value of the frame counter packet, if it was read.
uint8_t packet_id
Id, offset and declared size of the last packet looked at.
Frame data packet 25: the primary's clocks and episode settings for one frame.
bool synchronous_mode
The primary's episode settings after frame N (FEpisodeSettings, in UE units).
bool Read(std::istream &in, uint32_t size)
Reads a payload of size bytes.
double max_substep_delta_time
float tile_streaming_distance
float actor_active_distance
bool adjust_signs_height_to_ground
float max_culling_distance
static constexpr uint8_t kPacketId
bool deterministic_ragdolls
std::optional< double > fixed_delta_seconds
One record of frame data packet 34: an actor's world pose as the primary holds it,...
bool Read(std::istream &in, uint32_t size)
Reads a payload of size bytes; records that grew in a newer build are read up to the fields known her...
void Write(std::ostream &out) const
static constexpr uint8_t kPacketId
std::vector< MirroredPosition > positions
static constexpr uint8_t kPacketId
std::vector< VehicleParts > vehicles
void Write(std::ostream &out) const
bool Read(std::istream &in, uint32_t size)
std::optional< uint32_t > reuse
Local actor to reuse; if empty, spawn a new one.
uint32_t spawn_id
Id to request for the new actor, 0 for a fresh one.
One record of frame data packet 27: the runtime state a sensor of the primary starts this frame's tic...
std::vector< SensorState > states
void Write(std::ostream &out) const
static constexpr uint8_t kPacketId
bool Read(std::istream &in, uint32_t size)
One record of frame data packet 26: a sensor of the primary that ticks in this frame,...
static constexpr uint8_t kPacketId
std::vector< SensorTick > ticks
void Write(std::ostream &out) const
bool Read(std::istream &in, uint32_t size)
A vehicle's moving parts: every wheel, by wheel index, and the doors open (any other door is closed),...
std::vector< DoorPose > open_doors
std::vector< WheelPose > wheels
std::optional< int32_t > current_gear
bool simulating_physics
Whether the primary's body simulates physics (it reports no angular velocity otherwise).
A wheel as the primary draws it: degrees and cm.
Frame data packet 28, on every frame: world-wide state a client can change on the primary that change...
float imu_gravity
The IMU's gravity, m/s^2.
bool publish_tf
ROS 2: whether TF frames are published.
uint16_t map_layers
rpc::MapLayer bits of the layers loaded.
bool Read(std::istream &in, uint32_t size)
static constexpr uint8_t kPacketId
bool day_night_cycle
UCarlaLightSubsystem: whether street lights follow the sun, and the last day/night state it broadcast...
bool Read(std::istream &in, uint32_t size)
void Write(std::ostream &out) const
static constexpr uint8_t kPacketId
std::optional< std::vector< uint64_t > > disabled_environment_objects