CARLA
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Attributes | List of all members
ARayCastSemanticLidar Class Reference

A ray-cast based Lidar sensor. More...

#include <RayCastSemanticLidar.h>

+ Inheritance diagram for ARayCastSemanticLidar:

Public Member Functions

 ARayCastSemanticLidar (const FObjectInitializer &ObjectInitializer)
 
void GetMirrorState (carla::multigpu::SensorState &State) const override
 Multi-GPU: the runtime state this sensor starts its next tick from (noise generator, sweep angle, history).
 
virtual void SendData (const float DeltaTime)
 
virtual void Set (const FActorDescription &Description) override
 
virtual void Set (const FLidarDescription &LidarDescription)
 
void SetMirrorState (const carla::multigpu::SensorState &State) override
 
virtual void SimulateLidar (const float DeltaTime, bool bLockPhysics=true)
 
- Public Member Functions inherited from ASensor
bool AreClientsListening ()
 
 ASensor (const FObjectInitializer &ObjectInitializer)
 
void ClearReadyToTick ()
 
std::optional< FActorAttribute > GetAttribute (const FString Name)
 
const UCarlaEpisode & GetEpisode () const
 
URandomEngine * GetRandomEngine ()
 
float GetReadyToTickDeltaSeconds () const
 
int32 GetSeed () const
 
auto GetToken () const
 Return the token that allows subscribing to this sensor's stream.
 
bool IsReadyToTick () const
 
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)
 
void SetDataStream (FDataStream InStream)
 Replace the FDataStream associated with this sensor.
 
void SetEpisode (const UCarlaEpisode &InEpisode)
 
void SetPrimaryTick (float DeltaSeconds)
 Multi-GPU secondary: tick in this engine frame, with the primary's delta.
 
void SetSavingDataToDisk (bool bSavingData)
 
void SetSeed (int32 InSeed)
 
void Tick (const float DeltaTime) final
 

Static Public Member Functions

static FActorDefinition GetSensorDefinition ()
 
- Static Public Member Functions inherited from ASensor
static FSensorCaptureContext MakeCaptureContext (const ASensor &Sensor)
 Call on the game thread right after CaptureScene().
 

Protected Types

using FSemanticDetection = carla::sensor::data::SemanticLidarDetection
 
using FSemanticLidarData = carla::sensor::data::SemanticLidarData
 

Protected Member Functions

virtual void BeginPlay () override
 
virtual void ComputeAndSaveDetections (const FTransform &SensorTransform)
 Copies the per-channel detections into the LidarData structure.
 
void ComputeRawDetection (const FHitResult &HitInfo, const FTransform &InverseSensorTransform, const FVector &SensorLocation, FSemanticDetection &Detection) const
 Compute all raw detection information.
 
void CreateLasers ()
 Creates a Laser for each channel.
 
virtual void EndPlay (EEndPlayReason::Type EndPlayReason) override
 
virtual void PreprocessRays (uint32_t Channels, uint32_t MaxPointsPerChannel)
 Method that allow to preprocess if the rays will be traced.
 
virtual void ResetDetections (uint32_t Channels, uint32_t MaxPointsPerChannel)
 Clear the per-channel detection buffers.
 
bool ShootLaser (const float VerticalAngle, float HorizontalAngle, FHitResult &HitResult, FCollisionQueryParams &TraceParams, const FVector &LidarBodyLocation, const FRotator &LidarBodyRotation) const
 Shoot a laser ray-trace, return whether the laser hit something.
 
virtual void WriteDetectionAsync (uint32_t Channel, const FHitResult &HitInfo, const FTransform &InverseSensorTransform, const FVector &SensorLocation)
 Computes the detection of a hit inside the raycast ParallelFor.
 
- Protected Member Functions inherited from ASensor
void EndPlay (EEndPlayReason::Type EndPlayReason) override
 
template<typename SensorType >
FAsyncDataStream GetDataStream (SensorType &&Self)
 Return the FDataStream associated with this sensor.
 
void PostActorCreated () override
 

Static Protected Member Functions

template<typename DetectionT , typename LidarDataT , typename PostprocessT >
static void CompactAndWriteDetections (std::vector< std::vector< DetectionT > > &Detections, std::vector< uint32_t > &OutPointsPerChannel, uint32_t Channels, LidarDataT &LidarData, PostprocessT &&Postprocess)
 Post-processes the detections channel by channel, drops the rejected ones and writes the rest to LidarData.
 
template<typename DetectionT >
static void CopyDetectionsToPointCloud (const std::vector< std::vector< DetectionT > > &Detections, const std::vector< uint32_t > &InPointsPerChannel, TArray< float > &PointCloud)
 Copies the kept detections into a flat x, y, z, intensity array (editor debug point cloud).
 
