URayCastSensor
Raycast sensor that collects observations by casting rays into the environment.
This sensor fires multiple rays in a cone or full circle pattern, detecting objects and measuring distances. For each ray, it reports whether an object was hit, the hit distance, and which tracked tags (if any) the hit object has. Useful for navigation and obstacle detection.
class URayCastSensor : public USceneComponent, public IScholaSensorMethods
GetObservationSpace_Implementation
virtual void GetObservationSpace_Implementation( FInstancedStruct &OutObservationSpace) const overrideGet the observation space for this sensor.
Parameters
OutObservationSpace(FInstancedStruct)
GenerateRayEndpoints
void GenerateRayEndpoints(int32 InNumRays, float InRayDegrees, FVector InBaseEnd, FVector InStart, FTransform InBaseTransform, FVector InEndOffset, TArray<FVector> &OutRayEndpoints)Generate the endpoints of the rays to be cast.
Parameters
-
InNumRays(int32) -
InRayDegrees(float) -
InBaseEnd(FVector) -
InStart(FVector) -
InBaseTransform(FTransform) -
InEndOffset(FVector) -
OutRayEndpoints(TArray<FVector>)
AppendEmptyTags
void AppendEmptyTags(FBoxPoint &OutObservations)Add empty tags to the observation for rays that miss.
Parameters
OutObservations(FBoxPoint)
CollectObservations_Implementation
virtual voidCollectObservations_Implementation(FInstancedStruct &OutObservations) overrideCollect observations about the environment state by casting rays.
Parameters
OutObservations(FInstancedStruct)
GenerateId
FString GenerateId() constGenerate a unique ID string for this sensor.
HandleRayHit
static void HandleRayHit(const UWorld *World, const TArray<FName> &TrackedTags, const FHitResult &InHitResult, TArrayView<float> &OutObservations, const FVector &InStart)Handle a successful ray trace and append observation data.
Parameters
-
World(const UWorld) -
TrackedTags(const TArray<FName>) -
InHitResult(const FHitResult) -
OutObservations(TArrayView<float>) -
InStart(const FVector)
Attributes
RayLength
float RayLength = 4096.fSphere radius for debug visualization at hit points.
CollisionChannel
TEnumAsByte<ECollisionChannel> CollisionChannelThe collision channel to use for the raycast.
bDrawDebugLines
bool bDrawDebugLines = falseDoes this sensor draw debug lines/spheres during runtime.
bTraceComplex
bool bTraceComplex = falseShould the sensor trace against complex collision.
NumRays
int32 NumRays = 2The number of rays to fire.
RayDegrees
float RayDegrees = 90.0fThe angle between the first and last ray.
TrackedTags
TArray<FName> TrackedTagsActor tags that are checked on raycast collision.
RayEndOffset
FVector RayEndOffsetA position adjustment that is applied to end points of the generated ray trajectories.
DebugHitColor
FColor DebugHitColor = FColor::GreenDebug color for ray hit (when ray intersects an object).
DebugMissColor
FColor DebugMissColor = FColor::RedDebug color for ray miss (when ray hits nothing).
bEnableParallelTracing
bool bEnableParallelTracing = falseShould the sensor run raytraces in parallel.
MinParallelBatchSize
int32 MinParallelBatchSize = 1The minimum number of rays to process in each parallel batch.
Source: Source/ScholaInteractors/Public/Sensors/RayCastSensor.h