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)
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);
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;
249 if (token.get_stream_id() == Id)
251 const FActorInfo *Info = Item.Value->GetActorInfo();
void Deregister(IdType Id)
auto GetToken() const
Return the token that allows subscribing to this sensor's stream.
carla::rpc::AttachmentType GetAttachmentType() const
TMap< IdType, AActor * > Actors
void WakeActorUp(UCarlaEpisode *CarlaEpisode)
void PutActorToSleep(IdType Id, UCarlaEpisode *CarlaEpisode)
DatabaseType ActorDatabase
void PutActorToSleep(UCarlaEpisode *CarlaEpisode)
TMap< AActor *, IdType > Ids
static void GetTagsOfTaggedActor(const AActor &Actor, TSet< crp::CityObjectLabel > &Tags)
Retrieve the tags of an already tagged actor.
void WakeActorUp(IdType Id, UCarlaEpisode *CarlaEpisode)
FString CarlaGetRelevantTagAsString(const TSet< crp::CityObjectLabel > &SemanticTags)
const TArray< IdType > & GetChildren() const
carla::SharedPtr< cc::Actor > Actor
Serializes a stream endpoint.
TSharedPtr< FCarlaActor > MakeCarlaActor(IdType Id, AActor &Actor, FActorDescription Description, carla::rpc::ActorState InState) const
FString Id
Display ID that identifies the actor.
FString GetDescriptionFromStream(carla::streaming::detail::stream_id_type Id)
static FString GetTagAsString(crp::CityObjectLabel Tag)
Retrieve the tags of an already tagged actor.
static FBoundingBox GetActorBoundingBox(const AActor *Actor, uint8 InTagQueried=0xFF)
Compute the bounding box of the given Carla actor.
A description of a Carla Actor with all its variation.
FActorDescription Description
static FCarlaActor::ActorType FActorRegistry_GetActorType(const AActor *Actor)
FCarlaActor::IdType IdType
void AttachActors(AActor *Child, AActor *Parent, EAttachmentType InAttachmentType=EAttachmentType::Rigid)
Attach Child to Parent.
A view over an actor and its properties.
FCarlaActor * Register(AActor &Actor, FActorDescription Description, IdType DesiredId=0)
Register the Actor in the database.
IdType GetActorId() const
FCarlaActor * FindCarlaActor(IdType Id)
static TSharedPtr< FCarlaActor > ConstructCarlaActor(IdType ActorId, AActor *Actor, TSharedPtr< const FActorInfo > Info, ActorType Type, carla::rpc::ActorState InState, UWorld *World)
A view over an actor and its properties.