CARLA
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
UCarlaEpisode Class Reference

A simulation episode. More...

#include <CarlaEpisode.h>

+ Inheritance diagram for UCarlaEpisode:
+ Collaboration diagram for UCarlaEpisode:

Public Member Functions

void ApplySettings (const FEpisodeSettings &Settings)
 
void AttachActors (AActor *Child, AActor *Parent, EAttachmentType InAttachmentType=EAttachmentType::Rigid)
 Attach Child to Parent. More...
 
bool DestroyActor (AActor *Actor)
 
bool DestroyActor (carla::rpc::ActorId ActorId)
 
FCarlaActorFindCarlaActor (FCarlaActor::IdType ActorId)
 Find a Carla actor by id. More...
 
FCarlaActorFindCarlaActor (AActor *Actor) const
 Find the actor view of Actor. More...
 
const TArray< FActorDefinition > & GetActorDefinitions () const
 Return the list of actor definitions that are available to be spawned this episode. More...
 
const FActorRegistryGetActorRegistry () const
 
FActorRegistryGetActorRegistry ()
 
FIntVector GetCurrentMapOrigin () const
 
double GetElapsedGameTime () const
 Game seconds since the start of this episode. More...
 
const carla::geom::GeoLocationGetGeoReference () const
 Return the GeoLocation point of the map loaded. More...
 
auto GetId () const
 Return the unique id of this episode. More...
 
const FString & GetMapName () const
 Return the name of the map loaded in this episode. More...
 
TArray< FTransform > GetRecommendedSpawnPoints () const
 Return the list of recommended spawn points for vehicles. More...
 
ACarlaRecorderGetRecorder () const
 
CarlaReplayerGetReplayer () const
 
const FEpisodeSettingsGetSettings () const
 
APawnGetSpectatorPawn () const
 
AWeatherGetWeather () const
 
bool LoadNewEpisode (const FString &MapString, bool ResetSettings=true)
 Load a new map and start a new episode. More...
 
bool LoadNewOpendriveEpisode (const FString &OpenDriveString, const carla::rpc::OpendriveGenerationParameters &Params)
 Load a new map generating the mesh from OpenDRIVE data and start a new episode. More...
 
void PutActorToSleep (carla::rpc::ActorId ActorId)
 
AActorReSpawnActorWithInfo (const FTransform &Transform, FActorDescription thisActorDescription)
 Spawns an actor based on ActorDescription at Transform. More...
 
carla::rpc::Actor SerializeActor (FCarlaActor *CarlaActor) const
 Create a serializable object describing the actor. More...
 
carla::rpc::Actor SerializeActor (AActor *Actor) const
 Create a serializable object describing the actor. More...
 
void SetCurrentMapOrigin (const FIntVector &NewOrigin)
 
void SetRecorder (ACarlaRecorder *Rec)
 
AActorSpawnActor (const FTransform &Transform, FActorDescription ActorDescription)
 Spawns an actor based on ActorDescription at Transform. More...
 
TPair< EActorSpawnResultStatus, FCarlaActor * > SpawnActorWithInfo (const FTransform &Transform, FActorDescription thisActorDescription, FCarlaActor::IdType DesiredId=0)
 Spawns an actor based on ActorDescription at Transform. More...
 
std::string StartRecorder (std::string name, bool AdditionalData)
 
 UCarlaEpisode (const FObjectInitializer &ObjectInitializer)
 
void WakeActorUp (carla::rpc::ActorId ActorId)
 

Private Member Functions

void EndPlay ()
 
void InitializeAtBeginPlay ()
 
void RegisterActorFactory (ACarlaActorFactory &ActorFactory)
 
bool SetActorSimulatePhysics (FCarlaActor &CarlaActor, bool bEnabled)
 
void TickTimers (float DeltaSeconds)
 
std::pair< int, FCarlaActor & > TryToCreateReplayerActor (FVector &Location, FVector &Rotation, FActorDescription &ActorDesc, unsigned int desiredId)
 

Private Attributes

UActorDispatcherActorDispatcher = nullptr
 
FIntVector CurrentMapOrigin
 
double ElapsedGameTime = 0.0
 
FEpisodeSettings EpisodeSettings
 
const uint64 Id = 0u
 
carla::geom::GeoLocation MapGeoReference
 
FString MapName
 
ACarlaRecorderRecorder = nullptr
 
APawnSpectator = nullptr
 
AWeatherWeather = nullptr
 

Friends

