CARLA
Loading...
Searching...
No Matches
CarlaReplayerHelper.h
Go to the documentation of this file.
1// Copyright (c) 2026 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#pragma once
8
11#include "CarlaRecorderState.h"
21
22#include <unordered_map>
23
24class UCarlaEpisode;
25class FCarlaActor;
26class UPrimitiveComponent;
28
30{
31
32public:
33
34 // set the episode to use
35 void SetEpisode(UCarlaEpisode *ThisEpisode)
36 {
37 Episode = ThisEpisode;
38 }
39
40 // replay event for creating actor
41 std::pair<int, uint32_t> ProcessReplayerEventAdd(
42 FVector Location,
43 FVector Rotation,
45 uint32_t DesiredId,
46 bool bIgnoreHero,
47 bool bIgnoreSpectator,
48 bool ReplaySensors);
49
50 // replay event for removing actor
51 bool ProcessReplayerEventDel(uint32_t DatabaseId);
52
53 // replay event for parenting actors
54 bool ProcessReplayerEventParent(uint32_t ChildId, uint32_t ParentId);
55
56 // reposition actors
57 bool ProcessReplayerPosition(CarlaRecorderPosition Pos1, CarlaRecorderPosition Pos2, double Per, double DeltaTime);
58
59 // replay event for traffic light state
61
62 // set the animation for Vehicles
64
65 // set the animation for Vehicles Wheels, interpolating like the positions;
66 // Travel is how far the vehicle moves forward from Wheels1 to Wheels2, in cm
68 const CarlaRecorderAnimWheels &Wheels1,
69 const CarlaRecorderAnimWheels &Wheels2,
70 double Per,
71 float Travel);
72
73 // set the animation for walkers
75
76 // set the openings and closing of vehicle doors
78
79 // set the animation for bikers
81
82 // set the vehicle light
84
85 // set scene lights
87
88 // set walker bones
90
91 // set weather
93
94 // replay finish
95 bool ProcessReplayerFinish(bool bApplyAutopilot, bool bIgnoreHero, std::unordered_map<uint32_t, bool> &IsHero);
96
97 // set the camera position to follow an actor
98 bool SetCameraPosition(uint32_t Id, FVector Offset, FQuat Rotation);
99
100 // set the velocity of the actor
101 void SetActorVelocity(FCarlaActor *CarlaActor, FVector Velocity);
102
103 // set the animation speed for walkers
104 void SetWalkerSpeed(uint32_t ActorId, float Speed);
105
106 void RemoveStaticProps();
107
108private:
109
111
112 // Collision state of the replayed actors' primitives, restored when the replay finishes.
114 {
115 TWeakObjectPtr<UPrimitiveComponent> Primitive;
118 };
119 TArray<FReplayedPrimitive> ReplayedPrimitives;
120
121 // Keep a replayed actor visible to sensors without letting it push anything or fire overlaps.
123
124 std::pair<int, FCarlaActor*>TryToCreateReplayerActor(
125 FVector &Location,
126 FVector &Rotation,
127 FActorDescription &ActorDesc,
128 uint32_t DesiredId,
129 bool SpawnSensors);
130
132
133 // enable / disable physics for an actor
134 bool SetActorSimulatePhysics(FCarlaActor *CarlaActor, bool bEnabled);
135 // enable / disable autopilot for an actor
136 bool SetActorAutopilot(FCarlaActor *CarlaActor, bool bEnabled, bool bKeepState = false);
137};
void SetWalkerSpeed(uint32_t ActorId, float Speed)
std::pair< int, FCarlaActor * > TryToCreateReplayerActor(FVector &Location, FVector &Rotation, FActorDescription &ActorDesc, uint32_t DesiredId, bool SpawnSensors)
void ProcessReplayerWalkerBones(const CarlaRecorderWalkerBones &Walker)
bool ProcessReplayerFinish(bool bApplyAutopilot, bool bIgnoreHero, std::unordered_map< uint32_t, bool > &IsHero)
void SetActorVelocity(FCarlaActor *CarlaActor, FVector Velocity)
void ProcessReplayerAnimVehicleWheels(const CarlaRecorderAnimWheels &Wheels1, const CarlaRecorderAnimWheels &Wheels2, double Per, float Travel)
void ProcessReplayerLightScene(CarlaRecorderLightScene LightScene)
FCarlaActor * FindTrafficSignAt(FVector Location)
void ProcessReplayerDoorVehicle(CarlaRecorderDoorVehicle DoorVehicle)
void ProcessReplayerAnimWalker(CarlaRecorderAnimWalker Walker)
void SetEpisode(UCarlaEpisode *ThisEpisode)
void MakeReplayedActorQueryOnly(AActor *Actor)
bool ProcessReplayerStateTrafficLight(CarlaRecorderStateTrafficLight State)
TArray< FReplayedPrimitive > ReplayedPrimitives
bool ProcessReplayerEventParent(uint32_t ChildId, uint32_t ParentId)
bool SetActorSimulatePhysics(FCarlaActor *CarlaActor, bool bEnabled)
void ProcessReplayerAnimVehicle(CarlaRecorderAnimVehicle Vehicle)
bool SetActorAutopilot(FCarlaActor *CarlaActor, bool bEnabled, bool bKeepState=false)
bool ProcessReplayerEventDel(uint32_t DatabaseId)
void ProcessReplayerLightVehicle(CarlaRecorderLightVehicle LightVehicle)
std::pair< int, uint32_t > ProcessReplayerEventAdd(FVector Location, FVector Rotation, CarlaRecorderActorDescription Description, uint32_t DesiredId, bool bIgnoreHero, bool bIgnoreSpectator, bool ReplaySensors)
void ProcessReplayerAnimBiker(CarlaRecorderAnimBiker Biker)
bool ProcessReplayerPosition(CarlaRecorderPosition Pos1, CarlaRecorderPosition Pos2, double Per, double DeltaTime)
void ProcessReplayerWeather(const CarlaRecorderWeather &Weather)
bool SetCameraPosition(uint32_t Id, FVector Offset, FQuat Rotation)
A view over an actor and its properties.
Definition CarlaActor.h:25
Euler angles of a rotation in CARLA's / Unreal's left-handed frame: x forward, y right,...
Definition Rotation.h:45
A simulation episode.
TWeakObjectPtr< UPrimitiveComponent > Primitive
A description of a Carla Actor with all its variation.