47 return _episode.
Lock()->GetRandomLocationFromNavigation();
60 uint64_t
id =
_episode.
Lock()->SetEpisodeSettings(settings);
66 using namespace std::literals::chrono_literals;
68 const auto number_of_attemps = 30u;
69 uint64_t tics_correct = 0;
70 for (
auto i = 0u; i < number_of_attemps; i++) {
73 const double error = abs(new_settings.
fixed_delta_seconds.value() - curr_snapshot.GetTimestamp().delta_seconds);
74 if (error < std::numeric_limits<float>::epsilon())
77 if (tics_correct >= 2)
89 log_warning(
"World::ApplySettings: After", number_of_attemps,
" attemps, the settings were not correctly set. Please check that everything is consistent.");
120 auto description = simulator->GetActorById(
id);
121 return description.has_value() ?
122 simulator->MakeActor(std::move(*description)) :
143 return _episode.
Lock()->SpawnActor(blueprint, transform, parent_actor, attachment_type);
152 return SpawnActor(blueprint, transform, parent_actor, attachment_type);
153 }
catch (
const std::exception &) {
166 return _episode.
Lock()->RegisterOnTickEvent(std::move(callback));
190 std::string landmark_id = landmark.
GetId();
191 for (
size_t i = 0; i < actors->size(); i++) {
195 if(sign && (sign->
GetSignId() == landmark_id)) {
206 std::string landmark_id = landmark.
GetId();
207 for (
size_t i = 0; i < actors->size(); i++) {
211 if(tl && (tl->
GetSignId() == landmark_id)) {
222 for (
size_t i = 0; i < actors->size(); i++) {
239 const std::vector<float> &vertices,
240 const std::vector<uint32_t> &triangles,
241 const std::string &material) {
242 _episode.
Lock()->SpawnCustomMesh(vertices, triangles, material);
258 return _episode.
Lock()->GetEnvironmentObjects(queried_tag);
262 std::vector<uint64_t> env_objects_ids,
264 _episode.
Lock()->EnableEnvironmentObjects(env_objects_ids, enable);
269 auto result =
_episode.
Lock()->ProjectPoint(location, direction, search_distance);
271 return result.second;
279 return ProjectPoint(location, DownVector, search_distance);
284 return _episode.
Lock()->CastRay(start_location, end_location);
289 std::vector<SharedPtr<Actor>> Result;
290 std::vector<SharedPtr<Landmark>> landmarks =
292 std::set<std::string> added_signals;
293 for (
auto& landmark : landmarks) {
297 if(added_signals.count(landmark->GetId()) == 0) {
298 Result.emplace_back(traffic_light);
299 added_signals.insert(landmark->GetId());
309 std::vector<SharedPtr<Actor>> Result;
313 const std::unique_ptr<road::Controller>& controller =
318 Result.emplace_back(traffic_light);
326 const std::string &object_name,
329 _episode.
Lock()->ApplyColorTextureToObjects({object_name}, parameter, Texture);
333 const std::vector<std::string> &objects_name,
336 _episode.
Lock()->ApplyColorTextureToObjects(objects_name, parameter, Texture);
340 const std::string &object_name,
343 _episode.
Lock()->ApplyColorTextureToObjects({object_name}, parameter, Texture);
347 const std::vector<std::string> &objects_name,
350 _episode.
Lock()->ApplyColorTextureToObjects(objects_name, parameter, Texture);
385 const std::string &object_name,
399 if (ao_roughness_metallic_emissive_texture.
GetWidth() &&
400 ao_roughness_metallic_emissive_texture.
GetHeight()) {
404 ao_roughness_metallic_emissive_texture);
413 const std::vector<std::string> &objects_names,
427 if (ao_roughness_metallic_emissive_texture.
GetWidth() &&
428 ao_roughness_metallic_emissive_texture.
GetHeight()) {
432 ao_roughness_metallic_emissive_texture);
std::map< std::string, unsigned int > junction
static bool Match(const char *str, const char *wildcard_pattern)
Match str with the Unix shell-style wildcard_pattern.
Contains all the necessary information for spawning an Actor.
Represents an actor in the simulation.
Class containing a reference to RoadInfoSignal.
std::string GetId() const
carla::road::SignId GetSignId() const
std::vector< SharedPtr< Landmark > > GetAllLandmarksInDistance(double distance, bool stop_at_junction=false) const
Returns a list of landmarks from the current position to a certain distance.
float GetIMUSensorGravity() const
Get gravity value used for the IMU sensor accelerometer calculation.
SharedPtr< ActorList > GetActors() const
Return a list with all the actors currently present in the world.
void ApplyColorTextureToObject(const std::string &actor_name, const rpc::MaterialParameter ¶meter, const rpc::TextureColor &Texture)
std::vector< geom::BoundingBox > GetLevelBBs(uint8_t queried_tag) const
Returns all the BBs of all the elements of the level.
void LoadLevelLayer(rpc::MapLayer map_layers) const
SharedPtr< BlueprintLibrary > GetBlueprintLibrary() const
Return the list of blueprints available in this world.
void EnableEnvironmentObjects(std::vector< uint64_t > env_objects_ids, bool enable) const
void FreezeAllTrafficLights(bool frozen)
std::vector< geom::Transform > GetEgoSpawnPoints() const
Get all ego spawn points available in the level.
WorldSnapshot GetSnapshot() const
Return a snapshot of the world at this moment.
void ResetAllTrafficLights()
bool HasSkyLightMap() const
void SetPublishTF(bool publish_tf)
Set whether to publish ROS2 TF information.
rpc::WeatherParameters GetWeather() const
Retrieve the weather parameters currently active in the world.
SharedPtr< Actor > GetSpectator() const
Return the spectator actor.
rpc::VehicleLightStateList GetVehiclesLightStates() const
Returns a list of pairs where the firts element is the vehicle ID and the second one is the light sta...
SharedPtr< Actor > GetActor(ActorId id) const
Find actor by id, return nullptr if not found.
SharedPtr< Actor > GetTrafficLight(const Landmark &landmark) const
SharedPtr< Actor > TrySpawnActor(const ActorBlueprint &blueprint, const geom::Transform &transform, Actor *parent=nullptr, rpc::AttachmentType attachment_type=rpc::AttachmentType::Rigid) noexcept
Same as SpawnActor but return nullptr on failure instead of throwing an exception.
void SetPedestriansCrossFactor(float percentage)
set the probability that an agent could cross the roads in its path following percentage of 0....
uint64_t Tick(time_duration timeout)
Signal the simulator to continue to next tick (only has effect on synchronous mode).
detail::EpisodeProxy _episode
std::optional< rpc::LabelledPoint > GroundProjection(geom::Location location, float search_distance=10000.0) const
std::optional< rpc::LabelledPoint > ProjectPoint(geom::Location location, geom::Vector3D direction, float search_distance=10000.f) const
bool IsWeatherEnabled() const
Query if the Weather is enabled or not.
WorldSnapshot WaitForTick(time_duration timeout) const
Block calling thread until a world tick is received.
std::vector< SharedPtr< Actor > > GetTrafficLightsInJunction(const road::JuncId junc_id) const
void ApplyTexturesToObject(const std::string &actor_name, const rpc::TextureColor &diffuse_texture, const rpc::TextureFloatColor &emissive_texture, const rpc::TextureFloatColor &normal_texture, const rpc::TextureFloatColor &ao_roughness_metallic_emissive_texture)
std::vector< std::string > GetNamesOfAllObjects() const
uint64_t ApplySettings(const rpc::EpisodeSettings &settings, time_duration timeout)
void SetSkyLightMap(const rpc::TextureFloatColor &panorama, float intensity=1.0f, int32_t face_size=512)
Light the scene with an environment map: an equirectangular linear RGB(A) float panorama in the CARLA...
std::vector< rpc::EnvironmentObject > GetEnvironmentObjects(uint8_t queried_tag) const
SharedPtr< Map > GetMap() const
Return the map that describes this world.
std::vector< rpc::LabelledPoint > CastRay(geom::Location start_location, geom::Location end_location) const
std::vector< SharedPtr< Actor > > GetTrafficLightsFromWaypoint(const Waypoint &waypoint, double distance) const
void SetIMUSensorGravity(float gravity)
Set gravity value used for the IMU sensor accelerometer calculation.
void SpawnCustomMesh(const std::vector< float > &vertices, const std::vector< uint32_t > &triangles, const std::string &material)
Spawns a static procedural mesh with collision.
bool GetPublishTF() const
Get whether ROS2 TF information is being published.
void ApplyColorTextureToObjects(const std::vector< std::string > &objects_names, const rpc::MaterialParameter ¶meter, const rpc::TextureColor &Texture)
void ApplyFloatColorTextureToObjects(const std::vector< std::string > &objects_names, const rpc::MaterialParameter ¶meter, const rpc::TextureFloatColor &Texture)
SharedPtr< Actor > SpawnActor(const ActorBlueprint &blueprint, const geom::Transform &transform, Actor *parent=nullptr, rpc::AttachmentType attachment_type=rpc::AttachmentType::Rigid)
Spawn an actor into the world based on the blueprint provided at transform.
void SetPedestriansSeed(unsigned int seed)
set the seed to use with random numbers in the pedestrians module
void ApplyTexturesToObjects(const std::vector< std::string > &objects_names, const rpc::TextureColor &diffuse_texture, const rpc::TextureFloatColor &emissive_texture, const rpc::TextureFloatColor &normal_texture, const rpc::TextureFloatColor &ao_roughness_metallic_emissive_texture)
SharedPtr< LightManager > GetLightManager() const
std::optional< geom::Location > GetRandomLocationFromNavigation() const
Get a random location from the pedestrians navigation mesh.
SharedPtr< Actor > GetTrafficSign(const Landmark &landmark) const
void ApplyFloatColorTextureToObject(const std::string &actor_name, const rpc::MaterialParameter ¶meter, const rpc::TextureFloatColor &Texture)
void RemoveOnTick(size_t callback_id)
Remove a callback registered with OnTick.
SharedPtr< Actor > GetTrafficLightFromOpenDRIVE(const road::SignId &sign_id) const
size_t OnTick(std::function< void(WorldSnapshot)> callback)
Register a callback to be called every time a world tick is received.
void SetWeather(const rpc::WeatherParameters &weather)
Change the weather in the simulation.
rpc::EpisodeSettings GetSettings() const
void UnloadLevelLayer(rpc::MapLayer map_layers) const
SharedPtrType Lock() const
Same as TryLock but never return nullptr.
const std::set< ContId > & GetControllers() const
static bool IsTrafficLight(const std::string &type)
std::optional< double > fixed_delta_seconds
uint32_t GetWidth() const
uint32_t GetHeight() const
Positive time duration up to milliseconds resolution.
static time_duration milliseconds(size_t timeout)
@ Tex_Ao_Roughness_Metallic_Emissive
std::vector< std::pair< ActorId, VehicleLightState::flag_type > > VehicleLightStateList
This file contains definitions of common data structures used in traffic manager.
std::shared_ptr< T > SharedPtr
static void log_warning(Args &&... args)