class ACarlaGameModeBase
 
class FCarlaEngine
 

Detailed Description

A simulation episode.

Each time the level is restarted a new episode is created.

Definition at line 34 of file CarlaEpisode.h.

Constructor & Destructor Documentation

◆ UCarlaEpisode()

UCarlaEpisode::UCarlaEpisode ( const FObjectInitializer &  ObjectInitializer)

Definition at line 52 of file CarlaEpisode.cpp.

References ActorDispatcher.

Member Function Documentation

◆ ApplySettings()

void UCarlaEpisode::ApplySettings ( const FEpisodeSettings Settings)

Definition at line 210 of file CarlaEpisode.cpp.

References FEpisodeSettings::ActorActiveDistance, EpisodeSettings, FCarlaStaticDelegates::OnEpisodeSettingsChange, and FEpisodeSettings::TileStreamingDistance.

Referenced by FCarlaServer::FPimpl::BindActions(), LoadNewEpisode(), and FCarlaEngine::NotifyBeginEpisode().

+ Here is the caller graph for this function:

◆ AttachActors()

void UCarlaEpisode::AttachActors ( AActor Child,
AActor Parent,
EAttachmentType  InAttachmentType = EAttachmentType::Rigid 
)

Attach Child to Parent.

Precondition
Actors cannot be null.

Definition at line 276 of file CarlaEpisode.cpp.

References ACarlaRecorder::AddEvent(), UActorAttacher::AttachActors(), CurrentMapOrigin, FindCarlaActor(), FCarlaActor::GetActorId(), ACarlaRecorder::IsEnabled(), and Recorder.

Referenced by FCarlaServer::FPimpl::BindActions(), CarlaReplayerHelper::ProcessReplayerEventParent(), and FActorRegistry::WakeActorUp().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DestroyActor() [1/2]

bool UCarlaEpisode::DestroyActor ( AActor Actor)
inline

Definition at line 223 of file CarlaEpisode.h.

References FCarlaActor::GetActorId().

Referenced by FCarlaServer::FPimpl::BindActions(), and CarlaReplayerHelper::ProcessReplayerEventDel().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DestroyActor() [2/2]

bool UCarlaEpisode::DestroyActor ( carla::rpc::ActorId  ActorId)
inline

Definition at line 234 of file CarlaEpisode.h.

◆ EndPlay()

void UCarlaEpisode::EndPlay ( void  )
private

Definition at line 365 of file CarlaEpisode.cpp.

References ACarlaRecorder::GetReplayer(), CarlaReplayer::IsEnabled(), Recorder, CarlaReplayer::Stop(), and ACarlaRecorder::Stop().

Referenced by ACarlaGameModeBase::EndPlay().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FindCarlaActor() [1/2]

FCarlaActor* UCarlaEpisode::FindCarlaActor ( FCarlaActor::IdType  ActorId)
inline

◆ FindCarlaActor() [2/2]

FCarlaActor* UCarlaEpisode::FindCarlaActor ( AActor Actor) const
inline

Find the actor view of Actor.

If the actor is not found or is pending kill, the returned view is invalid.

Definition at line 161 of file CarlaEpisode.h.

◆ GetActorDefinitions()

const TArray<FActorDefinition>& UCarlaEpisode::GetActorDefinitions ( ) const
inline

Return the list of actor definitions that are available to be spawned this episode.

Definition at line 103 of file CarlaEpisode.h.

Referenced by FCarlaServer::FPimpl::BindActions(), and InitializeAtBeginPlay().

+ Here is the caller graph for this function:

◆ GetActorRegistry() [1/2]

const FActorRegistry& UCarlaEpisode::GetActorRegistry ( ) const
inline

◆ GetActorRegistry() [2/2]

FActorRegistry& UCarlaEpisode::GetActorRegistry ( )
inline

Definition at line 139 of file CarlaEpisode.h.

◆ GetCurrentMapOrigin()

FIntVector UCarlaEpisode::GetCurrentMapOrigin ( ) const
inline

Definition at line 288 of file CarlaEpisode.h.

Referenced by FWorldObserver_Serialize(), FActorData::GetLocalTransform(), and FActorData::RecordActorData().

+ Here is the caller graph for this function:

◆ GetElapsedGameTime()

double UCarlaEpisode::GetElapsedGameTime ( ) const
inline

Game seconds since the start of this episode.

Definition at line 95 of file CarlaEpisode.h.

Referenced by FWorldObserver::BroadcastTick().

