19 #include "Components/BoxComponent.h" 20 #include "Components/SkeletalMeshComponent.h" 21 #include "VehicleAnimInstance.h" 35 PrimaryActorTick.TickGroup = TG_PrePhysics;
40 : Super(ObjectInitializer)
42 PrimaryActorTick.TickGroup = TG_PrePhysics;
62 uint32_t FollowId,
bool ReplaySensors)
91 Super::Tick(DeltaSeconds);
105 for (
auto It = Registry.
begin(); It != Registry.
end(); ++It)
158 PrimaryActorTick.bCanEverTick =
true;
164 PrimaryActorTick.bCanEverTick =
false;
170 check(CarlaActor !=
nullptr);
177 Transform.GetLocation(),
178 Transform.GetRotation().Euler()
184 check(CarlaActor !=
nullptr);
207 check(CarlaActor !=
nullptr)
214 if (CarlaVehicle ==
nullptr)
217 USkeletalMeshComponent* SkeletalMesh = CarlaVehicle->GetMesh();
218 if (SkeletalMesh ==
nullptr)
221 UVehicleAnimInstance* VehicleAnim = Cast<UVehicleAnimInstance>(SkeletalMesh->GetAnimInstance());
222 if (VehicleAnim ==
nullptr)
225 const UWheeledVehicleMovementComponent* WheeledVehicleMovementComponent = VehicleAnim->GetWheeledVehicleMovementComponent();
226 if (WheeledVehicleMovementComponent ==
nullptr)
231 Record.
WheelValues.reserve(WheeledVehicleMovementComponent->Wheels.Num());
234 for (
auto Wheel : WheeledVehicleMovementComponent->Wheels)
251 WheeledVehicleMovementComponent->GetForwardSpeed(),
252 WheeledVehicleMovementComponent->GetEngineRotationSpeed() / WheeledVehicleMovementComponent->GetEngineMaxRotationSpeed()
259 check(CarlaActor !=
nullptr);
275 check(CarlaActor !=
nullptr);
289 static_cast<char>(LightState)
297 check(CarlaActor !=
nullptr);
309 check(CarlaActor !=
nullptr);
311 FVector Velocity, AngularVelocity;
312 constexpr
float TO_METERS = 1e-2;
326 check(CarlaActor !=
nullptr);
347 UBoxComponent* Trigger = Triggers.Top();
348 auto VolumeOrigin = Trigger->GetComponentLocation();
349 auto VolumeExtent = Trigger->GetScaledBoxExtent();
353 {VolumeOrigin, VolumeExtent}
387 check(CarlaActor !=
nullptr);
397 FString Name = Bone.Get<0>();
398 auto Transforms = Bone.Get<1>();
399 FVector Loc = Transforms.Relative.GetTranslation();
400 FVector Rot = Transforms.Relative.GetRotation().Euler();
402 Walker.
Bones.push_back(Entry);
423 File.open(Filename, std::ios::binary);
448 return std::string(Filename);
575 if (FoundActor1 !=
nullptr) {
590 if (FoundActor2 !=
nullptr) {
662 Light->GetLightIntensity(),
663 Light->GetLightColor(),
665 static_cast<uint8
>(Light->GetLightType())
692 for (
auto& It : Registry)
695 if (CarlaActor !=
nullptr)
706 UWorld *World = GetWorld();
710 const auto& Lights = CarlaLightSubsystem->
GetLights();
711 for (
const auto& LightPair : Lights)
713 UCarlaLight* Light = LightPair.Value;
727 Description.
UId = ActorDescription.
UId;
728 Description.
Id = ActorDescription.
Id;
732 for (
const auto &item : ActorDescription.
Variations)
735 Attr.
Type =
static_cast<uint8_t
>(item.Value.Type);
736 Attr.
Id = item.Value.Id;
737 Attr.
Value = item.Value.Value;
739 if (!Attr.
Id.IsEmpty())
741 Description.
Attributes.emplace_back(std::move(Attr));
750 Transform.GetTranslation(),
751 Transform.GetRotation().Euler(),
752 std::move(Description)
void AddEventLightSceneChanged(const UCarlaLight *Light)
FCarlaActor * FindCarlaActor(FCarlaActor::IdType ActorId)
Find a Carla actor by id.
bool IsTwoWheeledVehicle()
CarlaReplayer * GetReplayer() const
CarlaRecorderTrafficLightTimes TrafficLightTimes
CarlaRecorderFrames Frames
void Add(const CarlaRecorderAnimVehicle &InObj)
CarlaRecorderAnimVehicles Vehicles
auto end() const noexcept
std::vector< carla::rpc::LightState > GetLights(FString Client)
void Add(const CarlaRecorderAnimBiker &InObj)
void SetTimeFactor(double NewTimeFactor)
void StopReplayer(bool KeepActors=false)
A registry of all the Carla actors.
CarlaRecorderPlatformTime PlatformTime
void Add(const CarlaRecorderPosition &InObj)
void AddAnimBiker(const CarlaRecorderAnimBiker &Biker)
std::string Start(std::string Name, FString MapName, bool AdditionalData=false)
void Write(std::ostream &OutFile)
FVehiclePhysicsControl GetVehiclePhysicsControl() const
CarlaRecorderAnimVehicleWheels Wheels
TArray< UBoxComponent * > GetTriggerVolumes() const
FVector GetActorAngularVelocity() const
virtual ETrafficLightState GetTrafficLightState() const
std::string ShowFileCollisions(std::string Name, char Type1, char Type2)
virtual ECarlaServerResponse GetWalkerControl(FWalkerControl &)
void Write(std::ostream &OutFile)
CarlaRecorderLightScenes LightScenes
void Add(const CarlaRecorderCollision &Collision)
void AddAnimVehicle(const CarlaRecorderAnimVehicle &Vehicle)
TMap< FString, FWalkerBoneControlOutData > BoneTransforms
void Add(const CarlaRecorderAnimWheels &InObj)
CarlaRecorderAnimWalkers Walkers
void Write(std::ostream &OutFile)
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderLightScene &InObj)
void Add(const CarlaRecorderTrafficLightTime &InObj)
void AddBoundingBox(const CarlaRecorderActorBoundingBox &ActorBoundingBox)
auto begin() const noexcept
void SetIgnoreHero(bool InIgnoreHero)
void SetReplayerTimeFactor(double TimeFactor)
void AddAnimWalker(const CarlaRecorderAnimWalker &Walker)
void Write(std::ofstream &OutFile)
void AddActorBoundingBox(FCarlaActor *CarlaActor)
Class which implements the state changing of traffic lights.
std::string ShowFileActorsBlocked(std::string Name, double MinTime=30, double MinDistance=10)
void Write(std::ostream &File)
float GetGreenTime() const
void Add(const CarlaRecorderEventAdd &Event)
void AddVehicleLight(FCarlaActor *CarlaActor)
void AddEvent(const CarlaRecorderEventAdd &Event)
void Add(const CarlaRecorderStateTrafficLight &State)
void AddWalkerAnimation(FCarlaActor *CarlaActor)
std::string QueryBlocked(std::string Filename, double MinTime=30, double MinDistance=10)
CarlaRecorderVisualTime VisualTime
void AddVehicleWheelsAnimation(FCarlaActor *CarlaActor)
EVehicleWheelLocation Location
CarlaRecorderWalkersBones WalkersBones
void Write(std::ostream &OutFile)
CarlaRecorderActorBoundingBoxes BoundingBoxes
bg::model::box< Point3D > Box
void AddKinematics(const CarlaRecorderKinematics &ActorKinematics)
void AddActorKinematics(FCarlaActor *CarlaActor)
void AddTrafficLightTime(const ATrafficLightBase &TrafficLight)
CarlaRecorderPhysicsControls PhysicsControls
CarlaRecorderLightVehicles LightVehicles
void Add(const CarlaRecorderPhysicsControl &InObj)
std::string QueryCollisions(std::string Filename, char Category1='a', char Category2='a')
CarlaRecorderAnimBikers Bikers
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderLightVehicle &InObj)
void Write(std::ostream &OutFile)
void AddCollision(AActor *Actor1, AActor *Actor2)
const FActorRegistry & GetActorRegistry() const
void CreateRecorderEventAdd(uint32_t DatabaseId, uint8_t Type, const FTransform &Transform, FActorDescription ActorDescription)
TMap< FString, FActorAttribute > Variations
User selected variations of the actor.
void Write(std::ostream &OutFile)
CarlaRecorderEventsParent EventsParent
void Add(const CarlaRecorderActorBoundingBox &InObj)
void Add(const CarlaRecorderKinematics &InObj)
void Write(std::ostream &OutFile)
void Write(std::ostream &OutFile)
float GetElapsedTime() const
std::string ReplayFile(std::string Name, double TimeStart, double Duration, uint32_t FollowId, bool ReplaySensors)
void AddActorBones(FCarlaActor *CarlaActor)
void Write(std::ostream &OutFile)
void Write(std::ostream &OutFile)
std::string QueryInfo(std::string Filename, bool bShowAll=false)
virtual ECarlaServerResponse GetBonesTransform(FWalkerBoneControlOut &)
void SetFrame(double DeltaSeconds)
std::vector< CarlaRecorderActorAttribute > Attributes
CarlaRecorderEventsAdd EventsAdd
CarlaRecorderCollisions Collisions
FString Id
Display ID that identifies the actor.
void Write(std::ofstream &OutFile)
void AddPosition(const CarlaRecorderPosition &Position)
void SetTime(double ThisTime)
float GetWheelSteerAngle(EVehicleWheelLocation WheelLocation)
A description of a Carla Actor with all its variation.
FVector GetActorVelocity() const
FActorDescription Description
void SetReplayerIgnoreHero(bool IgnoreHero)
void Write(std::ostream &OutFile)
const FActorInfo * GetActorInfo() const
void AddTrafficLightState(FCarlaActor *CarlaActor)
void Add(const CarlaRecorderWalkerBones &InObj)
bool IsPendingKill() const
void AddExistingActors(void)
void Ticking(float DeltaSeconds)
float GetYellowTime() const
VehicleLightStateType State
std::string ReplayFile(std::string Filename, double TimeStart=0.0f, double Duration=0.0f, uint32_t FollowId=0, bool ReplaySensors=false)
void SetReplayerIgnoreSpectator(bool IgnoreSpectator)
CarlaRecorderActorsKinematics Kinematics
void WriteStart(std::ostream &OutFile)
void AddVehicleAnimation(FCarlaActor *CarlaActor)
void Write(std::ostream &OutFile)
virtual UTrafficLightController * GetTrafficLightController()
std::string ShowFileInfo(std::string Name, bool bShowAll=false)
CarlaRecorderPositions Positions
void WriteEnd(std::ostream &OutFile)
FTransform GetActorGlobalTransform() const
uint32 UId
UId of the definition in which this description was based.
CarlaRecorderActorTriggerVolumes TriggerVolumes
std::string GetRecorderFilename(std::string Filename)
CarlaRecorderEventsDel EventsDel
virtual ECarlaServerResponse GetVehicleLightState(FVehicleLightState &)
virtual ECarlaServerResponse GetVehicleControl(FVehicleControl &)
void Stop(bool KeepActors=false)
IdType GetActorId() const
void Add(const CarlaRecorderEventParent &Event)
void Add(const CarlaRecorderAnimWalker &InObj)
FCarlaActor * FindCarlaActor(IdType Id)
void AddAnimVehicleWheels(const CarlaRecorderAnimWheels &VehicleWheels)
void AddActorPosition(FCarlaActor *CarlaActor)
void AddLightVehicle(const CarlaRecorderLightVehicle &LightVehicle)
ATrafficLightGroup * GetGroup()
std::vector< WheelInfo > WheelValues
void Add(const CarlaRecorderActorBoundingBox &InObj)
void Add(const CarlaRecorderEventDel &Event)
flag_type light_state
Lights state flag, all turned off by default.
Base class for CARLA wheeled vehicles.
Maps a controller from OpenDrive.
Defines the physical appearance of a vehicle whitch is obtained by the sensors.
void Write(std::ostream &OutFile)
void SetIgnoreSpectator(bool InIgnoreSpectator)
CarlaRecorderStates States
void AddPhysicsControl(const ACarlaWheeledVehicle &Vehicle)
std::vector< CarlaRecorderWalkerBone > Bones
void Write(std::ostream &OutFile)
geom::Transform Transform
FVehiclePhysicsControl VehiclePhysicsControl
void Write(double DeltaSeconds)
void AddTriggerVolume(const ATrafficSignBase &TrafficSign)
void AddState(const CarlaRecorderStateTrafficLight &State)
double GetVisualGameTime() const
Visual game seconds.
ActorType GetActorType() const
A view over an actor and its properties.
void Write(std::ostream &OutFile) const