A simulation episode. More...
#include <CarlaEpisode.h>
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) |
FCarlaActor * | FindCarlaActor (FCarlaActor::IdType ActorId) |
Find a Carla actor by id. More... | |
FCarlaActor * | FindCarlaActor (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... | |
FString | GetActorDescriptionFromStream (carla::streaming::detail::stream_id_type StreamId) |
Get the description of the Carla actor (sensor) using specific stream id. More... | |
const FActorRegistry & | GetActorRegistry () const |
FActorRegistry & | GetActorRegistry () |
FIntVector | GetCurrentMapOrigin () const |
double | GetElapsedGameTime () const |
Game seconds since the start of this episode. More... | |
FFrameData & | GetFrameData () |
const carla::geom::GeoLocation & | GetGeoReference () 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... | |
ACarlaRecorder * | GetRecorder () const |
CarlaReplayer * | GetReplayer () const |
FSensorManager & | GetSensorManager () |
const FEpisodeSettings & | GetSettings () const |
APawn * | GetSpectatorPawn () const |
double | GetVisualGameTime () const |
Visual game seconds. More... | |
AWeather * | GetWeather () 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) |
AActor * | ReSpawnActorWithInfo (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) |
void | SetVisualGameTime (double Time) |
AActor * | SpawnActor (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) |
Public Attributes | |
bool | bIsPrimaryServer = true |
Private Member Functions | |
void | EndPlay () |
void | InitializeAtBeginPlay () |
void | RegisterActorFactory (ACarlaActorFactory &ActorFactory) |
bool | SetActorCollisions (FCarlaActor &CarlaActor, bool bEnabled) |
bool | SetActorDead (FCarlaActor &CarlaActor) |
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 | |
UActorDispatcher * | ActorDispatcher = nullptr |
FIntVector | CurrentMapOrigin |
double | ElapsedGameTime = 0.0 |
FEpisodeSettings | EpisodeSettings |
FFrameData | FrameData |
const uint64 | Id = 0u |
carla::geom::GeoLocation | MapGeoReference |
FString | MapName |
UMaterialParameterCollectionInstance * | MaterialParameters = nullptr |
ACarlaRecorder * | Recorder = nullptr |
FSensorManager | SensorManager |
APawn * | Spectator = nullptr |
double | VisualGameTime = 0.0 |
AWeather * | Weather = nullptr |
Friends | |
class | ACarlaGameModeBase |
class | FCarlaEngine |
A simulation episode.
Each time the level is restarted a new episode is created.
Definition at line 37 of file CarlaEpisode.h.
UCarlaEpisode::UCarlaEpisode | ( | const FObjectInitializer & | ObjectInitializer | ) |
Definition at line 56 of file CarlaEpisode.cpp.
References ActorDispatcher, FrameData, and FFrameData::SetEpisode().
void UCarlaEpisode::ApplySettings | ( | const FEpisodeSettings & | Settings | ) |
Definition at line 230 of file CarlaEpisode.cpp.
References FEpisodeSettings::ActorActiveDistance, EpisodeSettings, FCarlaStaticDelegates::OnEpisodeSettingsChange, and FEpisodeSettings::TileStreamingDistance.
Referenced by FCarlaServer::FPimpl::BindActions(), LoadNewEpisode(), FCarlaEngine::NotifyBeginEpisode(), and FCarlaEngine::OnPreTick().
void UCarlaEpisode::AttachActors | ( | AActor * | Child, |
AActor * | Parent, | ||
EAttachmentType | InAttachmentType = EAttachmentType::Rigid |
||
) |
Attach Child to Parent.
Definition at line 294 of file CarlaEpisode.cpp.
References FFrameData::AddEvent(), ACarlaRecorder::AddEvent(), UActorAttacher::AttachActors(), bIsPrimaryServer, CurrentMapOrigin, FindCarlaActor(), FCarlaActor::GetActorId(), GetFrameData(), ACarlaRecorder::IsEnabled(), and Recorder.
Referenced by FCarlaServer::FPimpl::BindActions(), CarlaReplayerHelper::ProcessReplayerEventParent(), FFrameData::ProcessReplayerEventParent(), and FActorRegistry::WakeActorUp().
|
inline |
Definition at line 251 of file CarlaEpisode.h.
References FCarlaActor::GetActorId().
Referenced by FCarlaServer::FPimpl::BindActions(), CarlaReplayerHelper::ProcessReplayerEventDel(), and FFrameData::ProcessReplayerEventDel().
|
inline |
Definition at line 262 of file CarlaEpisode.h.
|
private |
Definition at line 405 of file CarlaEpisode.cpp.
References ACarlaRecorder::GetReplayer(), CarlaReplayer::IsEnabled(), Recorder, CarlaReplayer::Stop(), and ACarlaRecorder::Stop().
Referenced by ACarlaGameModeBase::EndPlay().
|
inline |
Find a Carla actor by id.
If the actor is not found or is pending kill, the returned view is invalid.
Definition at line 172 of file CarlaEpisode.h.
Referenced by AttachActors(), FCarlaServer::FPimpl::BindActions(), ALargeMapManager::CheckActiveActors(), ALargeMapManager::CheckDormantActors(), ALargeMapManager::ConvertDormantToActiveActors(), FFrameData::CreateOrReuseActor(), FFrameData::CreateRecorderEventAdd(), ACarlaRecorder::CreateRecorderEventAdd(), ALargeMapManager::OnActorDestroyed(), CarlaReplayerHelper::ProcessReplayerAnimBiker(), FFrameData::ProcessReplayerAnimBiker(), CarlaReplayerHelper::ProcessReplayerAnimVehicle(), FFrameData::ProcessReplayerAnimVehicle(), CarlaReplayerHelper::ProcessReplayerAnimVehicleWheels(), FFrameData::ProcessReplayerAnimVehicleWheels(), CarlaReplayerHelper::ProcessReplayerEventDel(), FFrameData::ProcessReplayerEventDel(), CarlaReplayerHelper::ProcessReplayerEventParent(), FFrameData::ProcessReplayerEventParent(), CarlaReplayerHelper::ProcessReplayerLightVehicle(), FFrameData::ProcessReplayerLightVehicle(), CarlaReplayerHelper::ProcessReplayerPosition(), FFrameData::ProcessReplayerPosition(), CarlaReplayerHelper::ProcessReplayerStateTrafficLight(), FFrameData::ProcessReplayerStateTrafficLight(), CarlaReplayerHelper::ProcessReplayerWalkerBones(), FSparseHighDetailMap::SaveMap(), SerializeActor(), CarlaReplayerHelper::SetCameraPosition(), FFrameData::SetCameraPosition(), CarlaReplayerHelper::SetWalkerSpeed(), FFrameData::SetWalkerSpeed(), and CarlaReplayerHelper::TryToCreateReplayerActor().
|
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 181 of file CarlaEpisode.h.
|
inline |
Return the list of actor definitions that are available to be spawned this episode.
Definition at line 123 of file CarlaEpisode.h.
Referenced by FCarlaServer::FPimpl::BindActions(), and InitializeAtBeginPlay().
|
inline |
Get the description of the Carla actor (sensor) using specific stream id.
If the actor is not found returns an empty string
Definition at line 189 of file CarlaEpisode.h.
Referenced by FCarlaServer::FPimpl::BindActions().
|
inline |
Definition at line 154 of file CarlaEpisode.h.
Referenced by ACarlaRecorder::AddCollision(), FFrameData::AddExistingActors(), ACarlaRecorder::AddExistingActors(), FFrameData::AddPhysicsControl(), ACarlaRecorder::AddPhysicsControl(), FFrameData::AddTrafficLightTime(), ACarlaRecorder::AddTrafficLightTime(), FFrameData::AddTriggerVolume(), ACarlaRecorder::AddTriggerVolume(), FCarlaServer::FPimpl::BindActions(), ARayCastSemanticLidar::ComputeRawDetection(), FFrameData::CreateOrReuseActor(), CarlaReplayerHelper::FindTrafficLightAt(), FFrameData::FindTrafficLightAt(), FWorldObserver_Serialize(), FFrameData::GetFrameData(), ALargeMapManager::OnActorSpawned(), CarlaReplayerHelper::ProcessReplayerFinish(), FFrameData::ProcessReplayerFinish(), ALargeMapManager::RegisterInitialObjects(), ACarlaRecorder::Ticking(), and CarlaReplayerHelper::TryToCreateReplayerActor().
|
inline |
Definition at line 159 of file CarlaEpisode.h.
|
inline |
Definition at line 321 of file CarlaEpisode.h.
Referenced by FWorldObserver_Serialize(), FActorData::GetLocalTransform(), and FActorData::RecordActorData().
|
inline |
Game seconds since the start of this episode.
Definition at line 98 of file CarlaEpisode.h.
Referenced by FWorldObserver::BroadcastTick().
|
inline |
Definition at line 325 of file CarlaEpisode.h.
Referenced by AttachActors(), FCarlaEngine::NotifyInitGame(), FCarlaEngine::OnPostTick(), and SpawnActorWithInfo().
|
inline |
Return the GeoLocation point of the map loaded.
Definition at line 133 of file CarlaEpisode.h.
Referenced by AGnssSensor::BeginPlay().
|
inline |
Return the unique id of this episode.
Definition at line 85 of file CarlaEpisode.h.
Referenced by FCarlaServer::FPimpl::BindActions(), and FWorldObserver_Serialize().
|
inline |
Return the name of the map loaded in this episode.
Definition at line 92 of file CarlaEpisode.h.
Referenced by FCarlaServer::FPimpl::BindActions(), LoadNewEpisode(), FCarlaServer::NotifyBeginEpisode(), and CarlaReplayer::ReplayFile().
TArray< FTransform > UCarlaEpisode::GetRecommendedSpawnPoints | ( | ) | const |
Return the list of recommended spawn points for vehicles.
Definition at line 241 of file CarlaEpisode.cpp.
References UCarlaStatics::GetGameMode(), and ACarlaGameModeBase::GetSpawnPointsTransforms().
Referenced by FCarlaServer::FPimpl::BindActions().
|
inline |
Definition at line 304 of file CarlaEpisode.h.
Referenced by FCarlaServer::FPimpl::BindActions(), ACollisionSensor::OnCollisionEvent(), and FCarlaEngine::OnPostTick().
|
inline |
Definition at line 314 of file CarlaEpisode.h.
Referenced by ACarlaRecorder::Ticking().
|
inline |
Definition at line 327 of file CarlaEpisode.h.
Referenced by ASensor::BeginPlay(), ASensor::EndPlay(), and FCarlaEngine::OnPostTick().
|
inline |
Definition at line 72 of file CarlaEpisode.h.
Referenced by ACarlaGameModeBase::BeginPlay(), and FCarlaServer::FPimpl::BindActions().
|
inline |
Definition at line 143 of file CarlaEpisode.h.
Referenced by FCarlaServer::FPimpl::BindActions(), CarlaReplayerHelper::SetCameraPosition(), and FFrameData::SetCameraPosition().
|
inline |
Visual game seconds.
Definition at line 104 of file CarlaEpisode.h.
Referenced by ACarlaRecorder::Ticking().
|
inline |
Definition at line 149 of file CarlaEpisode.h.
Referenced by ASceneCaptureSensor::BeginPlay(), and FCarlaServer::FPimpl::BindActions().
|
private |
Definition at line 322 of file CarlaEpisode.cpp.
References ActorDispatcher, FActorDescription::Class, Float, GetActorDefinitions(), ATrafficSignBase::GetTrafficSignState(), FActorDescription::Id, MaterialParameters, UActorDispatcher::RegisterActor(), Spectator, String, UCarlaEpisode_GetTrafficSignId(), FActorDescription::UId, and FActorDescription::Variations.
Referenced by ACarlaGameModeBase::BeginPlay().
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 64 of file CarlaEpisode.cpp.
References ApplySettings(), bIsPrimaryServer, carla::client::detail::Get(), UCarlaGameInstance::GetCarlaEngine(), UCarlaStatics::GetGameInstance(), GetMapName(), and FCarlaEngine::GetSecondaryServer().
Referenced by FCarlaServer::FPimpl::BindActions(), and CarlaReplayer::ReplayFile().
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.
Definition at line 147 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().
|
inline |
Definition at line 279 of file CarlaEpisode.h.
Referenced by FCarlaServer::FPimpl::BindActions(), ALargeMapManager::ConvertActiveToDormantActors(), CarlaReplayerHelper::ProcessReplayerEventParent(), and FFrameData::ProcessReplayerEventParent().
|
inlineprivate |
Definition at line 340 of file CarlaEpisode.h.
Referenced by ACarlaGameModeBase::SpawnActorFactories().
|
inline |
Spawns an actor based on ActorDescription at Transform.
Definition at line 212 of file CarlaEpisode.h.
Referenced by FActorData::RespawnActor().
carla::rpc::Actor UCarlaEpisode::SerializeActor | ( | FCarlaActor * | CarlaActor | ) | const |
Create a serializable object describing the actor.
Definition at line 248 of file CarlaEpisode.cpp.
References FCarlaActor::GetActorInfo(), FCarlaActor::GetParent(), carla::rpc::Actor::parent_id, and FActorInfo::SerializedData.
Referenced by FCarlaServer::FPimpl::BindActions(), ACollisionSensor::OnCollisionEvent(), AObstacleDetectionSensor::OnObstacleDetectionEvent(), and SerializeActor().
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 267 of file CarlaEpisode.cpp.
References carla::rpc::Actor::bounding_box, CarlaGetRelevantTagAsString(), carla::rpc::Actor::description, FindCarlaActor(), UBoundingBoxCalculator::GetActorBoundingBox(), ATagger::GetTagsOfTaggedActor(), FActorDescription::Id, carla::rpc::Actor::id, carla::rpc::Actor::semantic_tags, and SerializeActor().
|
private |
|
private |
|
private |
|
inline |
Definition at line 323 of file CarlaEpisode.h.
Referenced by ALargeMapManager::PostWorldOriginOffset().
|
inline |
Definition at line 309 of file CarlaEpisode.h.
Referenced by ACarlaGameModeBase::InitGame(), and FCarlaEngine::NotifyBeginEpisode().
|
inline |
Definition at line 109 of file CarlaEpisode.h.
Referenced by CarlaReplayer::ProcessVisualTime().
|
inline |
Spawns an actor based on ActorDescription at Transform.
To properly despawn an actor created with this function call DestroyActor.
Definition at line 233 of file CarlaEpisode.h.
References Rigid.
Referenced by FTrafficSignData::RespawnActor(), and FTrafficLightData::RespawnActor().
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.
Definition at line 434 of file CarlaEpisode.cpp.
References ActorDispatcher, bIsPrimaryServer, FFrameData::CreateRecorderEventAdd(), ACarlaRecorder::CreateRecorderEventAdd(), GetFrameData(), UCarlaStatics::GetLargeMapManager(), ALargeMapManager::GlobalToLocalTransform(), ACarlaRecorder::IsEnabled(), Recorder, and UActorDispatcher::SpawnActor().
Referenced by FCarlaServer::FPimpl::BindActions(), FFrameData::CreateOrReuseActor(), and CarlaReplayerHelper::TryToCreateReplayerActor().
std::string UCarlaEpisode::StartRecorder | ( | std::string | name, |
bool | AdditionalData | ||
) |
Definition at line 418 of file CarlaEpisode.cpp.
References MapName, Recorder, and ACarlaRecorder::Start().
Referenced by FCarlaServer::FPimpl::BindActions().
|
inlineprivate |
Definition at line 357 of file CarlaEpisode.h.
Referenced by FCarlaEngine::OnPreTick().
|
private |
|
inline |
Definition at line 284 of file CarlaEpisode.h.
Referenced by ALargeMapManager::ConvertDormantToActiveActors().
|
friend |
Definition at line 333 of file CarlaEpisode.h.
|
friend |
Definition at line 334 of file CarlaEpisode.h.
|
private |
Definition at line 378 of file CarlaEpisode.h.
Referenced by InitializeAtBeginPlay(), SpawnActorWithInfo(), and UCarlaEpisode().
bool UCarlaEpisode::bIsPrimaryServer = true |
Definition at line 329 of file CarlaEpisode.h.
Referenced by AttachActors(), LoadNewEpisode(), FCarlaEngine::NotifyBeginEpisode(), and SpawnActorWithInfo().
|
private |
Definition at line 393 of file CarlaEpisode.h.
Referenced by AttachActors().
|
private |
Definition at line 366 of file CarlaEpisode.h.
|
private |
Definition at line 375 of file CarlaEpisode.h.
Referenced by ApplySettings(), and FCarlaEngine::NotifyBeginEpisode().
|
private |
Definition at line 395 of file CarlaEpisode.h.
Referenced by UCarlaEpisode().
|
private |
Definition at line 363 of file CarlaEpisode.h.
|
private |
Definition at line 391 of file CarlaEpisode.h.
Referenced by ACarlaGameModeBase::ParseOpenDrive().
|
private |
Definition at line 372 of file CarlaEpisode.h.
Referenced by UOpenDrive::FindPathToXODRFile(), UOpenDrive::GetXODR(), UOpenDrive::GetXODRByPath(), ACarlaGameModeBase::InitGame(), and StartRecorder().
|
private |
Definition at line 387 of file CarlaEpisode.h.
Referenced by InitializeAtBeginPlay().
|
private |
Definition at line 389 of file CarlaEpisode.h.
Referenced by AttachActors(), EndPlay(), SpawnActorWithInfo(), and StartRecorder().
|
private |
Definition at line 397 of file CarlaEpisode.h.
|
private |
Definition at line 381 of file CarlaEpisode.h.
Referenced by InitializeAtBeginPlay().
|
private |
Definition at line 369 of file CarlaEpisode.h.
|
private |
Definition at line 384 of file CarlaEpisode.h.
Referenced by ACarlaGameModeBase::BeginPlay(), and ACarlaGameModeBase::InitGame().