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.");
99 _episode.
Lock()->SetIMUISensorGravity(NewIMUISensorGravity);
109 auto description = simulator->GetActorById(
id);
110 return description.has_value() ?
111 simulator->MakeActor(std::move(*description)) :
132 const std::string& socket_name) {
141 const std::string& socket_name)
noexcept {
143 return SpawnActor(blueprint, transform, parent_actor, attachment_type, socket_name);
144 }
catch (
const std::exception &) {
157 return _episode.
Lock()->RegisterOnTickEvent(std::move(callback));
181 std::string landmark_id = landmark.
GetId();
182 for (
size_t i = 0; i < actors->size(); i++) {
186 if(sign && (sign->
GetSignId() == landmark_id)) {
197 std::string landmark_id = landmark.
GetId();
198 for (
size_t i = 0; i < actors->size(); i++) {
202 if(tl && (tl->
GetSignId() == landmark_id)) {
213 for (
size_t i = 0; i < actors->size(); i++) {
242 return _episode.
Lock()->GetEnvironmentObjects(queried_tag);
246 std::vector<uint64_t> env_objects_ids,
248 _episode.
Lock()->EnableEnvironmentObjects(env_objects_ids, enable);
253 auto result =
_episode.
Lock()->ProjectPoint(location, direction, search_distance);
255 return result.second;
263 return ProjectPoint(location, DownVector, search_distance);
268 return _episode.
Lock()->CastRay(start_location, end_location);
272 const Waypoint& waypoint,
double distance)
const {
273 std::vector<SharedPtr<Actor>> Result;
274 std::vector<SharedPtr<Landmark>> landmarks =
276 std::set<std::string> added_signals;
277 for (
auto& landmark : landmarks) {
281 if(added_signals.count(landmark->GetId()) == 0) {
282 Result.emplace_back(traffic_light);
283 added_signals.insert(landmark->GetId());
293 std::vector<SharedPtr<Actor>> Result;
295 const road::Junction* junction = map->GetMap().GetJunction(junc_id);
297 const std::unique_ptr<road::Controller>& controller =
302 Result.emplace_back(traffic_light);
310 const std::string &object_name,
313 _episode.
Lock()->ApplyColorTextureToObjects({object_name}, parameter, Texture);
317 const std::vector<std::string> &objects_name,
320 _episode.
Lock()->ApplyColorTextureToObjects(objects_name, parameter, Texture);
324 const std::string &object_name,
327 _episode.
Lock()->ApplyColorTextureToObjects({object_name}, parameter, Texture);
331 const std::vector<std::string> &objects_name,
334 _episode.
Lock()->ApplyColorTextureToObjects(objects_name, parameter, Texture);
342 const std::string &object_name,
356 if (ao_roughness_metallic_emissive_texture.
GetWidth() &&
357 ao_roughness_metallic_emissive_texture.
GetHeight()) {
361 ao_roughness_metallic_emissive_texture);
370 const std::vector<std::string> &objects_names,
384 if (ao_roughness_metallic_emissive_texture.
GetWidth() &&
385 ao_roughness_metallic_emissive_texture.
GetHeight()) {
389 ao_roughness_metallic_emissive_texture);
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
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)
boost::optional< rpc::LabelledPoint > GroundProjection(geom::Location location, float search_distance=10000.0) const
WorldSnapshot GetSnapshot() const
Return a snapshot of the world at this moment.
void ResetAllTrafficLights()
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
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
SharedPtr< Actor > TrySpawnActor(const ActorBlueprint &blueprint, const geom::Transform &transform, Actor *parent=nullptr, rpc::AttachmentType attachment_type=rpc::AttachmentType::Rigid, const std::string &socket_name="") noexcept
Same as SpawnActor but return nullptr on failure instead of throwing an exception.
boost::optional< rpc::LabelledPoint > ProjectPoint(geom::Location location, geom::Vector3D direction, float search_distance=10000.f) const
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 SetIMUISensorGravity(float NewIMUISensorGravity)
Set Gravity value used for IMUI Sensor accelerometer calculation
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)
boost::optional< geom::Location > GetRandomLocationFromNavigation() const
Get a random location from the pedestrians navigation mesh
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 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)
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
SharedPtr< Actor > SpawnActor(const ActorBlueprint &blueprint, const geom::Transform &transform, Actor *parent=nullptr, rpc::AttachmentType attachment_type=rpc::AttachmentType::Rigid, const std::string &socket_name="")
Spawn an actor into the world based on the blueprint provided at transform.
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.
float GetIMUISensorGravity() const
Get Gravity value used for IMUI Sensor accelerometer calculation
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)
boost::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.
static void log_warning(Args &&... args)
boost::shared_ptr< T > SharedPtr
Use this SharedPtr (boost::shared_ptr) to keep compatibility with boost::python, but it would be nice...