CARLA
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
ASensor Class Reference

Base class for sensors. More...

#include <Sensor.h>

+ Inheritance diagram for ASensor:
+ Collaboration diagram for ASensor:

Public Member Functions

 ASensor (const FObjectInitializer &ObjectInitializer)
 
virtual void BeginPlay ()
 
boost::optional< FActorAttributeGetAttribute (const FString Name)
 
const UCarlaEpisodeGetEpisode () const
 
URandomEngineGetRandomEngine ()
 
int32 GetSeed () const
 
auto GetToken () const
 Return the token that allows subscribing to this sensor's stream. More...
 
bool IsStreamReady ()
 
FDataStream MoveDataStream ()
 
virtual void OnFirstClientConnected ()
 
virtual void OnLastClientDisconnected ()
 
virtual void PostPhysTick (UWorld *World, ELevelTick TickType, float DeltaSeconds)
 
void PostPhysTickInternal (UWorld *World, ELevelTick TickType, float DeltaSeconds)
 
virtual void PrePhysTick (float DeltaSeconds)
 
virtual void Set (const FActorDescription &Description)
 
void SetDataStream (FDataStream InStream)
 Replace the FDataStream associated with this sensor. More...
 
void SetEpisode (const UCarlaEpisode &InEpisode)
 
void SetSeed (int32 InSeed)
 
void Tick (const float DeltaTime) final
 

Protected Member Functions

void EndPlay (EEndPlayReason::Type EndPlayReason) override
 
template<typename SensorT >
FAsyncDataStream GetDataStream (const SensorT &Self)
 Return the FDataStream associated with this sensor. More...
 
void PostActorCreated () override
 

Protected Attributes

bool bIsActive = false
 
URandomEngineRandomEngine = nullptr
 Random Engine used to provide noise for sensor output. More...
 
int32 Seed = 123456789
 Seed of the pseudo-random engine. More...
 

Private Attributes

bool bClientsListening = false
 
const UCarlaEpisodeEpisode = nullptr
 
FDelegateHandle OnPostTickDelegate
 
bool ReadyToTick = false
 Allows the sensor to tick with the tick rate from UE4. More...
 
FActorDescription SensorDescription
 
FDataStream Stream
 

Detailed Description

Base class for sensors.

Definition at line 23 of file Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/Sensor.h.

Constructor & Destructor Documentation

◆ ASensor()

ASensor::ASensor ( const FObjectInitializer &  ObjectInitializer)

Definition at line 17 of file Sensor.cpp.

Member Function Documentation

◆ BeginPlay()

void ASensor::BeginPlay ( )
virtual

Reimplemented in ASceneCaptureSensor, AInertialMeasurementUnit, AGnssSensor, ARadar, and ASceneCaptureCamera.

Definition at line 27 of file Sensor.cpp.

References Episode, UCarlaStatics::GetCurrentEpisode(), UCarlaEpisode::GetSensorManager(), and FSensorManager::RegisterSensor().

+ Here is the call graph for this function:

◆ EndPlay()

void ASensor::EndPlay ( EEndPlayReason::Type  EndPlayReason)
overrideprotected

Definition at line 113 of file Sensor.cpp.

References FSensorManager::DeRegisterSensor(), Episode, UCarlaStatics::GetCurrentEpisode(), GetEpisode(), UCarlaStatics::GetGameInstance(), UCarlaEpisode::GetSensorManager(), FDataStreamTmpl< T >::GetToken(), and Stream.

+ Here is the call graph for this function:

◆ GetAttribute()

boost::optional< FActorAttribute > ASensor::GetAttribute ( const FString  Name)

Definition at line 49 of file Sensor.cpp.

References SensorDescription, and FActorDescription::Variations.

Referenced by ADVSCamera::PostPhysTick().

+ Here is the caller graph for this function:

◆ GetDataStream()

