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 38 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 252 of file CarlaEpisode.h.
References FCarlaActor::GetActorId().
Referenced by FCarlaServer::FPimpl::BindActions(), CarlaReplayerHelper::ProcessReplayerEventDel(), and FFrameData::ProcessReplayerEventDel().
|
inline |
Definition at line 263 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 173 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 182 of file CarlaEpisode.h.
|
inline |
Return the list of actor definitions that are available to be spawned this episode.
Definition at line 124 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 190 of file CarlaEpisode.h.
Referenced by FCarlaServer::FPimpl::BindActions().
|
inline |
Definition at line 155 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 160 of file CarlaEpisode.h.
|
inline |
Definition at line 322 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 99 of file CarlaEpisode.h.
Referenced by FWorldObserver::BroadcastTick().
|
inline |
Definition at line 326 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 134 of file CarlaEpisode.h.
Referenced by AGnssSensor::BeginPlay().
|
inline |
Return the unique id of this episode.
Definition at line 86 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 93 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 305 of file CarlaEpisode.h.
Referenced by FCarlaServer::FPimpl::BindActions(), ACollisionSensor::OnCollisionEvent(), and FCarlaEngine::OnPostTick().
|
inline |
Definition at line 315 of file CarlaEpisode.h.
Referenced by ACarlaRecorder::Ticking().
|
inline |
Definition at line 328 of file CarlaEpisode.h.
Referenced by ASensor::BeginPlay(), ASensor::EndPlay(), and FCarlaEngine::OnPostTick().
|
inline |
Definition at line 73 of file CarlaEpisode.h.
Referenced by ACarlaGameModeBase::BeginPlay(), and FCarlaServer::FPimpl::BindActions().
|
inline |
Definition at line 144 of file CarlaEpisode.h.
Referenced by FCarlaServer::FPimpl::BindActions(), CarlaReplayerHelper::SetCameraPosition(), and FFrameData::SetCameraPosition().
|
inline |
Visual game seconds.
Definition at line 105 of file CarlaEpisode.h.
Referenced by ACarlaRecorder::Ticking().
|
inline |
Definition at line 150 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 280 of file CarlaEpisode.h.
Referenced by FCarlaServer::FPimpl::BindActions(), ALargeMapManager::ConvertActiveToDormantActors(), CarlaReplayerHelper::ProcessReplayerEventParent(), and FFrameData::ProcessReplayerEventParent().
|
inlineprivate |
Definition at line 341 of file CarlaEpisode.h.
Referenced by ACarlaGameModeBase::SpawnActorFactories().
|
inline |
Spawns an actor based on ActorDescription at Transform.
Definition at line 213 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 324 of file CarlaEpisode.h.
Referenced by ALargeMapManager::PostWorldOriginOffset().
|
inline |
Definition at line 310 of file CarlaEpisode.h.
Referenced by ACarlaGameModeBase::InitGame(), and FCarlaEngine::NotifyBeginEpisode().
|
inline |
Definition at line 110 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 234 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 358 of file CarlaEpisode.h.
References carla::ros2::ROS2::GetInstance().
Referenced by FCarlaEngine::OnPreTick().
|
private |
|
inline |
Definition at line 285 of file CarlaEpisode.h.
Referenced by ALargeMapManager::ConvertDormantToActiveActors().
|
friend |
Definition at line 334 of file CarlaEpisode.h.
|
friend |
Definition at line 335 of file CarlaEpisode.h.
|
private |
Definition at line 385 of file CarlaEpisode.h.
Referenced by InitializeAtBeginPlay(), SpawnActorWithInfo(), and UCarlaEpisode().
bool UCarlaEpisode::bIsPrimaryServer = true |
Definition at line 330 of file CarlaEpisode.h.
Referenced by AttachActors(), LoadNewEpisode(), FCarlaEngine::NotifyBeginEpisode(), and SpawnActorWithInfo().
|
private |
Definition at line 400 of file CarlaEpisode.h.
Referenced by AttachActors().
|
private |
Definition at line 373 of file CarlaEpisode.h.
|
private |
Definition at line 382 of file CarlaEpisode.h.
Referenced by ApplySettings(), and FCarlaEngine::NotifyBeginEpisode().
|
private |
Definition at line 402 of file CarlaEpisode.h.
Referenced by UCarlaEpisode().
|
private |
Definition at line 370 of file CarlaEpisode.h.
|
private |
Definition at line 398 of file CarlaEpisode.h.
Referenced by ACarlaGameModeBase::ParseOpenDrive().
|
private |
Definition at line 379 of file CarlaEpisode.h.
Referenced by ACarlaGameModeBase::InitGame(), and StartRecorder().
|
private |
Definition at line 394 of file CarlaEpisode.h.
Referenced by InitializeAtBeginPlay().
|
private |
Definition at line 396 of file CarlaEpisode.h.
Referenced by AttachActors(), EndPlay(), SpawnActorWithInfo(), and StartRecorder().
|
private |
Definition at line 404 of file CarlaEpisode.h.
|
private |
Definition at line 388 of file CarlaEpisode.h.
Referenced by InitializeAtBeginPlay().
|
private |
Definition at line 376 of file CarlaEpisode.h.
|
private |
Definition at line 391 of file CarlaEpisode.h.
Referenced by ACarlaGameModeBase::BeginPlay(), and ACarlaGameModeBase::InitGame().