template<typename DetectionT >
static void ResetChannelDetections (std::vector< std::vector< DetectionT > > &Detections, uint32_t Channels, uint32_t MaxPointsPerChannel)
 Clears every channel buffer and reserves room for a full scan.
 
- Static Protected Member Functions inherited from ASensor
template<typename SensorType , typename ElementType >
static void SendDataToClient (SensorType &&Sensor, TArrayView< ElementType > SensorData, const FSensorCaptureContext &CaptureContext)
 

Protected Attributes

FLidarDescription Description
 
TArray< float > LaserAngles
 
std::vector< uint32_t > PointsPerChannel
 
std::vector< std::vector< bool > > RayPreprocessCondition
 
- Protected Attributes inherited from ASensor
bool bIsActive = false
 
bool bSavingDataToDisk = false
 
URandomEngine * RandomEngine = nullptr
 Random Engine used to provide noise for sensor output.
 
int32 Seed = 123456789
 Seed of the pseudo-random engine.
 

Private Attributes

std::vector< std::vector< FSemanticDetection > > SemanticDetections
 
FSemanticLidarData SemanticLidarData
 

Detailed Description

A ray-cast based Lidar sensor.

Definition at line 28 of file RayCastSemanticLidar.h.

Member Typedef Documentation

◆ FSemanticDetection

Definition at line 35 of file RayCastSemanticLidar.h.

◆ FSemanticLidarData

Definition at line 34 of file RayCastSemanticLidar.h.

Constructor & Destructor Documentation

◆ ARayCastSemanticLidar()

ARayCastSemanticLidar::ARayCastSemanticLidar ( const FObjectInitializer &  ObjectInitializer)

Definition at line 36 of file RayCastSemanticLidar.cpp.

Member Function Documentation

◆ BeginPlay()

void ARayCastSemanticLidar::BeginPlay ( )
overrideprotectedvirtual

Reimplemented from ASensor.

Definition at line 42 of file RayCastSemanticLidar.cpp.

◆ CompactAndWriteDetections()

template<typename DetectionT , typename LidarDataT , typename PostprocessT >
static void ARayCastSemanticLidar::CompactAndWriteDetections ( std::vector< std::vector< DetectionT > > &  Detections,
std::vector< uint32_t > &  OutPointsPerChannel,
uint32_t  Channels,
LidarDataT &  LidarData,
PostprocessT &&  Postprocess 
)
inlinestaticprotected

Post-processes the detections channel by channel, drops the rejected ones and writes the rest to LidarData.

Runs sequentially in channel and point order, so the random sequence for noise and drop-off is unchanged.

Definition at line 94 of file RayCastSemanticLidar.h.

Referenced by AHSSLidar::ComputeAndSaveDetections(), and ARayCastLidar::ComputeAndSaveDetections().

◆ ComputeAndSaveDetections()

void ARayCastSemanticLidar::ComputeAndSaveDetections ( const FTransform &  SensorTransform)
protectedvirtual

◆ ComputeRawDetection()

void ARayCastSemanticLidar::ComputeRawDetection ( const FHitResult &  HitInfo,
const FTransform &  InverseSensorTransform,
const FVector &  SensorLocation,
FSemanticDetection &  Detection 
) const
protected

◆ CopyDetectionsToPointCloud()

template<typename DetectionT >
static void ARayCastSemanticLidar::CopyDetectionsToPointCloud ( const std::vector< std::vector< DetectionT > > &  Detections,
const std::vector< uint32_t > &  InPointsPerChannel,
TArray< float > &  PointCloud 
)
inlinestaticprotected

Copies the kept detections into a flat x, y, z, intensity array (editor debug point cloud).

Definition at line 126 of file RayCastSemanticLidar.h.

Referenced by AHSSLidar::ComputeAndSaveDetections(), and ARayCastLidar::ComputeAndSaveDetections().

◆ CreateLasers()

void ARayCastSemanticLidar::CreateLasers ( )
protected

◆ EndPlay()

void ARayCastSemanticLidar::EndPlay ( EEndPlayReason::Type  EndPlayReason)
overrideprotectedvirtual

Definition at line 51 of file RayCastSemanticLidar.cpp.

◆ GetMirrorState()

void ARayCastSemanticLidar::GetMirrorState ( carla::multigpu::SensorState &  State) const
overridevirtual

Multi-GPU: the runtime state this sensor starts its next tick from (noise generator, sweep angle, history).

Override only for sensors whose PostPhysTick runs whether or not anyone listens: the primary's sensor owns the state of a sensor computed by a secondary.

Reimplemented from ASensor.

Definition at line 314 of file RayCastSemanticLidar.cpp.