template<typename SensorT >
FAsyncDataStream ASensor::GetDataStream ( const SensorT &  Self)
inlineprotected

Return the FDataStream associated with this sensor.

You need to provide a reference to self, this is necessary for template deduction.

Definition at line 110 of file Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/Sensor.h.

Referenced by ACollisionSensor::OnCollisionEvent(), AObstacleDetectionSensor::OnObstacleDetectionEvent(), AGnssSensor::PostPhysTick(), AInertialMeasurementUnit::PostPhysTick(), ARayCastLidar::PostPhysTick(), ARayCastSemanticLidar::PostPhysTick(), ARadar::PostPhysTick(), and ADVSCamera::PostPhysTick().

+ Here is the caller graph for this function:

◆ GetEpisode()

const UCarlaEpisode& ASensor::GetEpisode ( ) const
inline

Definition at line 93 of file Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/Sensor.h.

Referenced by ASceneCaptureSensor::BeginPlay(), ARayCastSemanticLidar::ComputeRawDetection(), EndPlay(), ACollisionSensor::OnCollisionEvent(), AObstacleDetectionSensor::OnObstacleDetectionEvent(), and ADVSCamera::Simulation().

+ Here is the caller graph for this function:

◆ GetRandomEngine()

URandomEngine* ASensor::GetRandomEngine ( )
inline

Definition at line 79 of file Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/Sensor.h.

Referenced by UActorBlueprintFunctionLibrary::SetGnss(), UActorBlueprintFunctionLibrary::SetIMU(), and UActorBlueprintFunctionLibrary::SetRadar().

+ Here is the caller graph for this function:

◆ GetSeed()

int32 ASensor::GetSeed ( ) const
inline

◆ GetToken()

auto ASensor::GetToken ( ) const
inline

Return the token that allows subscribing to this sensor's stream.

Definition at line 56 of file Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/Sensor.h.

Referenced by FActorRegistry::GetDescriptionFromStream(), ACollisionSensor::OnCollisionEvent(), AObstacleDetectionSensor::OnObstacleDetectionEvent(), AGnssSensor::PostPhysTick(), AInertialMeasurementUnit::PostPhysTick(), ARayCastLidar::PostPhysTick(), ARayCastSemanticLidar::PostPhysTick(), ARadar::PostPhysTick(), and ADVSCamera::PostPhysTick().

+ Here is the caller graph for this function:

◆ IsStreamReady()

bool ASensor::IsStreamReady ( )
inline

Definition at line 61 of file Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/Sensor.h.

Referenced by AObstacleDetectionSensor::OnObstacleDetectionEvent().

+ Here is the caller graph for this function:

◆ MoveDataStream()

FDataStream ASensor::MoveDataStream ( )
inline

Definition at line 50 of file Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/Sensor.h.

Referenced by FActorSensorData::RecordActorData().

+ Here is the caller graph for this function:

◆ OnFirstClientConnected()

virtual void ASensor::OnFirstClientConnected ( )
inlinevirtual

Reimplemented in ASceneCaptureCamera.

Definition at line 71 of file Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/Sensor.h.

Referenced by Tick().

+ Here is the caller graph for this function:

◆ OnLastClientDisconnected()

virtual void ASensor::OnLastClientDisconnected ( )
inlinevirtual

Reimplemented in ASceneCaptureCamera.

Definition at line 73 of file Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/Sensor.h.

Referenced by Tick().

+ Here is the caller graph for this function:

◆ PostActorCreated()

void ASensor::PostActorCreated ( )
overrideprotected

Definition at line 94 of file Sensor.cpp.

◆ PostPhysTick()

virtual void ASensor::PostPhysTick ( UWorld *  World,
ELevelTick  TickType,
float  DeltaSeconds 
)
inlinevirtual

