45 return _episode.
Lock()->GetRandomLocationFromNavigation();
58 uint64_t
id =
_episode.
Lock()->SetEpisodeSettings(settings);
64 using namespace std::literals::chrono_literals;
66 const auto number_of_attemps = 30u;
67 uint64_t tics_correct = 0;
68 for (
auto i = 0u; i < number_of_attemps; i++) {
71 const double error = abs(new_settings.
fixed_delta_seconds.get() - curr_snapshot.GetTimestamp().delta_seconds);
72 if (error < std::numeric_limits<float>::epsilon())
75 if (tics_correct >= 2)
81 log_warning(
"World::ApplySettings: After", number_of_attemps,
" attemps, the settings were not correctly set. Please check that everything is consistent.");
100 auto description = simulator->GetActorById(
id);
101 return description.has_value() ?
102 simulator->MakeActor(std::move(*description)) :
123 return _episode.
Lock()->SpawnActor(blueprint, transform, parent_actor, attachment_type);
132 return SpawnActor(blueprint, transform, parent_actor, attachment_type);
133 }
catch (
const std::exception &) {
146 return _episode.
Lock()->RegisterOnTickEvent(std::move(callback));
170 std::string landmark_id = landmark.
GetId();
171 for (
size_t i = 0; i < actors->size(); i++) {
175 if(sign && (sign->
GetSignId() == landmark_id)) {
186 std::string landmark_id = landmark.
GetId();
187 for (
size_t i = 0; i < actors->size(); i++) {
191 if(tl && (tl->
GetSignId() == landmark_id)) {
202 for (
size_t i = 0; i < actors->size(); i++) {
231 return _episode.
Lock()->GetEnvironmentObjects(queried_tag);
235 std::vector<uint64_t> env_objects_ids,
237 _episode.
Lock()->EnableEnvironmentObjects(env_objects_ids, enable);
242 auto result =
_episode.
Lock()->ProjectPoint(location, direction, search_distance);
244 return result.second;
252 return ProjectPoint(location, DownVector, search_distance);
257 return _episode.
Lock()->CastRay(start_location, end_location);
261 const Waypoint& waypoint,
double distance)
const {
262 std::vector<SharedPtr<Actor>> Result;
263 std::vector<SharedPtr<Landmark>> landmarks =
265 std::set<std::string> added_signals;
266 for (
auto& landmark : landmarks) {
270 if(added_signals.count(landmark->GetId()) == 0) {
271 Result.emplace_back(traffic_light);
272 added_signals.insert(landmark->GetId());
282 std::vector<SharedPtr<Actor>> Result;
284 const road::Junction* junction = map->GetMap().GetJunction(junc_id);
286 const std::unique_ptr<road::Controller>& controller =
291 Result.emplace_back(traffic_light);
299 const std::string &object_name,
302 _episode.
Lock()->ApplyColorTextureToObjects({object_name}, parameter, Texture);
306 const std::vector<std::string> &objects_name,
309 _episode.
Lock()->ApplyColorTextureToObjects(objects_name, parameter, Texture);
313 const std::string &object_name,
316 _episode.
Lock()->ApplyColorTextureToObjects({object_name}, parameter, Texture);
320 const std::vector<std::string> &objects_name,
323 _episode.
Lock()->ApplyColorTextureToObjects(objects_name, parameter, Texture);
331 const std::string &object_name,
345 if (ao_roughness_metallic_emissive_texture.
GetWidth() &&
346 ao_roughness_metallic_emissive_texture.
GetHeight()) {
350 ao_roughness_metallic_emissive_texture);
359 const std::vector<std::string> &objects_names,
373 if (ao_roughness_metallic_emissive_texture.
GetWidth() &&
374 ao_roughness_metallic_emissive_texture.
GetHeight()) {
378 ao_roughness_metallic_emissive_texture);
std::vector< std::string > GetNamesOfAllObjects() const
SharedPtr< BlueprintLibrary > GetBlueprintLibrary() const
Return the list of blueprints available in this world.
std::vector< SharedPtr< Actor > > GetTrafficLightsInJunction(const road::JuncId junc_id) const
void RemoveOnTick(size_t callback_id)
Remove a callback registered with OnTick.
static time_duration milliseconds(size_t timeout)
void SetWeather(const rpc::WeatherParameters &weather)
Change the weather in the simulation.
SharedPtr< ActorList > GetActors() const
Return a list with all the actors currently present in the world.
void SetPedestriansCrossFactor(float percentage)
set the probability that an agent could cross the roads in its path following percentage of 0...
size_t OnTick(std::function< void(WorldSnapshot)> callback)
Register a callback to be called every time a world tick is received.
boost::optional< rpc::LabelledPoint > ProjectPoint(geom::Location location, geom::Vector3D direction, float search_distance=10000.f) const
const std::set< ContId > & GetControllers() const
void UnloadLevelLayer(rpc::MapLayer map_layers) const
SharedPtr< Actor > GetSpectator() const
Return the spectator actor.
SharedPtr< LightManager > GetLightManager() const
boost::shared_ptr< T > SharedPtr
Use this SharedPtr (boost::shared_ptr) to keep compatibility with boost::python, but it would be nice...
std::vector< std::pair< ActorId, VehicleLightState::flag_type > > VehicleLightStateList
std::vector< rpc::LabelledPoint > CastRay(geom::Location start_location, geom::Location end_location) const
This file contains definitions of common data structures used in traffic manager. ...
SharedPtr< Map > GetMap() const
Return the map that describes this world.
void ApplyColorTextureToObject(const std::string &actor_name, const rpc::MaterialParameter ¶meter, const rpc::TextureColor &Texture)
Class containing a reference to RoadInfoSignal.
uint64_t Tick(time_duration timeout)
Signal the simulator to continue to next tick (only has effect on synchronous mode).
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...
detail::EpisodeProxy _episode
boost::optional< double > fixed_delta_seconds
std::string GetId() const
SharedPtr< Actor > GetTrafficLightFromOpenDRIVE(const road::SignId &sign_id) const
void ApplyColorTextureToObjects(const std::vector< std::string > &objects_names, const rpc::MaterialParameter ¶meter, const rpc::TextureColor &Texture)
static bool Match(const char *str, const char *wildcard_pattern)
Match str with the Unix shell-style wildcard_pattern.
SharedPtr< Actor > GetTrafficSign(const Landmark &landmark) const
void ResetAllTrafficLights()
void LoadLevelLayer(rpc::MapLayer map_layers) const
SharedPtr< Actor > GetActor(ActorId id) const
Find actor by id, return nullptr if not found.
carla::road::SignId GetSignId() const
static void log_warning(Args &&... args)
void SetPedestriansSeed(unsigned int seed)
set the seed to use with random numbers in the pedestrians module
void ApplyFloatColorTextureToObject(const std::string &actor_name, const rpc::MaterialParameter ¶meter, const rpc::TextureFloatColor &Texture)
boost::optional< rpc::LabelledPoint > GroundProjection(geom::Location location, float search_distance=10000.0) const
rpc::WeatherParameters GetWeather() const
Retrieve the weather parameters currently active in the world.
void FreezeAllTrafficLights(bool frozen)
void EnableEnvironmentObjects(std::vector< uint64_t > env_objects_ids, bool enable) const
std::vector< SharedPtr< Actor > > GetTrafficLightsFromWaypoint(const Waypoint &waypoint, double distance) const
Represents an actor in the simulation.
uint64_t ApplySettings(const rpc::EpisodeSettings &settings, time_duration timeout)
std::vector< geom::BoundingBox > GetLevelBBs(uint8_t queried_tag) const
Returns all the BBs of all the elements of the level.
Positive time duration up to milliseconds resolution.
uint32_t GetHeight() const
static bool IsTrafficLight(const std::string &type)
Contains all the necessary information for spawning an Actor.
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.
SharedPtrType Lock() const
Same as TryLock but never return nullptr.
rpc::EpisodeSettings GetSettings() 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.
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 ApplyFloatColorTextureToObjects(const std::vector< std::string > &objects_names, const rpc::MaterialParameter ¶meter, const rpc::TextureFloatColor &Texture)
WorldSnapshot GetSnapshot() const
Return a snapshot of the world at this moment.
std::vector< rpc::EnvironmentObject > GetEnvironmentObjects(uint8_t queried_tag) const
boost::optional< geom::Location > GetRandomLocationFromNavigation() const
Get a random location from the pedestrians navigation mesh.
SharedPtr< Actor > GetTrafficLight(const Landmark &landmark) 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)
uint32_t GetWidth() const
WorldSnapshot WaitForTick(time_duration timeout) const
Block calling thread until a world tick is received.
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)