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);
94 Super::Tick(DeltaSeconds);
108 for (
auto It = Registry.
begin(); It != Registry.
end(); ++It)
168 PrimaryActorTick.bCanEverTick =
true;
174 PrimaryActorTick.bCanEverTick =
false;
180 check(CarlaActor !=
nullptr);
187 Transform.GetLocation(),
188 Transform.GetRotation().Euler()
194 check(CarlaActor !=
nullptr);
217 check(CarlaActor !=
nullptr)
224 if (CarlaVehicle ==
nullptr)
228 if (Movement ==
nullptr)
233 Record.
WheelValues.reserve(Movement->WheelSetups.Num());
237 for (uint8 i = 0; CarlaVehicle->
HasWheel(i); ++i)
253 Movement->GetForwardSpeed(),
254 Movement->GetEngineRotationSpeed() / Movement->GetEngineMaxRotationSpeed()
261 check(CarlaActor !=
nullptr);
277 check(CarlaActor !=
nullptr);
291 static_cast<char>(LightState)
299 check(CarlaActor !=
nullptr);
312 if (LocalCarlaActor !=
nullptr)
324 check(CarlaActor !=
nullptr);
326 FVector Velocity, AngularVelocity;
327 constexpr float TO_METERS = 1e-2;
341 check(CarlaActor !=
nullptr);
347 {Box.Origin, Box.Extent}
367 UBoxComponent* Trigger = Triggers.Top();
368 auto VolumeOrigin = Trigger->GetComponentLocation();
369 auto VolumeExtent = Trigger->GetScaledBoxExtent();
372 CarlaActor->GetActorId(),
373 {VolumeOrigin, VolumeExtent}
386 Control.
DatabaseId = CarlaActor->GetActorId();
399 auto DatabaseId = CarlaActor->GetActorId();
413 check(CarlaActor !=
nullptr);
423 FString Name = Bone.Get<0>();
424 auto Transforms = Bone.Get<1>();
425 FVector Loc = Transforms.Relative.GetTranslation();
426 FVector Rot = Transforms.Relative.GetRotation().Euler();
428 Walker.
Bones.push_back(Entry);
453 File.open(Filename, std::ios::binary);
481 return std::string(Filename);
620 if (FoundActor1 !=
nullptr) {
624 if (RoleName !=
nullptr)
625 Collision.IsActor1Hero = (RoleName->Value ==
"hero");
635 if (FoundActor2 !=
nullptr) {
639 if (RoleName !=
nullptr)
640 Collision.IsActor2Hero = (RoleName->Value ==
"hero");
715 Light->GetLightIntensity(),
716 Light->GetLightColor(),
718 static_cast<uint8
>(Light->GetLightType())
745 for (
auto& It : Registry)
748 if (CarlaActor !=
nullptr)
759 UWorld *World = GetWorld();
763 const auto& Lights = CarlaLightSubsystem->
GetLights();
764 for (
const auto& LightPair : Lights)
766 UCarlaLight* Light = LightPair.Value;
776 if (WeatherActor !=
nullptr)
780 RecorderWeather.
Cloudiness = Params.Cloudiness;
786 RecorderWeather.
FogDensity = Params.FogDensity;
788 RecorderWeather.
FogFalloff = Params.FogFalloff;
789 RecorderWeather.
Wetness = Params.Wetness;
793 RecorderWeather.
DustStorm = Params.DustStorm;
801 const FTransform &Transform,
805 Description.
UId = ActorDescription.
UId;
806 Description.
Id = ActorDescription.
Id;
810 for (
const auto &item : ActorDescription.
Variations)
813 Attr.
Type =
static_cast<uint8_t
>(item.Value.Type);
814 Attr.
Id = item.Value.Id;
815 Attr.
Value = item.Value.Value;
817 if (!Attr.
Id.IsEmpty())
819 Description.
Attributes.emplace_back(std::move(Attr));
828 Transform.GetTranslation(),
829 Transform.GetRotation().Euler(),
830 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 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 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