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... | |
const FActorRegistry & | GetActorRegistry () const |
FActorRegistry & | GetActorRegistry () |
FIntVector | GetCurrentMapOrigin () const |
double | GetElapsedGameTime () const |
Game seconds since the start of this episode. More... | |
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 |
const FEpisodeSettings & | GetSettings () const |
APawn * | GetSpectatorPawn () const |
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) |
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) |
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 | |
UActorDispatcher * | ActorDispatcher = nullptr |
FIntVector | CurrentMapOrigin |
double | ElapsedGameTime = 0.0 |
FEpisodeSettings | EpisodeSettings |
const uint64 | Id = 0u |
carla::geom::GeoLocation | MapGeoReference |
FString | MapName |
ACarlaRecorder * | Recorder = nullptr |
APawn * | Spectator = nullptr |
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 34 of file CarlaEpisode.h.
UCarlaEpisode::UCarlaEpisode | ( | const FObjectInitializer & | ObjectInitializer | ) |
Definition at line 52 of file CarlaEpisode.cpp.
References ActorDispatcher.
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().
void UCarlaEpisode::AttachActors | ( | AActor * | Child, |
AActor * | Parent, | ||
EAttachmentType | InAttachmentType = EAttachmentType::Rigid |
||
) |
Attach Child to Parent.
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().
|
inline |
Definition at line 223 of file CarlaEpisode.h.
References FCarlaActor::GetActorId().
Referenced by FCarlaServer::FPimpl::BindActions(), and CarlaReplayerHelper::ProcessReplayerEventDel().
|
inline |
Definition at line 234 of file CarlaEpisode.h.
|
private |
Definition at line 365 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 152 of file CarlaEpisode.h.
Referenced by AttachActors(), FCarlaServer::FPimpl::BindActions(), ALargeMapManager::CheckActiveActors(), ALargeMapManager::CheckDormantActors(), ALargeMapManager::ConvertDormantToActiveActors(), ACarlaRecorder::CreateRecorderEventAdd(), ALargeMapManager::OnActorDestroyed(), CarlaReplayerHelper::ProcessReplayerAnimVehicle(), CarlaReplayerHelper::ProcessReplayerEventDel(), CarlaReplayerHelper::ProcessReplayerEventParent(), CarlaReplayerHelper::ProcessReplayerLightVehicle(), CarlaReplayerHelper::ProcessReplayerPosition(), CarlaReplayerHelper::ProcessReplayerStateTrafficLight(), SerializeActor(), CarlaReplayerHelper::SetCameraPosition(), CarlaReplayerHelper::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 161 of file CarlaEpisode.h.
|
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().
|
inline |
Definition at line 134 of file CarlaEpisode.h.
Referenced by ACarlaRecorder::AddCollision(), ACarlaRecorder::AddExistingActors(), ACarlaRecorder::AddPhysicsControl(), ACarlaRecorder::AddTrafficLightTime(), ACarlaRecorder::AddTriggerVolume(), FCarlaServer::FPimpl::BindActions(), ARayCastSemanticLidar::ComputeRawDetection(), CarlaReplayerHelper::FindTrafficLightAt(), FWorldObserver_Serialize(), ALargeMapManager::OnActorSpawned(), CarlaReplayerHelper::ProcessReplayerFinish(), ALargeMapManager::RegisterInitialObjects(), ACarlaRecorder::Ticking(), and CarlaReplayerHelper::TryToCreateReplayerActor().
|
inline |
Definition at line 139 of file CarlaEpisode.h.
|
inline |
Definition at line 288 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 95 of file CarlaEpisode.h.
Referenced by FWorldObserver::BroadcastTick().
|
inline |
Return the GeoLocation point of the map loaded.
Definition at line 113 of file CarlaEpisode.h.
Referenced by AGnssSensor::BeginPlay().
|
inline |
Return the unique id of this episode.
Definition at line 82 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 89 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 221 of file CarlaEpisode.cpp.
References UCarlaStatics::GetGameMode(), and ACarlaGameModeBase::GetSpawnPointsTransforms().
Referenced by FCarlaServer::FPimpl::BindActions().
|
inline |
Definition at line 271 of file CarlaEpisode.h.
Referenced by FCarlaServer::FPimpl::BindActions(), ACollisionSensor::OnCollisionEvent(), and FCarlaEngine::OnPostTick().
|
inline |
Definition at line 281 of file CarlaEpisode.h.
Referenced by ACarlaRecorder::Ticking().
|
inline |
Definition at line 69 of file CarlaEpisode.h.
Referenced by FCarlaServer::FPimpl::BindActions().
|
inline |
Definition at line 123 of file CarlaEpisode.h.
Referenced by FCarlaServer::FPimpl::BindActions(), and CarlaReplayerHelper::SetCameraPosition().
|
inline |
Definition at line 129 of file CarlaEpisode.h.
Referenced by ASceneCaptureSensor::BeginPlay(), and FCarlaServer::FPimpl::BindActions().
|
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().
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().
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 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().
|
inline |
Definition at line 246 of file CarlaEpisode.h.
Referenced by FCarlaServer::FPimpl::BindActions(), ALargeMapManager::ConvertActiveToDormantActors(), and CarlaReplayerHelper::ProcessReplayerEventParent().
|
inlineprivate |
Definition at line 301 of file CarlaEpisode.h.
Referenced by ACarlaGameModeBase::SpawnActorFactories().
|
inline |
Spawns an actor based on ActorDescription at Transform.
Definition at line 184 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 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().
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().
|
private |
|
inline |
Definition at line 290 of file CarlaEpisode.h.
Referenced by ALargeMapManager::PostWorldOriginOffset().
|
inline |
Definition at line 276 of file CarlaEpisode.h.
Referenced by ACarlaGameModeBase::InitGame(), and FCarlaEngine::NotifyBeginEpisode().
|
inline |
Spawns an actor based on ActorDescription at Transform.
To properly despawn an actor created with this function call DestroyActor.
Definition at line 205 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 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().
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().
|
inlineprivate |
Definition at line 314 of file CarlaEpisode.h.
Referenced by FCarlaEngine::OnPreTick().
|
private |
|
inline |
Definition at line 251 of file CarlaEpisode.h.
Referenced by ALargeMapManager::ConvertDormantToActiveActors().
|
friend |
Definition at line 294 of file CarlaEpisode.h.
|
friend |
Definition at line 295 of file CarlaEpisode.h.
|
private |
Definition at line 330 of file CarlaEpisode.h.
Referenced by InitializeAtBeginPlay(), SpawnActorWithInfo(), and UCarlaEpisode().
|
private |
Definition at line 342 of file CarlaEpisode.h.
Referenced by AttachActors().
|
private |
Definition at line 321 of file CarlaEpisode.h.
|
private |
Definition at line 327 of file CarlaEpisode.h.
Referenced by ApplySettings(), and FCarlaEngine::NotifyBeginEpisode().
|
private |
Definition at line 319 of file CarlaEpisode.h.
|
private |
Definition at line 340 of file CarlaEpisode.h.
Referenced by ACarlaGameModeBase::ParseOpenDrive().
|
private |
Definition at line 324 of file CarlaEpisode.h.
Referenced by UOpenDrive::FindPathToXODRFile(), UOpenDrive::GetXODR(), UOpenDrive::GetXODRByPath(), ACarlaGameModeBase::InitGame(), and StartRecorder().
|
private |
Definition at line 338 of file CarlaEpisode.h.
Referenced by AttachActors(), EndPlay(), SpawnActorWithInfo(), and StartRecorder().
|
private |
Definition at line 333 of file CarlaEpisode.h.
Referenced by InitializeAtBeginPlay().
|
private |
Definition at line 336 of file CarlaEpisode.h.
Referenced by ACarlaGameModeBase::BeginPlay(), and ACarlaGameModeBase::InitGame().