26#include <util/ue-header-guard-begin.h>
27#include "Components/BoxComponent.h"
28#include "Components/SkeletalMeshComponent.h"
29#include <util/ue-header-guard-end.h>
36 PrimaryActorTick.TickGroup = TG_PrePhysics;
41 : Super(ObjectInitializer)
43 PrimaryActorTick.TickGroup = TG_PrePhysics;
63 std::string Name,
double TimeStart,
double Duration,
64 uint32_t FollowId,
const FTransform& Offset,
bool ReplaySensors,
bool ReplayWeather,
65 std::string MapOverride)
68 return Replayer.
ReplayFile(Name, TimeStart, Duration, FollowId, Offset, ReplaySensors, ReplayWeather, MapOverride);
104 Super::Tick(DeltaSeconds);
118 for (
auto It = Registry.
begin(); It != Registry.
end(); ++It)
178 PrimaryActorTick.bCanEverTick =
true;
184 PrimaryActorTick.bCanEverTick =
false;
190 check(CarlaActor !=
nullptr);
204 check(CarlaActor !=
nullptr);
227 check(CarlaActor !=
nullptr)
234 if (CarlaVehicle ==
nullptr)
238 if (Movement ==
nullptr)
243 Record.
WheelValues.reserve(Movement->WheelSetups.Num());
247 for (uint8 i = 0; CarlaVehicle->
HasWheel(i); ++i)
263 Movement->GetForwardSpeed(),
264 Movement->GetEngineRotationSpeed() / Movement->GetEngineMaxRotationSpeed()
271 check(CarlaActor !=
nullptr);
287 check(CarlaActor !=
nullptr);
301 static_cast<char>(LightState)
309 check(CarlaActor !=
nullptr);
322 if (LocalCarlaActor !=
nullptr)
334 check(CarlaActor !=
nullptr);
336 FVector Velocity, AngularVelocity;
337 constexpr float TO_METERS = 1e-2;
351 check(CarlaActor !=
nullptr);
357 {Box.Origin, Box.Extent}
377 UBoxComponent* Trigger = Triggers.Top();
378 auto VolumeOrigin = Trigger->GetComponentLocation();
379 auto VolumeExtent = Trigger->GetScaledBoxExtent();
382 CarlaActor->GetActorId(),
383 {VolumeOrigin, VolumeExtent}
396 Control.
DatabaseId = CarlaActor->GetActorId();
409 auto DatabaseId = CarlaActor->GetActorId();
423 check(CarlaActor !=
nullptr);
433 FString Name = Bone.Get<0>();
434 auto Transforms = Bone.Get<1>();
435 FVector Loc = Transforms.Relative.GetTranslation();
436 FVector Rot = Transforms.Relative.GetRotation().Euler();
438 Walker.
Bones.push_back(Entry);
463 File.open(Filename, std::ios::binary);
491 return std::string(Filename);
630 if (FoundActor1 !=
nullptr) {
634 if (RoleName !=
nullptr)
635 Collision.IsActor1Hero = (RoleName->Value ==
"hero");
645 if (FoundActor2 !=
nullptr) {
649 if (RoleName !=
nullptr)
650 Collision.IsActor2Hero = (RoleName->Value ==
"hero");
725 Light->GetLightIntensity(),
726 Light->GetLightColor(),
728 static_cast<uint8
>(Light->GetLightType())
755 for (
auto& It : Registry)
758 if (CarlaActor !=
nullptr)
769 UWorld *World = GetWorld();
773 const auto& Lights = CarlaLightSubsystem->
GetLights();
774 for (
const auto& LightPair : Lights)
776 UCarlaLight* Light = LightPair.Value;
786 if (WeatherActor !=
nullptr)
790 RecorderWeather.
Cloudiness = Params.Cloudiness;
796 RecorderWeather.
FogDensity = Params.FogDensity;
798 RecorderWeather.
FogFalloff = Params.FogFalloff;
799 RecorderWeather.
Wetness = Params.Wetness;
803 RecorderWeather.
DustStorm = Params.DustStorm;
815 Description.
UId = ActorDescription.
UId;
816 Description.
Id = ActorDescription.
Id;
820 for (
const auto &item : ActorDescription.
Variations)
823 Attr.
Type =
static_cast<uint8_t
>(item.Value.Type);
824 Attr.
Id = item.Value.Id;
825 Attr.
Value = item.Value.Value;
827 if (!Attr.
Id.IsEmpty())
829 Description.
Attributes.emplace_back(std::move(Attr));
840 std::move(Description)
std::string GetRecorderFilename(std::string Filename)
EVehicleDoor
Type of door to open/close.
CarlaRecorderEventsAdd EventsAdd
void AddAnimVehicleWheels(const CarlaRecorderAnimWheels &VehicleWheels)
void AddState(const CarlaRecorderStateTrafficLight &State)
void Ticking(float DeltaSeconds)
void AddVehicleWheelsAnimation(FCarlaActor *CarlaActor)
CarlaRecorderTrafficLightTimes TrafficLightTimes
CarlaRecorderPhysicsControls PhysicsControls
void AddExistingWeather(void)
CarlaRecorderLightScenes LightScenes
void AddEvent(const CarlaRecorderEventAdd &Event)
std::string ShowFileCollisions(std::string Name, char Type1, char Type2)
CarlaRecorderAnimBikers Bikers
void AddVehicleDoor(const ACarlaWheeledVehicle &Vehicle, const EVehicleDoor SDoors, bool bIsOpen)
void AddWeather(const CarlaRecorderWeather &Weather)
void StopReplayer(bool KeepActors=false)
std::string ShowFileInfo(std::string Name, bool bShowAll=false)
void AddActorBoundingBox(FCarlaActor *CarlaActor)
void AddTriggerVolume(const ATrafficSignBase &TrafficSign)
void AddActorBones(FCarlaActor *CarlaActor)
void AddVehicleLight(FCarlaActor *CarlaActor)
CarlaRecorderActorBoundingBoxes BoundingBoxes
CarlaRecorderLightVehicles LightVehicles
CarlaRecorderVisualTime VisualTime
void AddEventLightSceneChanged(const UCarlaLight *Light)
void AddKinematics(const CarlaRecorderKinematics &ActorKinematics)
CarlaRecorderWeathers Weathers
CarlaRecorderPlatformTime PlatformTime
CarlaRecorderActorTriggerVolumes TriggerVolumes
void AddExistingActors(void)
std::string ShowFileActorsBlocked(std::string Name, double MinTime=30, double MinDistance=10)
void AddActorKinematics(FCarlaActor *CarlaActor)
std::string ReplayFile(std::string Name, double TimeStart, double Duration, uint32_t FollowId, const FTransform &Offset, bool ReplaySensors, bool ReplayWeather, std::string MapOverride)
void AddCollision(AActor *Actor1, AActor *Actor2)
void SetReplayerIgnoreSpectator(bool IgnoreSpectator)
std::string Start(std::string Name, FString MapName, bool AdditionalData=false, bool StopReplayer=true)
CarlaRecorderWalkersBones WalkersBones
void AddVehicleAnimation(FCarlaActor *CarlaActor)
void SetReplayerIgnoreHero(bool IgnoreHero)
void AddAnimBiker(const CarlaRecorderAnimBiker &Biker)
void AddPhysicsControl(const ACarlaWheeledVehicle &Vehicle)
void AddAnimVehicle(const CarlaRecorderAnimVehicle &Vehicle)
void AddTrafficLightState(FCarlaActor *CarlaActor)
void AddWalkerAnimation(FCarlaActor *CarlaActor)
void AddLightVehicle(const CarlaRecorderLightVehicle &LightVehicle)
void SetReplayerTimeFactor(double TimeFactor)
void AddTrafficLightTime(const ATrafficLightBase &TrafficLight)
void CreateRecorderEventAdd(uint32_t DatabaseId, uint8_t Type, const FTransform &Transform, FActorDescription ActorDescription)
CarlaRecorderEventsParent EventsParent
void AddPosition(const CarlaRecorderPosition &Position)
CarlaRecorderCollisions Collisions
void AddBoundingBox(const CarlaRecorderActorBoundingBox &ActorBoundingBox)
CarlaRecorderActorsKinematics Kinematics
CarlaRecorderPositions Positions
CarlaRecorderAnimWalkers Walkers
CarlaRecorderAnimVehicleWheels Wheels
void AddAnimWalker(const CarlaRecorderAnimWalker &Walker)
CarlaRecorderStates States
void AddDoorVehicle(const CarlaRecorderDoorVehicle &DoorVehicle)
void AddActorPosition(FCarlaActor *CarlaActor)
CarlaRecorderEventsDel EventsDel
void Write(double DeltaSeconds)
CarlaRecorderFrames Frames
CarlaRecorderAnimVehicles Vehicles
CarlaRecorderDoorVehicles DoorVehicles
Base class for CARLA wheeled vehicles.
bool IsTwoWheeledVehicle()
float GetWheelSteerAngle(EVehicleWheelLocation WheelLocation)
float GetWheelPitchAngle(EVehicleWheelLocation WheelLocation)
UChaosWheeledVehicleMovementComponent * GetChaosWheeledVehicleMovementComponent() const
Get chaos wheeled vehicle movement component casted.
bool HasWheel(int32 WheelIndex) const
Class which implements the state changing of traffic lights.
TArray< UBoxComponent * > GetTriggerVolumes() const
const FWeatherParameters & GetCurrentWeather() const
Returns the current WeatherParameters.
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderActorBoundingBox &InObj)
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderActorBoundingBox &InObj)
void Add(const CarlaRecorderKinematics &InObj)
void Write(std::ostream &OutFile)
void Write(std::ostream &OutFile) const
void Add(const CarlaRecorderAnimBiker &InObj)
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderAnimWheels &InObj)
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderAnimVehicle &InObj)
void Add(const CarlaRecorderAnimWalker &InObj)
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderCollision &Collision)
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderEventAdd &Event)
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderEventDel &Event)
void Write(std::ostream &OutFile)
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderEventParent &Event)
void SetFrame(double DeltaSeconds)
void WriteEnd(std::ostream &OutFile)
void WriteStart(std::ostream &OutFile)
void Add(const CarlaRecorderPhysicsControl &InObj)
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderPosition &InObj)
void Write(std::ostream &OutFile)
std::string QueryBlocked(std::string Filename, double MinTime=30, double MinDistance=10)
std::string QueryCollisions(std::string Filename, char Category1='a', char Category2='a')
std::string QueryInfo(std::string Filename, bool bShowAll=false)
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderStateTrafficLight &State)
void Add(const CarlaRecorderTrafficLightTime &InObj)
void Write(std::ostream &OutFile)
void Write(std::ofstream &OutFile)
void Add(const CarlaRecorderWalkerBones &InObj)
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderWeather &InObj)
void SetIgnoreHero(bool InIgnoreHero)
void ForgetSpawnedActors(void)
Forgets the spawned actors, so a later DestroySpawnedActors() leaves them alone.
void SetIgnoreSpectator(bool InIgnoreSpectator)
void SetTimeFactor(double NewTimeFactor)
std::string ReplayFile(std::string Filename, double TimeStart=0.0f, double Duration=0.0f, uint32_t FollowId=0, const FTransform &Offset=FTransform(), bool ReplaySensors=false, bool ReplayWeather=false, std::string MapOverride="")
void DestroySpawnedActors(void)
Destroys the actors this replayer spawned that are still alive, even when the replay already ended by...
void Stop(bool KeepActors=false)
A registry of all the Carla actors.
auto begin() const noexcept
FCarlaActor * FindCarlaActor(IdType Id)
auto end() const noexcept
A view over an actor and its properties.
virtual ECarlaServerResponse GetBonesTransform(FWalkerBoneControlOut &)
ActorType GetActorType() const
FVector GetActorAngularVelocity() const
virtual ECarlaServerResponse GetVehicleLightState(FVehicleLightState &)
FTransform GetActorGlobalTransform() const
virtual FVector GetActorVelocity() const
virtual ECarlaServerResponse GetVehicleControl(FVehicleControl &)
bool IsPendingKill() const
virtual ETrafficLightState GetTrafficLightState() const
virtual UTrafficLightController * GetTrafficLightController()
virtual ECarlaServerResponse GetWalkerControl(FWalkerControl &)
const FActorInfo * GetActorInfo() const
IdType GetActorId() const
double GetVisualGameTime() const
Visual game seconds.
CarlaReplayer * GetReplayer() const
FCarlaActor * FindCarlaActor(FCarlaActor::IdType ActorId)
Find a Carla actor by id.
AWeather * GetWeather() const
const FActorRegistry & GetActorRegistry() const
std::vector< carla::rpc::LightState > GetLights(FString Client)
Maps a controller from OpenDrive.
ATrafficLightGroup * GetGroup()
float GetElapsedTime() const
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.
std::vector< CarlaRecorderActorAttribute > Attributes
std::vector< WheelInfo > WheelValues
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderDoorVehicle &InObj)
void Write(std::ostream &File)
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderLightScene &InObj)
VehicleLightStateType State
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderLightVehicle &InObj)
FVehiclePhysicsControl VehiclePhysicsControl
void Write(std::ofstream &OutFile)
void SetTime(double ThisTime)
std::vector< CarlaRecorderWalkerBone > Bones
float RayleighScatteringScale
float ScatteringIntensity
float PrecipitationDeposits
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.
FActorDescription Description
TMap< FString, FWalkerBoneControlOutData > BoneTransforms
EVehicleWheelLocation Location