CARLA
Public Member Functions | Static Public Member Functions | Protected Types | 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:
+ Collaboration diagram for ARayCastSemanticLidar:

Public Member Functions

 ARayCastSemanticLidar (const FObjectInitializer &ObjectInitializer)
 
virtual void Set (const FActorDescription &Description) override
 
virtual void Set (const FLidarDescription &LidarDescription)
 
- Public Member Functions inherited from ASensor
 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 ()
 
void PostPhysTickInternal (UWorld *World, ELevelTick TickType, float DeltaSeconds)
 
virtual void PrePhysTick (float DeltaSeconds)
 
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
 

Static Public Member Functions

static FActorDefinition GetSensorDefinition ()
 

Protected Types

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

Protected Member Functions

virtual void ComputeAndSaveDetections (const FTransform &SensorTransform)
 This method uses all the saved FHitResults, compute the RawDetections and then send it to the LidarData structure. More...
 
void ComputeRawDetection (const FHitResult &HitInfo, const FTransform &SensorTransf, FSemanticDetection &Detection) const
 Compute all raw detection information. More...
 
void CreateLasers ()
 Creates a Laser for each channel. More...
 
virtual void PostPhysTick (UWorld *World, ELevelTick TickType, float DeltaTime) override
 
virtual void PreprocessRays (uint32_t Channels, uint32_t MaxPointsPerChannel)
 Method that allow to preprocess if the rays will be traced. More...
 
void ResetRecordedHits (uint32_t Channels, uint32_t MaxPointsPerChannel)
 Clear the recorded data structure. More...
 
bool ShootLaser (const float VerticalAngle, float HorizontalAngle, FHitResult &HitResult, FCollisionQueryParams &TraceParams) const
 Shoot a laser ray-trace, return whether the laser hit something. More...
 
void SimulateLidar (const float DeltaTime)
 Updates LidarMeasurement with the points read in DeltaTime. More...
 
void WritePointAsync (uint32_t Channel, FHitResult &Detection)
 Saving the hits the raycast returns per channel. More...
 
- Protected Member Functions inherited from ASensor
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

FLidarDescription Description
 
TArray< float > LaserAngles
 
std::vector< uint32_t > PointsPerChannel
 
std::vector< std::vector< bool > > RayPreprocessCondition
 
std::vector< std::vector< FHitResult > > RecordedHits
 
- Protected Attributes inherited from ASensor
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

FSemanticLidarData SemanticLidarData
 

Detailed Description

A ray-cast based Lidar sensor.

Definition at line 25 of file RayCastSemanticLidar.h.

Member Typedef Documentation

◆ FSemanticDetection

Definition at line 32 of file RayCastSemanticLidar.h.

◆ FSemanticLidarData

Definition at line 31 of file RayCastSemanticLidar.h.

Constructor & Destructor Documentation

◆ ARayCastSemanticLidar()

ARayCastSemanticLidar::ARayCastSemanticLidar ( const FObjectInitializer &  ObjectInitializer)

Definition at line 30 of file RayCastSemanticLidar.cpp.

Member Function Documentation

◆ ComputeAndSaveDetections()

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

This method uses all the saved FHitResults, compute the RawDetections and then send it to the LidarData structure.

Reimplemented in ARayCastLidar.

Definition at line 187 of file RayCastSemanticLidar.cpp.

References FLidarDescription::Channels, ComputeRawDetection(), Description, PointsPerChannel, RecordedHits, carla::sensor::data::SemanticLidarData::ResetMemory(), SemanticLidarData, carla::sensor::data::SemanticLidarData::WriteChannelCount(), and carla::sensor::data::SemanticLidarData::WritePointSync().

Referenced by SimulateLidar().

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

◆ ComputeRawDetection()

void ARayCastSemanticLidar::ComputeRawDetection ( const FHitResult &  HitInfo,
const FTransform &  SensorTransf,
FSemanticDetection Detection 
) const
protected

Compute all raw detection information.

Definition at line 204 of file RayCastSemanticLidar.cpp.

References carla::sensor::data::SemanticLidarDetection::cos_inc_angle, FActorRegistry::FindCarlaActor(), FCarlaActor::GetActorId(), UCarlaEpisode::GetActorRegistry(), ASensor::GetEpisode(), carla::sensor::data::SemanticLidarDetection::object_idx, carla::sensor::data::SemanticLidarDetection::object_tag, and carla::sensor::data::SemanticLidarDetection::point.

Referenced by ComputeAndSaveDetections().

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

◆ CreateLasers()

void ARayCastSemanticLidar::CreateLasers ( )
protected

Creates a Laser for each channel.

Definition at line 52 of file RayCastSemanticLidar.cpp.

References FLidarDescription::Channels, Description, LaserAngles, FLidarDescription::LowerFovLimit, and FLidarDescription::UpperFovLimit.