+ Here is the caller graph for this function:

◆ GetGeoReference()

const carla::geom::GeoLocation& UCarlaEpisode::GetGeoReference ( ) const
inline

Return the GeoLocation point of the map loaded.

Definition at line 113 of file CarlaEpisode.h.

Referenced by AGnssSensor::BeginPlay().

+ Here is the caller graph for this function:

◆ GetId()

auto UCarlaEpisode::GetId ( ) const
inline

Return the unique id of this episode.

Definition at line 82 of file CarlaEpisode.h.

Referenced by FCarlaServer::FPimpl::BindActions(), and FWorldObserver_Serialize().

+ Here is the caller graph for this function:

◆ GetMapName()

const FString& UCarlaEpisode::GetMapName ( ) const
inline

Return the name of the map loaded in this episode.

Definition at line 89 of file CarlaEpisode.h.

Referenced by FCarlaServer::FPimpl::BindActions(), LoadNewEpisode(), FCarlaServer::NotifyBeginEpisode(), and CarlaReplayer::ReplayFile().

+ Here is the caller graph for this function:

◆ GetRecommendedSpawnPoints()

TArray< FTransform > UCarlaEpisode::GetRecommendedSpawnPoints ( ) const

Return the list of recommended spawn points for vehicles.

Definition at line 221 of file CarlaEpisode.cpp.

References UCarlaStatics::GetGameMode(), and ACarlaGameModeBase::GetSpawnPointsTransforms().

Referenced by FCarlaServer::FPimpl::BindActions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetRecorder()

ACarlaRecorder* UCarlaEpisode::GetRecorder ( ) const
inline

Definition at line 271 of file CarlaEpisode.h.

Referenced by FCarlaServer::FPimpl::BindActions(), ACollisionSensor::OnCollisionEvent(), and FCarlaEngine::OnPostTick().

+ Here is the caller graph for this function:

◆ GetReplayer()

CarlaReplayer* UCarlaEpisode::GetReplayer ( ) const
inline

Definition at line 281 of file CarlaEpisode.h.

Referenced by ACarlaRecorder::Ticking().

+ Here is the caller graph for this function:

◆ GetSettings()

const FEpisodeSettings& UCarlaEpisode::GetSettings ( ) const
inline

Definition at line 69 of file CarlaEpisode.h.

Referenced by FCarlaServer::FPimpl::BindActions().

+ Here is the caller graph for this function:

◆ GetSpectatorPawn()

APawn* UCarlaEpisode::GetSpectatorPawn ( ) const
inline

Definition at line 123 of file CarlaEpisode.h.

Referenced by FCarlaServer::FPimpl::BindActions(), and CarlaReplayerHelper::SetCameraPosition().

+ Here is the caller graph for this function:

◆ GetWeather()

AWeather* UCarlaEpisode::GetWeather ( ) const
inline

Definition at line 129 of file CarlaEpisode.h.

Referenced by ASceneCaptureSensor::BeginPlay(), and FCarlaServer::FPimpl::BindActions().

+ Here is the caller graph for this function:

◆ InitializeAtBeginPlay()

void UCarlaEpisode::InitializeAtBeginPlay ( )
private

Definition at line 297 of file CarlaEpisode.cpp.

References ActorDispatcher, FActorDescription::Class, Float, GetActorDefinitions(), ATrafficSignBase::GetTrafficSignState(), FActorDescription::Id, UActorDispatcher::RegisterActor(), Spectator, String, UCarlaEpisode_GetTrafficSignId(), FActorDescription::UId, and FActorDescription::Variations.

Referenced by ACarlaGameModeBase::BeginPlay().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LoadNewEpisode()

bool UCarlaEpisode::LoadNewEpisode ( const FString &  MapString,
bool  ResetSettings = true 
)

Load a new map and start a new episode.

If MapString is empty, the current map is reloaded.

Definition at line 59 of file CarlaEpisode.cpp.

References ApplySettings(), carla::client::detail::Get(), and GetMapName().

Referenced by FCarlaServer::FPimpl::BindActions(), and CarlaReplayer::ReplayFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LoadNewOpendriveEpisode()

bool UCarlaEpisode::LoadNewOpendriveEpisode ( const FString &  OpenDriveString,
const carla::rpc::OpendriveGenerationParameters Params 
)

Load a new map generating the mesh from OpenDRIVE data and start a new episode.

If MapString is empty, it fails.

