21 : Super(ObjectInitializer)
23 PrimaryActorTick.bCanEverTick =
true;
30 return SensorDefinition;
36 Super::Set(Description);
49 #if !(UE_BUILD_SHIPPING || UE_BUILD_TEST) 60 const FVector &Start = GetActorLocation();
61 const FVector &End = Start + (GetActorForwardVector() *
Distance);
62 UWorld* CurrentWorld = GetWorld();
65 FHitResult HitOut = FHitResult();
68 FCollisionQueryParams TraceParams(FName(TEXT(
"ObstacleDetection Trace")),
true,
this);
70 #if !(UE_BUILD_SHIPPING || UE_BUILD_TEST) 75 const FName TraceTag(
"ObstacleDebugTrace");
76 CurrentWorld->DebugDrawTraceTag = TraceTag;
77 TraceParams.TraceTag = TraceTag;
82 TraceParams.bTraceComplex =
true;
85 TraceParams.bIgnoreTouches =
true;
88 TraceParams.bReturnPhysicalMaterial =
false;
91 TraceParams.AddIgnoredActor(
this);
92 if(Super::GetOwner()!=
nullptr)
93 TraceParams.AddIgnoredActor(Super::GetOwner());
101 FCollisionObjectQueryParams TraceChannel = FCollisionObjectQueryParams(
102 FCollisionObjectQueryParams::AllDynamicObjects);
103 isHitReturned = CurrentWorld->SweepSingleByObjectType(
116 ECollisionChannel TraceChannel = ECC_WorldStatic;
117 isHitReturned = CurrentWorld->SweepSingleByChannel(
137 const FHitResult &Hit)
139 if ((Actor !=
nullptr) && (OtherActor !=
nullptr) &&
IsStreamReady())
146 #if defined(WITH_ROS2) 148 if (ROS2->IsEnabled())
150 TRACE_CPUPROFILER_EVENT_SCOPE_STR(
"ROS2 Send");
152 AActor* ParentActor = GetAttachParentActor();
155 FTransform LocalTransformRelativeToParent = GetActorTransform().GetRelativeTransform(ParentActor->GetActorTransform());
156 ROS2->ProcessDataFromObstacleDetection(DataStream.GetSensorType(), StreamId, LocalTransformRelativeToParent,
Actor, OtherActor, HitDistance/100.0f,
this);
160 ROS2->ProcessDataFromObstacleDetection(DataStream.GetSensorType(), StreamId, DataStream.GetSensorTransform(),
Actor, OtherActor, HitDistance/100.0f,
this);
165 DataStream.SerializeAndSend(*
this,
auto GetToken() const
Return the token that allows subscribing to this sensor's stream.
const UCarlaEpisode * Episode
static void MakeObstacleDetectorDefinitions(const FString &Type, const FString &Id, FActorDefinition &Definition)
void Set(const FActorDescription &Description) override
carla::rpc::Actor SerializeActor(FCarlaActor *CarlaActor) const
Create a serializable object describing the actor.
static FActorDefinition GetSensorDefinition()
const UCarlaEpisode & GetEpisode() const
static float RetrieveActorAttributeToFloat(const FString &Id, const TMap< FString, FActorAttribute > &Attributes, float Default)
A definition of a Carla Actor with all the variation and attributes.
virtual void PostPhysTick(UWorld *World, ELevelTick TickType, float DeltaSeconds) override
TMap< FString, FActorAttribute > Variations
User selected variations of the actor.
carla::SharedPtr< cc::Actor > Actor
void OnObstacleDetectionEvent(AActor *Actor, AActor *OtherActor, float Distance, const FHitResult &Hit)
A description of a Carla Actor with all its variation.
const auto & get_stream_id() const
AObstacleDetectionSensor(const FObjectInitializer &ObjectInitializer)
FAsyncDataStream GetDataStream(const SensorT &Self)
Return the FDataStream associated with this sensor.
static std::shared_ptr< ROS2 > GetInstance()
static bool RetrieveActorAttributeToBool(const FString &Id, const TMap< FString, FActorAttribute > &Attributes, bool Default)
carla::streaming::detail::token_type token_type