33 if (
nullptr != Cast<ACarlaWheeledVehicle>(Actor))
37 else if (
nullptr != Cast<ACharacter>(Actor))
41 else if (
nullptr != Cast<ATrafficLightBase>(Actor))
45 else if (
nullptr != Cast<ATrafficSignBase>(Actor))
49 else if (
nullptr != Cast<ASensor>(Actor))
61 for (
auto &&Tag : SemanticTags)
63 if ((Tag != crp::CityObjectLabel::None) && (Tag != crp::CityObjectLabel::Other))
66 return (Str.EndsWith(TEXT(
"s")) ? Str.LeftChop(1) : Str);
69 return TEXT(
"unknown");
76 bool IsDormant = CarlaActor && (CarlaActor->
IsDormant());
80 Actors.Add(DesiredId, &Actor);
81 Ids.Add(&Actor, DesiredId);
87 if (DesiredId != 0 && Id != DesiredId) {
89 if (!
Actors.Contains(DesiredId))
97 Actors.Emplace(Id, &Actor);
98 if (
Ids.Contains(&Actor))
103 TEXT(
"This actor's memory address is already registered, "
104 "either you forgot to deregister the actor "
105 "or the actor was garbage collected."));
107 Ids.Emplace(&Actor, Id);
109 TSharedPtr<FCarlaActor> View =
110 MakeCarlaActor(Id, Actor, std::move(Description), crp::ActorState::Active);
112 TSharedPtr<FCarlaActor>& Result =
ActorDatabase.Emplace(Id, MoveTemp(View));
122 if(!CarlaActor)
return;
137 check(Actor !=
nullptr);
139 check(CarlaActor->
GetActor() == Actor);
149 auto Info = MakeShared<FActorInfo>();
150 Info->Description = std::move(Description);
154 if (Info->Description.Id.IsEmpty())
160 Info->SerializedData.id = Id;
161 Info->SerializedData.description = Info->Description;
162 Info->SerializedData.bounding_box = Info->BoundingBox;
163 Info->SerializedData.semantic_tags.reserve(Info->SemanticTags.Num());
164 for (
auto &&Tag : Info->SemanticTags)
166 using tag_t =
decltype(Info->SerializedData.semantic_tags)::value_type;
167 Info->SerializedData.semantic_tags.emplace_back(
static_cast<tag_t
>(Tag));
169 auto *Sensor = Cast<ASensor>(&Actor);
170 if (Sensor !=
nullptr)
172 const auto &Token = Sensor->GetToken();
173 Info->SerializedData.stream_token =
decltype(Info->SerializedData.stream_token)(
174 std::begin(Token.data),
175 std::end(Token.data));
178 TSharedPtr<FCarlaActor> CarlaActor =
181 std::move(Info), Type,
182 InState, Actor.GetWorld());
230 UE_LOG(LogCarla, Error, TEXT(
"Failed to attach actor %d to %d during wake up"), Id, CarlaActor->
GetParent());
245 ASensor *Sensor = Cast<ASensor>(Item.Value->GetActor());
246 if (Sensor ==
nullptr)
continue;
251 const FActorInfo *Info = Item.Value->GetActorInfo();
FString CarlaGetRelevantTagAsString(const TSet< crp::CityObjectLabel > &SemanticTags)
static FCarlaActor::ActorType FActorRegistry_GetActorType(const AActor *Actor)
auto GetToken() const
Return the token that allows subscribing to this sensor's stream.
static void GetTagsOfTaggedActor(const AActor &Actor, TSet< crp::CityObjectLabel > &Tags)
Retrieve the tags of an already tagged actor.
static FString GetTagAsString(crp::CityObjectLabel Tag)
Retrieve the tags of an already tagged actor.
FString GetDescriptionFromStream(carla::streaming::detail::stream_id_type Id)
TMap< AActor *, IdType > Ids
TSharedPtr< FCarlaActor > MakeCarlaActor(IdType Id, AActor &Actor, FActorDescription Description, carla::rpc::ActorState InState) const
FCarlaActor::IdType IdType
FCarlaActor * Register(AActor &Actor, FActorDescription Description, IdType DesiredId=0)
Register the Actor in the database.
TMap< IdType, AActor * > Actors
DatabaseType ActorDatabase
void Deregister(IdType Id)
FCarlaActor * FindCarlaActor(IdType Id)
void PutActorToSleep(IdType Id, UCarlaEpisode *CarlaEpisode)
void WakeActorUp(IdType Id, UCarlaEpisode *CarlaEpisode)
A view over an actor and its properties.
carla::rpc::AttachmentType GetAttachmentType() const
static TSharedPtr< FCarlaActor > ConstructCarlaActor(IdType ActorId, AActor *Actor, TSharedPtr< const FActorInfo > Info, ActorType Type, carla::rpc::ActorState InState, UWorld *World)
IdType GetActorId() const
void WakeActorUp(UCarlaEpisode *CarlaEpisode)
const TArray< IdType > & GetChildren() const
void PutActorToSleep(UCarlaEpisode *CarlaEpisode)
static FBoundingBox GetActorBoundingBox(const AActor *Actor, uint8 InTagQueried=0xFF)
Compute the bounding box of the given Carla actor.
void AttachActors(AActor *Child, AActor *Parent, EAttachmentType InAttachmentType=EAttachmentType::Rigid, const FString &SocketName="")
Attach Child to Parent.
Serializes a stream endpoint.
const auto & get_stream_id() const
A description of a Carla Actor with all its variation.
FString Id
Display ID that identifies the actor.
A view over an actor and its properties.
FActorDescription Description