19 #include "GameFramework/Pawn.h" 20 #include "Materials/MaterialParameterCollectionInstance.h" 32 #include "CarlaEpisode.generated.h" 37 UCLASS(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(
218 auto result = ActorDispatcher->ReSpawnActor(NewTransform, thisActorDescription);
219 if (Recorder->IsEnabled())
233 UFUNCTION(BlueprintCallable)
238 return SpawnActorWithInfo(
Transform, std::move(ActorDescription)).Value->GetActor();
244 UFUNCTION(BlueprintCallable)
251 UFUNCTION(BlueprintCallable)
258 return DestroyActor(ActorId);
265 if (bIsPrimaryServer)
267 GetFrameData().AddEvent(
270 if (Recorder->IsEnabled())
274 Recorder->AddEvent(std::move(RecEvent));
277 return ActorDispatcher->DestroyActor(ActorId);
282 ActorDispatcher->PutActorToSleep(ActorId,
this);
287 ActorDispatcher->WakeActorUp(ActorId,
this);
317 return Recorder->GetReplayer();
320 std::string StartRecorder(std::string name,
bool AdditionalData);
330 bool bIsPrimaryServer =
true;
337 void InitializeAtBeginPlay();
343 ActorDispatcher->Bind(ActorFactory);
346 std::pair<int, FCarlaActor&> TryToCreateReplayerActor(
350 unsigned int desiredId);
352 bool SetActorSimulatePhysics(
FCarlaActor &CarlaActor,
bool bEnabled);
354 bool SetActorCollisions(
FCarlaActor &CarlaActor,
bool bEnabled);
360 ElapsedGameTime += DeltaSeconds;
361 SetVisualGameTime(VisualGameTime + DeltaSeconds);
362 #if defined(WITH_ROS2) 364 if (ROS2->IsEnabled())
365 ROS2->SetTimestamp(GetElapsedGameTime());
370 const uint64 Id = 0u;
373 double ElapsedGameTime = 0.0;
376 double VisualGameTime = 0.0;
378 UPROPERTY(VisibleAnywhere)
381 UPROPERTY(VisibleAnywhere)
384 UPROPERTY(VisibleAnywhere)
387 UPROPERTY(VisibleAnywhere)
390 UPROPERTY(VisibleAnywhere)
393 UPROPERTY(VisibleAnywhere)
394 UMaterialParameterCollectionInstance *MaterialParameters =
nullptr;
398 carla::geom::GeoLocation MapGeoReference;
400 FIntVector CurrentMapOrigin;
Base class for Carla actor factories.
FCarlaActor * FindCarlaActor(FCarlaActor::IdType ActorId)
Find a Carla actor by id.
CarlaReplayer * GetReplayer() const
Seting for map generation from opendrive without additional geometry.
FActorRegistry & GetActorRegistry()
FCarlaActor * FindCarlaActor(AActor *Actor) const
Find the actor view of Actor.
A registry of all the Carla actors.
FSensorManager & GetSensorManager()
bool DestroyActor(carla::rpc::ActorId ActorId)
double GetElapsedGameTime() const
Game seconds since the start of this episode.
Object in charge of binding ActorDefinitions to spawn functions, as well as keeping the registry of a...
void WakeActorUp(carla::rpc::ActorId ActorId)
This file contains definitions of common data structures used in traffic manager. ...
void PutActorToSleep(carla::rpc::ActorId ActorId)
A definition of a Carla Actor with all the variation and attributes.
const FActorRegistry & GetActorRegistry() const
carla::SharedPtr< cc::Actor > Actor
Recorder for the simulation.
ACarlaRecorder * Recorder
auto GetId() const
Return the unique id of this episode.
A description of a Carla Actor with all its variation.
FIntVector GetCurrentMapOrigin() const
FString CarlaGetRelevantTagAsString(const TSet< crp::CityObjectLabel > &SemanticTags)
void RegisterActorFactory(ACarlaActorFactory &ActorFactory)
ACarlaRecorder * GetRecorder() const
void SetCurrentMapOrigin(const FIntVector &NewOrigin)
FString GetActorDescriptionFromStream(carla::streaming::detail::stream_id_type StreamId)
Get the description of the Carla actor (sensor) using specific stream id.
void SetRecorder(ACarlaRecorder *Rec)
FFrameData & GetFrameData()
const carla::geom::GeoLocation & GetGeoReference() const
Return the GeoLocation point of the map loaded.
Base class for the CARLA Game Mode.
static std::shared_ptr< ROS2 > GetInstance()
IdType GetActorId() const
void SetVisualGameTime(double Time)
AActor * ReSpawnActorWithInfo(const FTransform &Transform, FActorDescription thisActorDescription)
Spawns an actor based on ActorDescription at Transform.
geom::Transform Transform
double GetVisualGameTime() const
Visual game seconds.
void TickTimers(float DeltaSeconds)
A view over an actor and its properties.