43 auto Controller = Cast<AWheeledVehicleAIController>(
Vehicle->GetController());
44 if (Controller !=
nullptr)
76 auto Walker = Cast<APawn>(View.
GetActor());
77 auto Controller = Walker !=
nullptr ? Cast<AWalkerController>(Walker->GetController()) :
nullptr;
78 if (Controller !=
nullptr)
88 auto* TrafficLightComponent =
93 if(TrafficLightComponent ==
nullptr)
117 static bool bLoggedMissingController =
false;
118 if (!bLoggedMissingController)
120 bLoggedMissingController =
true;
121 UE_LOG(LogCarla, Warning, TEXT(
"TrafficLightComponent doesn't have any Controller assigned (logged once; affected lights stream zeroed state)"));
126 static bool bLoggedMissingGroup =
false;
127 if (!bLoggedMissingGroup)
129 bLoggedMissingGroup =
true;
130 UE_LOG(LogCarla, Warning, TEXT(
"TrafficLightComponent doesn't have any Group assigned (logged once; affected lights stream zeroed state)"));
135 const FString fstring_sign_id = TrafficLightComponent->GetSignId();
136 const std::string sign_id = carla::rpc::FromFString(fstring_sign_id);
138 size_t sign_id_length = sign_id.length();
139 if(max_size < sign_id_length)
141 UE_LOG(LogCarla, Warning, TEXT(
"The max size of a signal id is 32. %s (%d)"), *fstring_sign_id, sign_id.length());
142 sign_id_length = max_size;
159 auto TrafficSign = Cast<ATrafficSignBase>(View.
GetActor());
160 if (TrafficSign !=
nullptr)
162 USignComponent* TrafficSignComponent =
163 Cast<USignComponent>(TrafficSign->FindComponentByClass<USignComponent>());
165 if(TrafficSignComponent)
167 const FString fstring_sign_id = TrafficSignComponent->GetSignId();
168 const std::string sign_id = carla::rpc::FromFString(fstring_sign_id);
170 size_t sign_id_length = sign_id.length();
171 if(max_size < sign_id_length)
173 UE_LOG(LogCarla, Warning, TEXT(
"The max size of a signal id is 32. %s (%d)"), *fstring_sign_id, sign_id.length());
174 sign_id_length = max_size;
221 static bool bLoggedMissingGroup =
false;
222 if (!bLoggedMissingGroup)
224 bLoggedMissingGroup =
true;
225 UE_LOG(LogCarla, Warning, TEXT(
"TrafficLight doesn't have any Group assigned (logged once; affected lights stream zeroed state)"));
230 const FString fstring_sign_id = ActorData->
SignId;
231 const std::string sign_id = carla::rpc::FromFString(fstring_sign_id);
233 size_t sign_id_length = sign_id.length();
234 if(max_size < sign_id_length)
236 UE_LOG(LogCarla, Warning, TEXT(
"The max size of a signal id is 32. %s (%d)"), *fstring_sign_id, sign_id.length());
237 sign_id_length = max_size;
254 const FString fstring_sign_id = ActorData->
SignId;
255 const std::string sign_id = carla::rpc::FromFString(fstring_sign_id);
257 size_t sign_id_length = sign_id.length();
258 if(max_size < sign_id_length)
260 UE_LOG(LogCarla, Warning, TEXT(
"The max size of a signal id is 32. %s (%d)"), *fstring_sign_id, sign_id.length());
261 sign_id_length = max_size;
308 bool PendingLightUpdates)
310 TRACE_CPUPROFILER_EVENT_SCOPE_STR(__FUNCTION__);
318 auto total_size =
sizeof(Serializer::Header) +
sizeof(ActorDynamicState) * Registry.
Num();
319 auto current_size = 0;
321 buffer.reset(total_size);
322 auto write_data = [¤t_size, &buffer](
const auto &data)
324 auto begin = buffer.begin() + current_size;
325 std::memcpy(begin, &data,
sizeof(data));
326 current_size +=
sizeof(data);
329 constexpr float TO_METERS = 1e-2;
332 Serializer::Header header;
333 header.episode_id = Episode.
GetId();
334 header.platform_timestamp = FPlatformTime::Seconds();
335 header.delta_seconds = DeltaSeconds;
337 FIntVector MapOriginInMeters = MapOrigin / 100;
340 uint8_t simulation_state = (SimulationState::MapChange * MapChange);
341 simulation_state |= (SimulationState::PendingLightUpdate * PendingLightUpdates);
343 header.simulation_state =
static_cast<SimulationState
>(simulation_state);
348 for (
auto& It : Registry)
353 FTransform ActorTransform;
354 FVector Velocity(0.0f);
364 Velocity = TO_METERS * ActorData->
Velocity;
377 if (Actor ==
nullptr)
402 ActorDynamicState info = {
415 buffer.resize(current_size);
417 check(buffer.size() == current_size);
419 return std::move(buffer);
void BroadcastTick(const UCarlaEpisode &Episode, float DeltaSeconds, bool MapChange, bool PendingLightUpdate)
Send a message to every connected client with the info about the given Episode.