18 : Super(ObjectInitializer)
20 PrimaryActorTick.bCanEverTick =
false;
32 Super::SetOwner(NewOwner);
36 if (NewOwner !=
nullptr)
45 FVector NormalImpulse,
46 const FHitResult &Hit)
48 if (Actor ==
nullptr || OtherActor ==
nullptr)
60 [CurrentFrame](std::tuple<uint64_t, AActor*, AActor*> Item)
62 return std::get<0>(Item) < CurrentFrame;
69 if (std::get<0>(
Collision) == CurrentFrame &&
78 constexpr
float TO_METERS = 1e-2;
79 NormalImpulse *= TO_METERS;
90 CollisionRegistry.emplace_back(CurrentFrame, Actor, OtherActor);
93 #if defined(WITH_ROS2) 95 if (ROS2->IsEnabled())
97 TRACE_CPUPROFILER_EVENT_SCOPE_STR(
"ROS2 Send");
99 AActor* ParentActor = GetAttachParentActor();
102 FTransform LocalTransformRelativeToParent = GetActorTransform().GetRelativeTransform(ParentActor->GetActorTransform());
103 ROS2->ProcessDataFromCollisionSensor(0, StreamId, LocalTransformRelativeToParent, OtherActor->GetUniqueID(),
carla::geom::Vector3D{NormalImpulse.X, NormalImpulse.Y, NormalImpulse.Z},
this);
107 ROS2->ProcessDataFromCollisionSensor(0, StreamId, GetActorTransform(), OtherActor->GetUniqueID(),
carla::geom::Vector3D{NormalImpulse.X, NormalImpulse.Y, NormalImpulse.Z},
this);
auto GetToken() const
Return the token that allows subscribing to this sensor's stream.
void SerializeAndSend(SensorT &Sensor, ArgsT &&... Args)
void OnCollisionEvent(AActor *Actor, AActor *OtherActor, FVector NormalImpulse, const FHitResult &Hit)
const UCarlaEpisode * Episode
static FActorDefinition GetSensorDefinition()
carla::rpc::Actor SerializeActor(FCarlaActor *CarlaActor) const
Create a serializable object describing the actor.
const UCarlaEpisode & GetEpisode() const
A definition of a Carla Actor with all the variation and attributes.
static uint64_t GetFrameCounter()
std::vector< std::tuple< uint64_t, AActor *, AActor * > > CollisionRegistry
Registry that saves all collisions.
void AddCollision(AActor *Actor1, AActor *Actor2)
carla::SharedPtr< cc::Actor > Actor
static FActorDefinition MakeGenericSensorDefinition(const FString &Type, const FString &Id)
ACollisionSensor(const FObjectInitializer &ObjectInitializer)
void SetOwner(AActor *NewOwner) override
ACarlaRecorder * GetRecorder() const
const auto & get_stream_id() const
FAsyncDataStream GetDataStream(const SensorT &Self)
Return the FDataStream associated with this sensor.
static std::shared_ptr< ROS2 > GetInstance()
carla::streaming::detail::token_type token_type