References carla::sensor::data::SemanticLidarData::GetHorizontalAngle(), URandomEngine::GetState(), ASensor::RandomEngine, SemanticLidarData, and State.

◆ GetSensorDefinition()

FActorDefinition ARayCastSemanticLidar::GetSensorDefinition ( )
static

◆ PreprocessRays()

void ARayCastSemanticLidar::PreprocessRays ( uint32_t  Channels,
uint32_t  MaxPointsPerChannel 
)
protectedvirtual

Method that allow to preprocess if the rays will be traced.

Reimplemented in AHSSLidar, and ARayCastLidar.

Definition at line 206 of file RayCastSemanticLidar.cpp.

References RayPreprocessCondition.

Referenced by SimulateLidar().

◆ ResetChannelDetections()

template<typename DetectionT >
static void ARayCastSemanticLidar::ResetChannelDetections ( std::vector< std::vector< DetectionT > > &  Detections,
uint32_t  Channels,
uint32_t  MaxPointsPerChannel 
)
inlinestaticprotected

Clears every channel buffer and reserves room for a full scan.

Definition at line 81 of file RayCastSemanticLidar.h.

Referenced by ResetDetections(), AHSSLidar::ResetDetections(), and ARayCastLidar::ResetDetections().

◆ ResetDetections()

void ARayCastSemanticLidar::ResetDetections ( uint32_t  Channels,
uint32_t  MaxPointsPerChannel 
)
protectedvirtual

Clear the per-channel detection buffers.

Reimplemented in AHSSLidar, and ARayCastLidar.

Definition at line 216 of file RayCastSemanticLidar.cpp.

References ResetChannelDetections(), and SemanticDetections.

Referenced by SimulateLidar().

◆ SendData()

void ARayCastSemanticLidar::SendData ( const float  DeltaTime)
virtual

◆ Set() [1/2]

void ARayCastSemanticLidar::Set ( const FActorDescription &  Description)
overridevirtual

Reimplemented from ASensor.

Reimplemented in AHSSLidar, and ARayCastLidar.

Definition at line 60 of file RayCastSemanticLidar.cpp.

References Set(), and UActorBlueprintFunctionLibrary::SetLidar().

Referenced by Set().

◆ Set() [2/2]

void ARayCastSemanticLidar::Set ( const FLidarDescription &  LidarDescription)
virtual

◆ SetMirrorState()

void ARayCastSemanticLidar::SetMirrorState ( const carla::multigpu::SensorState &  State)
overridevirtual

◆ ShootLaser()

bool ARayCastSemanticLidar::ShootLaser ( const float  VerticalAngle,
float  HorizontalAngle,
FHitResult &  HitResult,
FCollisionQueryParams &  TraceParams,
const FVector &  LidarBodyLocation,
const FRotator &  LidarBodyRotation 
) const
protected

Shoot a laser ray-trace, return whether the laser hit something.

Definition at line 290 of file RayCastSemanticLidar.cpp.

References Description, and FLidarDescription::Range.

Referenced by SimulateLidar(), and AHSSLidar::SimulateLidar().

◆ SimulateLidar()

void ARayCastSemanticLidar::SimulateLidar ( const float  DeltaTime,
bool  bLockPhysics = true 
)
virtual

◆ WriteDetectionAsync()

void ARayCastSemanticLidar::WriteDetectionAsync ( uint32_t  Channel,
const FHitResult &  HitInfo,
const FTransform &  InverseSensorTransform,
const FVector &  SensorLocation 
)
protectedvirtual

Computes the detection of a hit inside the raycast ParallelFor.

Reimplemented in AHSSLidar, and ARayCastLidar.

Definition at line 220 of file RayCastSemanticLidar.cpp.

References ComputeRawDetection(), DEBUG_ASSERT, and SemanticDetections.

Referenced by SimulateLidar().

Member Data Documentation

◆ Description

FLidarDescription ARayCastSemanticLidar::Description
protected

◆ LaserAngles

TArray<float> ARayCastSemanticLidar::LaserAngles
protected

Definition at line 152 of file RayCastSemanticLidar.h.

Referenced by CreateLasers(), SimulateLidar(), and AHSSLidar::SimulateLidar().

◆ PointsPerChannel

std::vector<uint32_t> ARayCastSemanticLidar::PointsPerChannel
protected

◆ RayPreprocessCondition

std::vector<std::vector<bool> > ARayCastSemanticLidar::RayPreprocessCondition
protected

◆ SemanticDetections

std::vector<std::vector<FSemanticDetection> > ARayCastSemanticLidar::SemanticDetections
private

◆ SemanticLidarData

FSemanticLidarData ARayCastSemanticLidar::SemanticLidarData
private

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