Referenced by ARayCastLidar::Set(), and Set().

+ Here is the caller graph for this function:

◆ GetSensorDefinition()

FActorDefinition ARayCastSemanticLidar::GetSensorDefinition ( )
static

Definition at line 25 of file RayCastSemanticLidar.cpp.

References UActorBlueprintFunctionLibrary::MakeLidarDefinition().

+ Here is the call graph for this function:

◆ PostPhysTick()

void ARayCastSemanticLidar::PostPhysTick ( UWorld *  World,
ELevelTick  TickType,
float  DeltaTime 
)
overrideprotectedvirtual

Reimplemented from ASensor.

Reimplemented in ARayCastLidar.

Definition at line 68 of file RayCastSemanticLidar.cpp.

References carla::streaming::detail::token_type::get_stream_id(), ASensor::GetDataStream(), carla::ros2::ROS2::GetInstance(), ASensor::GetToken(), SemanticLidarData, and SimulateLidar().

+ Here is the call graph for this function:

◆ PreprocessRays()

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

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

Reimplemented in ARayCastLidar.

Definition at line 171 of file RayCastSemanticLidar.cpp.

References RayPreprocessCondition.

Referenced by SimulateLidar().

+ Here is the caller graph for this function:

◆ ResetRecordedHits()

void ARayCastSemanticLidar::ResetRecordedHits ( uint32_t  Channels,
uint32_t  MaxPointsPerChannel 
)
protected

Clear the recorded data structure.

Definition at line 162 of file RayCastSemanticLidar.cpp.

References RecordedHits.

Referenced by SimulateLidar().

+ Here is the caller graph for this function:

◆ Set() [1/2]

void ARayCastSemanticLidar::Set ( const FActorDescription Description)
overridevirtual

Reimplemented from ASensor.

Reimplemented in ARayCastLidar.

Definition at line 36 of file RayCastSemanticLidar.cpp.

References UActorBlueprintFunctionLibrary::SetLidar().

+ Here is the call graph for this function:

◆ Set() [2/2]

void ARayCastSemanticLidar::Set ( const FLidarDescription LidarDescription)
virtual

Reimplemented in ARayCastLidar.

Definition at line 44 of file RayCastSemanticLidar.cpp.

References FLidarDescription::Channels, CreateLasers(), Description, PointsPerChannel, and SemanticLidarData.

+ Here is the call graph for this function:

◆ ShootLaser()

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

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

Definition at line 231 of file RayCastSemanticLidar.cpp.

References Description, and FLidarDescription::Range.

Referenced by SimulateLidar().

+ Here is the caller graph for this function:

◆ SimulateLidar()

void ARayCastSemanticLidar::SimulateLidar ( const float  DeltaTime)
protected

Updates LidarMeasurement with the points read in DeltaTime.

Definition at line 100 of file RayCastSemanticLidar.cpp.

References FLidarDescription::Channels, ComputeAndSaveDetections(), Description, carla::sensor::data::SemanticLidarData::GetHorizontalAngle(), FLidarDescription::HorizontalFov, LaserAngles, FLidarDescription::PointsPerSecond, PreprocessRays(), RayPreprocessCondition, ResetRecordedHits(), FLidarDescription::RotationFrequency, SemanticLidarData, carla::sensor::data::SemanticLidarData::SetHorizontalAngle(), ShootLaser(), carla::geom::Math::ToDegrees(), carla::geom::Math::ToRadians(), and WritePointAsync().

Referenced by ARayCastLidar::PostPhysTick(), and PostPhysTick().

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

◆ WritePointAsync()

void ARayCastSemanticLidar::WritePointAsync ( uint32_t  Channel,
FHitResult &  Detection 
)
protected

Saving the hits the raycast returns per channel.

Definition at line 181 of file RayCastSemanticLidar.cpp.

References DEBUG_ASSERT, and RecordedHits.

Referenced by SimulateLidar().

+ Here is the caller graph for this function:

Member Data Documentation

◆ Description

FLidarDescription ARayCastSemanticLidar::Description
protected

◆ LaserAngles

TArray<float> ARayCastSemanticLidar::LaserAngles
protected

Definition at line 73 of file RayCastSemanticLidar.h.

Referenced by CreateLasers(), and SimulateLidar().

◆ PointsPerChannel

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

◆ RayPreprocessCondition

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

◆ RecordedHits

std::vector<std::vector<FHitResult> > ARayCastSemanticLidar::RecordedHits
protected

◆ SemanticLidarData

FSemanticLidarData ARayCastSemanticLidar::SemanticLidarData
private

Definition at line 80 of file RayCastSemanticLidar.h.

Referenced by ComputeAndSaveDetections(), PostPhysTick(), Set(), and SimulateLidar().


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