Todo:
this can take too long to finish, clients need a method to know if the navigation is available or not.

Definition at line 127 of file CarlaEpisode.cpp.

References BuildRecastBuilderFile(), carla::rpc::OpendriveGenerationParameters::enable_pedestrian_navigation, carla::client::detail::Get(), UCarlaStatics::GetGameInstance(), carla::opendrive::OpenDriveParser::Load(), carla::log_warning(), UCarlaGameInstance::SetOpendriveGenerationParameters(), and carla::rpc::OpendriveGenerationParameters::vertex_distance.

Referenced by FCarlaServer::FPimpl::BindActions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PutActorToSleep()

void UCarlaEpisode::PutActorToSleep ( carla::rpc::ActorId  ActorId)
inline

Definition at line 246 of file CarlaEpisode.h.

Referenced by FCarlaServer::FPimpl::BindActions(), ALargeMapManager::ConvertActiveToDormantActors(), and CarlaReplayerHelper::ProcessReplayerEventParent().

+ Here is the caller graph for this function:

◆ RegisterActorFactory()

void UCarlaEpisode::RegisterActorFactory ( ACarlaActorFactory ActorFactory)
inlineprivate

Definition at line 301 of file CarlaEpisode.h.

Referenced by ACarlaGameModeBase::SpawnActorFactories().

+ Here is the caller graph for this function:

◆ ReSpawnActorWithInfo()

AActor* UCarlaEpisode::ReSpawnActorWithInfo ( const FTransform &  Transform,
FActorDescription  thisActorDescription 
)
inline

Spawns an actor based on ActorDescription at Transform.

Returns
the actor to be spawned

Definition at line 184 of file CarlaEpisode.h.

Referenced by FActorData::RespawnActor().

+ Here is the caller graph for this function:

◆ SerializeActor() [1/2]

carla::rpc::Actor UCarlaEpisode::SerializeActor ( FCarlaActor CarlaActor) const

Create a serializable object describing the actor.

Definition at line 228 of file CarlaEpisode.cpp.

References FCarlaActor::GetActorInfo(), FCarlaActor::GetParent(), GetRelevantTagAsString(), carla::rpc::Actor::parent_id, and FActorInfo::SerializedData.

Referenced by FCarlaServer::FPimpl::BindActions(), ACollisionSensor::OnCollisionEvent(), AObstacleDetectionSensor::OnObstacleDetectionEvent(), and SerializeActor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SerializeActor() [2/2]

carla::rpc::Actor UCarlaEpisode::SerializeActor ( AActor Actor) const

Create a serializable object describing the actor.

Can be used to serialized actors that are not in the registry

Definition at line 249 of file CarlaEpisode.cpp.

References carla::rpc::Actor::bounding_box, carla::rpc::Actor::description, FindCarlaActor(), UBoundingBoxCalculator::GetActorBoundingBox(), GetRelevantTagAsString(), ATagger::GetTagsOfTaggedActor(), FActorDescription::Id, carla::rpc::Actor::id, carla::rpc::Actor::semantic_tags, and SerializeActor().

+ Here is the call graph for this function:

◆ SetActorSimulatePhysics()

bool UCarlaEpisode::SetActorSimulatePhysics ( FCarlaActor CarlaActor,
bool  bEnabled 
)
private

◆ SetCurrentMapOrigin()

void UCarlaEpisode::SetCurrentMapOrigin ( const FIntVector &  NewOrigin)
inline

Definition at line 290 of file CarlaEpisode.h.

Referenced by ALargeMapManager::PostWorldOriginOffset().

+ Here is the caller graph for this function:

◆ SetRecorder()

void UCarlaEpisode::SetRecorder ( ACarlaRecorder Rec)
inline

Definition at line 276 of file CarlaEpisode.h.

Referenced by ACarlaGameModeBase::InitGame(), and FCarlaEngine::NotifyBeginEpisode().

+ Here is the caller graph for this function:

◆ SpawnActor()

AActor* UCarlaEpisode::SpawnActor ( const FTransform &  Transform,
FActorDescription  ActorDescription 
)
inline

Spawns an actor based on ActorDescription at Transform.

To properly despawn an actor created with this function call DestroyActor.

Returns
nullptr on failure.
Note
Special overload for blueprints.

Definition at line 205 of file CarlaEpisode.h.

References Rigid.

Referenced by FTrafficSignData::RespawnActor(), and FTrafficLightData::RespawnActor().

+ Here is the caller graph for this function:

