19#include "GameFramework/Pawn.h"
20#include "Materials/MaterialParameterCollectionInstance.h"
32#include "CarlaEpisode.generated.h"
37UCLASS(BlueprintType, Blueprintable)
57 UFUNCTION(BlueprintCallable)
58 bool LoadNewEpisode(
const FString &MapString,
bool ResetSettings =
true);
64 bool LoadNewOpendriveEpisode(
65 const FString &OpenDriveString,
72 UFUNCTION(BlueprintCallable)
75 return EpisodeSettings;
78 UFUNCTION(BlueprintCallable)
92 UFUNCTION(BlueprintCallable)
93 const FString &GetMapName()
const
101 return ElapsedGameTime;
107 return VisualGameTime;
112 VisualGameTime = Time;
115 if (MaterialParameters)
117 MaterialParameters->SetScalarParameterValue(FName(
"VisualTime"), VisualGameTime);
123 UFUNCTION(BlueprintCallable)
126 return ActorDispatcher->GetActorDefinitions();
130 UFUNCTION(BlueprintCallable)
131 TArray<FTransform> GetRecommendedSpawnPoints()
const;
136 return MapGeoReference;
143 UFUNCTION(BlueprintCallable)
149 UFUNCTION(BlueprintCallable)
157 return ActorDispatcher->GetActorRegistry();
162 return ActorDispatcher->GetActorRegistry();
175 return ActorDispatcher->GetActorRegistry().FindCarlaActor(ActorId);
184 return ActorDispatcher->GetActorRegistry().FindCarlaActor(Actor);
192 return ActorDispatcher->GetActorRegistry().GetDescriptionFromStream(StreamId);
205 TPair<EActorSpawnResultStatus, FCarlaActor*> SpawnActorWithInfo(
206 const FTransform &Transform,
214 const FTransform &Transform,
217 FTransform NewTransform = Transform;
218 auto result = ActorDispatcher->ReSpawnActor(NewTransform, thisActorDescription);
219 if (Recorder->IsEnabled())
233 UFUNCTION(BlueprintCallable)
235 const FTransform &Transform,
238 return SpawnActorWithInfo(Transform, std::move(ActorDescription)).Value->GetActor();
244 UFUNCTION(BlueprintCallable)
249 const FString& SocketName =
"");
252 UFUNCTION(BlueprintCallable)
259 return DestroyActor(ActorId);
266 if (bIsPrimaryServer)
268 GetFrameData().AddEvent(
271 if (Recorder->IsEnabled())
275 Recorder->AddEvent(std::move(RecEvent));
278 return ActorDispatcher->DestroyActor(ActorId);
283 ActorDispatcher->PutActorToSleep(ActorId,
this);
288 ActorDispatcher->WakeActorUp(ActorId,
this);
318 return Recorder->GetReplayer();
321 std::string StartRecorder(std::string name,
bool AdditionalData);
331 bool bIsPrimaryServer =
true;
338 void InitializeAtBeginPlay();
344 ActorDispatcher->Bind(ActorFactory);
351 unsigned int desiredId);
361 ElapsedGameTime += DeltaSeconds;
362 SetVisualGameTime(VisualGameTime + DeltaSeconds);
363 #if defined(WITH_ROS2)
365 if (ROS2->IsEnabled())
366 ROS2->SetTimestamp(GetElapsedGameTime());
371 const uint64 Id = 0u;
374 double ElapsedGameTime = 0.0;
377 double VisualGameTime = 0.0;
379 UPROPERTY(VisibleAnywhere)
382 UPROPERTY(VisibleAnywhere)
385 UPROPERTY(VisibleAnywhere)
388 UPROPERTY(VisibleAnywhere)
391 UPROPERTY(VisibleAnywhere)
394 UPROPERTY(VisibleAnywhere)
395 UMaterialParameterCollectionInstance *MaterialParameters =
nullptr;
399 carla::geom::GeoLocation MapGeoReference;
401 FIntVector CurrentMapOrigin;
FString CarlaGetRelevantTagAsString(const TSet< crp::CityObjectLabel > &SemanticTags)
Base class for Carla actor factories.
Base class for the CARLA Game Mode.
Recorder for the simulation
A registry of all the Carla actors.
A view over an actor and its properties.
IdType GetActorId() const
ACarlaRecorder * Recorder
Object in charge of binding ActorDefinitions to spawn functions, as well as keeping the registry of a...
FIntVector GetCurrentMapOrigin() const
auto GetId() const
Return the unique id of this episode.
FFrameData & GetFrameData()
double GetVisualGameTime() const
Visual game seconds
bool SetActorSimulatePhysics(FCarlaActor &CarlaActor, bool bEnabled)
CarlaReplayer * GetReplayer() const
void PutActorToSleep(carla::rpc::ActorId ActorId)
void SetCurrentMapOrigin(const FIntVector &NewOrigin)
FCarlaActor * FindCarlaActor(FCarlaActor::IdType ActorId)
Find a Carla actor by id.
FCarlaActor * FindCarlaActor(AActor *Actor) const
Find the actor view of Actor.
void RegisterActorFactory(ACarlaActorFactory &ActorFactory)
double GetElapsedGameTime() const
Game seconds since the start of this episode.
FString GetActorDescriptionFromStream(carla::streaming::detail::stream_id_type StreamId)
Get the description of the Carla actor (sensor) using specific stream id.
bool DestroyActor(carla::rpc::ActorId ActorId)
void SetRecorder(ACarlaRecorder *Rec)
AActor * ReSpawnActorWithInfo(const FTransform &Transform, FActorDescription thisActorDescription)
Spawns an actor based on ActorDescription at Transform.
std::pair< int, FCarlaActor & > TryToCreateReplayerActor(FVector &Location, FVector &Rotation, FActorDescription &ActorDesc, unsigned int desiredId)
void TickTimers(float DeltaSeconds)
bool SetActorCollisions(FCarlaActor &CarlaActor, bool bEnabled)
bool SetActorDead(FCarlaActor &CarlaActor)
void SetVisualGameTime(double Time)
const FActorRegistry & GetActorRegistry() const
ACarlaRecorder * GetRecorder() const
FSensorManager & GetSensorManager()
FActorRegistry & GetActorRegistry()
void WakeActorUp(carla::rpc::ActorId ActorId)
const carla::geom::GeoLocation & GetGeoReference() const
Return the GeoLocation point of the map loaded
static std::shared_ptr< ROS2 > GetInstance()
This file contains definitions of common data structures used in traffic manager.
A definition of a Carla Actor with all the variation and attributes.
A description of a Carla Actor with all its variation.
Seting for map generation from opendrive without additional geometry