A ray-cast based Lidar sensor. More...
#include <RayCastSemanticLidar.h>
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< FActorAttribute > | GetAttribute (const FString Name) |
const UCarlaEpisode & | GetEpisode () const |
URandomEngine * | GetRandomEngine () |
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 |
URandomEngine * | RandomEngine = 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 |
A ray-cast based Lidar sensor.
Definition at line 25 of file RayCastSemanticLidar.h.
|
protected |
Definition at line 32 of file RayCastSemanticLidar.h.
Definition at line 31 of file RayCastSemanticLidar.h.
ARayCastSemanticLidar::ARayCastSemanticLidar | ( | const FObjectInitializer & | ObjectInitializer | ) |
Definition at line 30 of file RayCastSemanticLidar.cpp.
|
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().
|
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().
|
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().
|
static |
Definition at line 25 of file RayCastSemanticLidar.cpp.
References UActorBlueprintFunctionLibrary::MakeLidarDefinition().
|
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().
|
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().
|
protected |
Clear the recorded data structure.
Definition at line 162 of file RayCastSemanticLidar.cpp.
References RecordedHits.
Referenced by SimulateLidar().
|
overridevirtual |
Reimplemented from ASensor.
Reimplemented in ARayCastLidar.
Definition at line 36 of file RayCastSemanticLidar.cpp.
References UActorBlueprintFunctionLibrary::SetLidar().
|
virtual |
Reimplemented in ARayCastLidar.
Definition at line 44 of file RayCastSemanticLidar.cpp.
References FLidarDescription::Channels, CreateLasers(), Description, PointsPerChannel, and SemanticLidarData.
|
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().
|
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().
|
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().
|
protected |
Definition at line 71 of file RayCastSemanticLidar.h.
Referenced by ARayCastLidar::ARayCastLidar(), ARayCastLidar::ComputeAndSaveDetections(), ComputeAndSaveDetections(), ARayCastLidar::ComputeDetection(), ARayCastLidar::ComputeIntensity(), CreateLasers(), ARayCastLidar::PostprocessDetection(), ARayCastLidar::PreprocessRays(), ARayCastLidar::Set(), Set(), ShootLaser(), and SimulateLidar().
|
protected |
Definition at line 73 of file RayCastSemanticLidar.h.
Referenced by CreateLasers(), and SimulateLidar().
|
protected |
Definition at line 77 of file RayCastSemanticLidar.h.
Referenced by ARayCastLidar::ComputeAndSaveDetections(), ComputeAndSaveDetections(), ARayCastLidar::Set(), and Set().
|
protected |
Definition at line 76 of file RayCastSemanticLidar.h.
Referenced by ARayCastLidar::PreprocessRays(), PreprocessRays(), and SimulateLidar().
|
protected |
Definition at line 75 of file RayCastSemanticLidar.h.
Referenced by ARayCastLidar::ComputeAndSaveDetections(), ComputeAndSaveDetections(), ResetRecordedHits(), and WritePointAsync().
|
private |
Definition at line 80 of file RayCastSemanticLidar.h.
Referenced by ComputeAndSaveDetections(), PostPhysTick(), Set(), and SimulateLidar().