◆ SpawnActorWithInfo()

TPair< EActorSpawnResultStatus, FCarlaActor * > UCarlaEpisode::SpawnActorWithInfo ( const FTransform &  Transform,
FActorDescription  thisActorDescription,
FCarlaActor::IdType  DesiredId = 0 
)

Spawns an actor based on ActorDescription at Transform.

To properly despawn an actor created with this function call DestroyActor.

Returns
A pair containing the result of the spawn function and a view over the actor and its properties. If the status is different of Success the view is invalid.

Definition at line 394 of file CarlaEpisode.cpp.

References ActorDispatcher, ACarlaRecorder::CreateRecorderEventAdd(), UCarlaStatics::GetLargeMapManager(), ALargeMapManager::GlobalToLocalTransform(), ACarlaRecorder::IsEnabled(), Recorder, and UActorDispatcher::SpawnActor().

Referenced by FCarlaServer::FPimpl::BindActions(), and CarlaReplayerHelper::TryToCreateReplayerActor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ StartRecorder()

std::string UCarlaEpisode::StartRecorder ( std::string  name,
bool  AdditionalData 
)

Definition at line 378 of file CarlaEpisode.cpp.

References MapName, Recorder, and ACarlaRecorder::Start().

Referenced by FCarlaServer::FPimpl::BindActions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ TickTimers()

void UCarlaEpisode::TickTimers ( float  DeltaSeconds)
inlineprivate

Definition at line 314 of file CarlaEpisode.h.

Referenced by FCarlaEngine::OnPreTick().

+ Here is the caller graph for this function:

◆ TryToCreateReplayerActor()

std::pair<int, FCarlaActor&> UCarlaEpisode::TryToCreateReplayerActor ( FVector &  Location,
FVector &  Rotation,
FActorDescription ActorDesc,
unsigned int  desiredId 
)
private

◆ WakeActorUp()

void UCarlaEpisode::WakeActorUp ( carla::rpc::ActorId  ActorId)
inline

Definition at line 251 of file CarlaEpisode.h.

Referenced by ALargeMapManager::ConvertDormantToActiveActors().

+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ ACarlaGameModeBase

friend class ACarlaGameModeBase
friend

Definition at line 294 of file CarlaEpisode.h.

◆ FCarlaEngine

friend class FCarlaEngine
friend

Definition at line 295 of file CarlaEpisode.h.

Member Data Documentation

◆ ActorDispatcher

UActorDispatcher* UCarlaEpisode::ActorDispatcher = nullptr
private

Definition at line 330 of file CarlaEpisode.h.

Referenced by InitializeAtBeginPlay(), SpawnActorWithInfo(), and UCarlaEpisode().

◆ CurrentMapOrigin

FIntVector UCarlaEpisode::CurrentMapOrigin
private

Definition at line 342 of file CarlaEpisode.h.

Referenced by AttachActors().

◆ ElapsedGameTime

double UCarlaEpisode::ElapsedGameTime = 0.0
private

Definition at line 321 of file CarlaEpisode.h.

◆ EpisodeSettings

FEpisodeSettings UCarlaEpisode::EpisodeSettings
private

Definition at line 327 of file CarlaEpisode.h.

Referenced by ApplySettings(), and FCarlaEngine::NotifyBeginEpisode().

◆ Id

const uint64 UCarlaEpisode::Id = 0u
private

Definition at line 319 of file CarlaEpisode.h.

◆ MapGeoReference

carla::geom::GeoLocation UCarlaEpisode::MapGeoReference
private

Definition at line 340 of file CarlaEpisode.h.

Referenced by ACarlaGameModeBase::ParseOpenDrive().

◆ MapName

FString UCarlaEpisode::MapName
private

◆ Recorder

ACarlaRecorder* UCarlaEpisode::Recorder = nullptr
private

Definition at line 338 of file CarlaEpisode.h.

Referenced by AttachActors(), EndPlay(), SpawnActorWithInfo(), and StartRecorder().

◆ Spectator

APawn* UCarlaEpisode::Spectator = nullptr
private

Definition at line 333 of file CarlaEpisode.h.

Referenced by InitializeAtBeginPlay().

◆ Weather

AWeather* UCarlaEpisode::Weather = nullptr
private

Definition at line 336 of file CarlaEpisode.h.

Referenced by ACarlaGameModeBase::BeginPlay(), and ACarlaGameModeBase::InitGame().


The documentation for this class was generated from the following files: