31#include <util/ue-header-guard-begin.h>
32#include "GameFramework/Pawn.h"
33#include "Materials/MaterialParameterCollectionInstance.h"
34#include <util/ue-header-guard-end.h>
36#include "CarlaEpisode.generated.h"
41UCLASS(BlueprintType, Blueprintable)
61 UFUNCTION(BlueprintCallable)
62 bool LoadNewEpisode(
const FString &MapString,
bool ResetSettings =
true);
68 bool LoadNewOpendriveEpisode(
69 const FString &OpenDriveString,
76 UFUNCTION(BlueprintCallable)
79 return EpisodeSettings;
82 UFUNCTION(BlueprintCallable)
96 UFUNCTION(BlueprintCallable)
100 static bool WaitForPendingNavigationBuild(
double TimeoutSeconds);
104 static void ClearGeneratedWorldFiles();
114 return ElapsedGameTime;
120 return VisualGameTime;
125 VisualGameTime = Time;
128 if (MaterialParameters)
130 MaterialParameters->SetScalarParameterValue(FName(
"VisualTime"), VisualGameTime);
136 UFUNCTION(BlueprintCallable)
139 return ActorDispatcher->GetActorDefinitions();
143 UFUNCTION(BlueprintCallable)
144 TArray<FTransform> GetRecommendedSpawnPoints()
const;
149 return MapGeoProjection;
156 UFUNCTION(BlueprintCallable)
162 UFUNCTION(BlueprintCallable)
170 return ActorDispatcher->GetActorRegistry();
175 return ActorDispatcher->GetActorRegistry();
188 return ActorDispatcher->GetActorRegistry().FindCarlaActor(ActorId);
197 return ActorDispatcher->GetActorRegistry().FindCarlaActor(Actor);
205 return ActorDispatcher->GetActorRegistry().GetDescriptionFromStream(StreamId);
211 return ActorDispatcher->GetActorRegistry().FindCarlaActorFromStream(StreamId);
224 TPair<EActorSpawnResultStatus, FCarlaActor*> SpawnActorWithInfo(
225 const FTransform &Transform,
233 const FTransform &Transform,
236 FTransform NewTransform = Transform;
237 auto result = ActorDispatcher->ReSpawnActor(NewTransform, thisActorDescription);
238 if (Recorder->IsEnabled())
252 UFUNCTION(BlueprintCallable)
254 const FTransform &Transform,
257 return SpawnActorWithInfo(Transform, std::move(ActorDescription)).Value->GetActor();
263 UFUNCTION(BlueprintCallable)
270 UFUNCTION(BlueprintCallable)
277 return DestroyActor(ActorId);
284 if (bIsPrimaryServer)
286 GetFrameData().AddEvent(
289 if (Recorder->IsEnabled())
293 Recorder->AddEvent(std::move(RecEvent));
296 return ActorDispatcher->DestroyActor(ActorId);
309 ActorDispatcher->PutActorToSleep(ActorId,
this);
314 ActorDispatcher->WakeActorUp(ActorId,
this);
344 return Recorder->GetReplayer();
347 std::string StartRecorder(std::string name,
bool AdditionalData,
bool StopReplayer);
361 if (bIsPrimaryServer)
363 MultiGpuWorldState.ChangedLights.Add(LightId);
378 PedestriansCrossFactor = FMath::Clamp(InCrossFactor, 0.0f, 1.0f);
385 PedestriansNavRNG.Initialize(
static_cast<int32
>(InSeed));
391 return PedestriansNavRNG.FRand() < PedestriansCrossFactor;
394 bool bIsPrimaryServer =
true;
402 void InitializeAtBeginPlay();
408 ActorDispatcher->Bind(ActorFactory);
415 unsigned int desiredId);
425 ElapsedGameTime += DeltaSeconds;
426 SetVisualGameTime(VisualGameTime + DeltaSeconds);
427 #if defined(WITH_ROS2)
429 if (ROS2->IsEnabled())
430 ROS2->SetTimestamp(GetElapsedGameTime());
438 void SetTimers(
double InElapsedGameTime,
double InVisualGameTime)
440 ElapsedGameTime = InElapsedGameTime;
441 SetVisualGameTime(InVisualGameTime);
442 #if defined(WITH_ROS2)
444 if (ROS2->IsEnabled())
445 ROS2->SetTimestamp(GetElapsedGameTime());
449 const uint64 Id = 0u;
452 double ElapsedGameTime = 0.0;
455 double VisualGameTime = 0.0;
457 UPROPERTY(VisibleAnywhere)
460 UPROPERTY(VisibleAnywhere)
463 UPROPERTY(VisibleAnywhere)
466 UPROPERTY(VisibleAnywhere)
469 UPROPERTY(VisibleAnywhere)
472 UPROPERTY(VisibleAnywhere)
473 UMaterialParameterCollectionInstance *MaterialParameters =
nullptr;
477 carla::geom::GeoProjection MapGeoProjection;
479 FIntVector CurrentMapOrigin;
481 float PedestriansCrossFactor = 0.0f;
483 FRandomStream PedestriansNavRNG = FRandomStream(0);
493 const TSet<
carla::rpc::CityObjectLabel> &SemanticTags);
FString CarlaGetRelevantTagAsString(const TSet< carla::rpc::CityObjectLabel > &SemanticTags)
Game mode for Autoware maps: when the world settings carry an MGRS data asset, the episode georeferen...
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()
FPrimaryWorldState & GetMultiGpuWorldState()
Multi-GPU primary: the world state the frames sent so far carried.
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)
void SetPedestriansCrossFactor(float InCrossFactor)
Probability that a walker whose navigation starts after this call is a "crosser" (may traverse crossw...
FCarlaActor * FindCarlaActor(FCarlaActor::IdType ActorId)
Find a Carla actor by id.
FCarlaActor * FindCarlaActor(AActor *Actor) const
Find the actor view of Actor.
const FString & GetMapName() const
void SetPedestriansSeed(uint32 InSeed)
Seed the RNG behind the crosser draw (and any future navigation randomness).
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.
void SetTimers(double InElapsedGameTime, double InVisualGameTime)
Multi-GPU secondary: adopt the primary's clocks for the frame being played.
std::pair< int, FCarlaActor & > TryToCreateReplayerActor(FVector &Location, FVector &Rotation, FActorDescription &ActorDesc, unsigned int desiredId)
void MarkSceneLightChanged(int32 LightId)
A scene light changed: Multi-GPU secondaries get its new state.
void TickTimers(float DeltaSeconds)
bool SetActorCollisions(FCarlaActor &CarlaActor, bool bEnabled)
bool SetActorDead(FCarlaActor &CarlaActor)
FCarlaActor * FindCarlaActorFromStream(carla::streaming::detail::stream_id_type StreamId)
Find the Carla actor (sensor) that owns the stream StreamId, or nullptr.
void SetVisualGameTime(double Time)
const FActorRegistry & GetActorRegistry() const
ACarlaRecorder * GetRecorder() const
FSensorManager & GetSensorManager()
bool DrawWalkerIsCrosser()
Draw once per walker at navigation start: crosser or not.
FActorRegistry & GetActorRegistry()
const carla::geom::GeoProjection & GetGeoProjection() const
Return the geo projection of the map loaded.
void WakeActorUp(carla::rpc::ActorId ActorId)
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.
What a Multi-GPU primary remembers between the frames it sends, to send the world state only when it ...
Seting for map generation from opendrive without additional geometry.