Reimplemented in ASceneCaptureSensor, ADVSCamera, ARadar, ARayCastSemanticLidar, ARayCastLidar, AInertialMeasurementUnit, AGnssSensor, ASceneCaptureCamera, AInstanceSegmentationCamera, AObstacleDetectionSensor, ADepthCamera, ANormalsCamera, ASemanticSegmentationCamera, and AOpticalFlowCamera.

Definition at line 69 of file Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/Sensor.h.

Referenced by PostPhysTickInternal().

+ Here is the caller graph for this function:

◆ PostPhysTickInternal()

void ASensor::PostPhysTickInternal ( UWorld *  World,
ELevelTick  TickType,
float  DeltaSeconds 
)

Definition at line 131 of file Sensor.cpp.

References PostPhysTick(), and ReadyToTick.

+ Here is the call graph for this function:

◆ PrePhysTick()

virtual void ASensor::PrePhysTick ( float  DeltaSeconds)
inlinevirtual

Reimplemented in ASceneCaptureSensor.

Definition at line 68 of file Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/Sensor.h.

Referenced by Tick().

+ Here is the caller graph for this function:

◆ Set()

void ASensor::Set ( const FActorDescription Description)
virtual

Reimplemented in ASceneCaptureSensor, AShaderBasedSensor, ADVSCamera, ARayCastSemanticLidar, ARayCastLidar, AGnssSensor, AInertialMeasurementUnit, ARadar, and AObstacleDetectionSensor.

Definition at line 35 of file Sensor.cpp.

References UActorBlueprintFunctionLibrary::ActorAttributeToFloat(), SensorDescription, and FActorDescription::Variations.

Referenced by ARayCastLidar::Set().

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

◆ SetDataStream()

void ASensor::SetDataStream ( FDataStream  InStream)
inline

Replace the FDataStream associated with this sensor.

Warning
Do not change the stream after BeginPlay. It is not thread-safe.

Definition at line 45 of file Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/Sensor.h.

Referenced by FActorSensorData::RestoreActorData().

+ Here is the caller graph for this function:

◆ SetEpisode()

void ASensor::SetEpisode ( const UCarlaEpisode InEpisode)
inline

◆ SetSeed()

void ASensor::SetSeed ( int32  InSeed)

Definition at line 87 of file Sensor.cpp.

References RandomEngine, URandomEngine::Seed(), and Seed.

Referenced by ARayCastLidar::ARayCastLidar(), UActorBlueprintFunctionLibrary::SetGnss(), UActorBlueprintFunctionLibrary::SetIMU(), and UActorBlueprintFunctionLibrary::SetRadar().

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

◆ Tick()

void ASensor::Tick ( const float  DeltaTime)
final

Definition at line 59 of file Sensor.cpp.

References FDataStreamTmpl< T >::AreClientsListening(), bClientsListening, OnFirstClientConnected(), OnLastClientDisconnected(), PrePhysTick(), ReadyToTick, and Stream.

+ Here is the call graph for this function:

Member Data Documentation

◆ bClientsListening

bool ASensor::bClientsListening = false
private

Definition at line 139 of file Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/Sensor.h.

Referenced by Tick().

◆ bIsActive

bool ASensor::bIsActive = false
protected

◆ Episode

const UCarlaEpisode* ASensor::Episode = nullptr
private

◆ OnPostTickDelegate

FDelegateHandle ASensor::OnPostTickDelegate
private

◆ RandomEngine

URandomEngine* ASensor::RandomEngine = nullptr
protected

◆ ReadyToTick

bool ASensor::ReadyToTick = false
private

Allows the sensor to tick with the tick rate from UE4.

Definition at line 137 of file Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/Sensor.h.

Referenced by PostPhysTickInternal(), and Tick().

◆ Seed

int32 ASensor::Seed = 123456789
protected

Seed of the pseudo-random engine.

Definition at line 117 of file Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/Sensor.h.

Referenced by SetSeed().

◆ SensorDescription

FActorDescription ASensor::SensorDescription
private

◆ Stream

FDataStream ASensor::Stream
private

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