CARLA
Loading...
Searching...
No Matches
carla::client::World Class Reference

#include <World.h>

Public Member Functions

void ApplyColorTextureToObject (const std::string &actor_name, const rpc::MaterialParameter &parameter, const rpc::TextureColor &Texture)
void ApplyColorTextureToObjects (const std::vector< std::string > &objects_names, const rpc::MaterialParameter &parameter, const rpc::TextureColor &Texture)
void ApplyFloatColorTextureToObject (const std::string &actor_name, const rpc::MaterialParameter &parameter, const rpc::TextureFloatColor &Texture)
void ApplyFloatColorTextureToObjects (const std::vector< std::string > &objects_names, const rpc::MaterialParameter &parameter, const rpc::TextureFloatColor &Texture)
uint64_t ApplySettings (const rpc::EpisodeSettings &settings, time_duration timeout)
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)
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)
std::vector< rpc::LabelledPoint > CastRay (geom::Location start_location, geom::Location end_location) const
void ClearSkyLightMap ()
void EnableEnvironmentObjects (std::vector< uint64_t > env_objects_ids, bool enable) const
void FreezeAllTrafficLights (bool frozen)
SharedPtr< Actor > GetActor (ActorId id) const
 Find actor by id, return nullptr if not found.
SharedPtr< ActorList > GetActors () const
 Return a list with all the actors currently present in the world.
SharedPtr< ActorList > GetActors (const std::vector< ActorId > &actor_ids) const
 Return a list with the actors requested by ActorId.
SharedPtr< BlueprintLibrary > GetBlueprintLibrary () const
 Return the list of blueprints available in this world.
std::vector< geom::Transform > GetEgoSpawnPoints () const
 Get all ego spawn points available in the level.
std::vector< rpc::EnvironmentObject > GetEnvironmentObjects (uint8_t queried_tag) const
detail::EpisodeProxy GetEpisode () const
uint64_t GetId () const
 Get the id of the episode associated with this world.
float GetIMUSensorGravity () const
 Get gravity value used for the IMU sensor accelerometer calculation.
std::vector< geom::BoundingBox > GetLevelBBs (uint8_t queried_tag) const
 Returns all the BBs of all the elements of the level.
SharedPtr< LightManager > GetLightManager () const
SharedPtr< Map > GetMap () const
 Return the map that describes this world.
std::vector< std::string > GetNamesOfAllObjects () const
bool GetPublishTF () const
 Get whether ROS2 TF information is being published.
std::optional< geom::Location > GetRandomLocationFromNavigation () const
 Get a random location from the pedestrians navigation mesh.
rpc::EpisodeSettings GetSettings () const
WorldSnapshot GetSnapshot () const
 Return a snapshot of the world at this moment.
SharedPtr< Actor > GetSpectator () const
 Return the spectator actor.
SharedPtr< Actor > GetTrafficLight (const Landmark &landmark) const
SharedPtr< Actor > GetTrafficLightFromOpenDRIVE (const road::SignId &sign_id) const
std::vector< SharedPtr< Actor > > GetTrafficLightsFromWaypoint (const Waypoint &waypoint, double distance) const
std::vector< SharedPtr< Actor > > GetTrafficLightsInJunction (const road::JuncId junc_id) const
SharedPtr< Actor > GetTrafficSign (const Landmark &landmark) const
rpc::VehicleLightStateList GetVehiclesLightStates () const
 Returns a list of pairs where the firts element is the vehicle ID and the second one is the light state.
rpc::WeatherParameters GetWeather () const
 Retrieve the weather parameters currently active in the world.
std::optional< rpc::LabelledPoint > GroundProjection (geom::Location location, float search_distance=10000.0) const
bool HasSkyLightMap () const
bool IsWeatherEnabled () const
 Query if the Weather is enabled or not.
void LoadLevelLayer (rpc::MapLayer map_layers) const
DebugHelper MakeDebugHelper () const
size_t OnTick (std::function< void(WorldSnapshot)> callback)
 Register a callback to be called every time a world tick is received.
World & operator= (const World &)=default
World & operator= (World &&)=default
std::optional< rpc::LabelledPoint > ProjectPoint (geom::Location location, geom::Vector3D direction, float search_distance=10000.f) const
void RemoveOnTick (size_t callback_id)
 Remove a callback registered with OnTick.
void ResetAllTrafficLights ()
void SetIMUSensorGravity (float gravity)
 Set gravity value used for the IMU sensor accelerometer calculation.
void SetPedestriansCrossFactor (float percentage)
 set the probability that an agent could cross the roads in its path following percentage of 0.0f means no pedestrian can cross roads percentage of 0.5f means 50% of all pedestrians can cross roads percentage of 1.0f means all pedestrians can cross roads if needed
void SetPedestriansSeed (unsigned int seed)
 set the seed to use with random numbers in the pedestrians module
void SetPublishTF (bool publish_tf)
 Set whether to publish ROS2 TF information.
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 world frame (column 0 = azimuth 0 = +X, azimuth grows toward +Y; row 0 = zenith) becomes the sky light's cubemap (ambient + reflections) at the given intensity, replacing the real-time atmosphere capture until ClearSkyLightMap.
void SetWeather (const rpc::WeatherParameters &weather)
 Change the weather in the simulation.
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 SpawnCustomMesh (const std::vector< float > &vertices, const std::vector< uint32_t > &triangles, const std::string &material)
 Spawns a static procedural mesh with collision.
uint64_t Tick (time_duration timeout)
 Signal the simulator to continue to next tick (only has effect on synchronous mode).
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 UnloadLevelLayer (rpc::MapLayer map_layers) const
WorldSnapshot WaitForTick (time_duration timeout) const
 Block calling thread until a world tick is received.
 World (const World &)=default
 World (detail::EpisodeProxy episode)
 World (World &&)=default
 ~World ()

Private Attributes

detail::EpisodeProxy _episode

Detailed Description

Definition at line 45 of file World.h.

Constructor & Destructor Documentation

◆ World() [1/3]

carla::client::World::World ( detail::EpisodeProxy episode)
inlineexplicit

Definition at line 48 of file World.h.

References _episode.

Referenced by operator=(), operator=(), World(), and World().

◆ ~World()

carla::client::World::~World ( )
inline

Definition at line 50 of file World.h.

◆ World() [2/3]

carla::client::World::World ( const World & )
default

References World().

◆ World() [3/3]

carla::client::World::World ( World && )
default

References World().

Member Function Documentation

◆ ApplyColorTextureToObject()

void carla::client::World::ApplyColorTextureToObject ( const std::string & actor_name,
const rpc::MaterialParameter & parameter,
const rpc::TextureColor & Texture )

◆ ApplyColorTextureToObjects()

void carla::client::World::ApplyColorTextureToObjects ( const std::vector< std::string > & objects_names,
const rpc::MaterialParameter & parameter,
const rpc::TextureColor & Texture )

◆ ApplyFloatColorTextureToObject()

void carla::client::World::ApplyFloatColorTextureToObject ( const std::string & actor_name,
const rpc::MaterialParameter & parameter,
const rpc::TextureFloatColor & Texture )

◆ ApplyFloatColorTextureToObjects()

void carla::client::World::ApplyFloatColorTextureToObjects ( const std::vector< std::string > & objects_names,
const rpc::MaterialParameter & parameter,
const rpc::TextureFloatColor & Texture )

◆ ApplySettings()

uint64_t carla::client::World::ApplySettings ( const rpc::EpisodeSettings & settings,
time_duration timeout )

◆ ApplyTexturesToObject()

void carla::client::World::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 )

◆ ApplyTexturesToObjects()

void carla::client::World::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 )

◆ CastRay()

std::vector< rpc::LabelledPoint > carla::client::World::CastRay ( geom::Location start_location,
geom::Location end_location ) const

◆ ClearSkyLightMap()

void carla::client::World::ClearSkyLightMap ( )

◆ EnableEnvironmentObjects()

void carla::client::World::EnableEnvironmentObjects ( std::vector< uint64_t > env_objects_ids,
bool enable ) const

◆ FreezeAllTrafficLights()

void carla::client::World::FreezeAllTrafficLights ( bool frozen)

◆ GetActor()

SharedPtr< Actor > carla::client::World::GetActor ( ActorId id) const

Find actor by id, return nullptr if not found.

Definition at line 118 of file World.cpp.

References _episode, and carla::client::detail::EpisodeProxyImpl< PointerT >::Lock().

◆ GetActors() [1/2]

◆ GetActors() [2/2]

SharedPtr< ActorList > carla::client::World::GetActors ( const std::vector< ActorId > & actor_ids) const

Return a list with the actors requested by ActorId.

Definition at line 132 of file World.cpp.

References _episode, and carla::client::detail::EpisodeProxyImpl< PointerT >::Lock().

◆ GetBlueprintLibrary()

SharedPtr< BlueprintLibrary > carla::client::World::GetBlueprintLibrary ( ) const

Return the list of blueprints available in this world.

This blueprints can be used to spawning actor into the world.

Definition at line 38 of file World.cpp.

References _episode, and carla::client::detail::EpisodeProxyImpl< PointerT >::Lock().

◆ GetEgoSpawnPoints()

std::vector< geom::Transform > carla::client::World::GetEgoSpawnPoints ( ) const

Get all ego spawn points available in the level.

Definition at line 380 of file World.cpp.

References _episode, and carla::client::detail::EpisodeProxyImpl< PointerT >::Lock().

◆ GetEnvironmentObjects()

std::vector< rpc::EnvironmentObject > carla::client::World::GetEnvironmentObjects ( uint8_t queried_tag) const

◆ GetEpisode()

detail::EpisodeProxy carla::client::World::GetEpisode ( ) const
inline

Definition at line 184 of file World.h.

References _episode.

◆ GetId()

uint64_t carla::client::World::GetId ( ) const
inline

Get the id of the episode associated with this world.

Definition at line 59 of file World.h.

References _episode, and carla::client::detail::EpisodeProxyImpl< PointerT >::GetId().

◆ GetIMUSensorGravity()

float carla::client::World::GetIMUSensorGravity ( ) const

Get gravity value used for the IMU sensor accelerometer calculation.

Definition at line 102 of file World.cpp.

References _episode, and carla::client::detail::EpisodeProxyImpl< PointerT >::Lock().

◆ GetLevelBBs()

std::vector< geom::BoundingBox > carla::client::World::GetLevelBBs ( uint8_t queried_tag) const

Returns all the BBs of all the elements of the level.

Definition at line 253 of file World.cpp.

References _episode, and carla::client::detail::EpisodeProxyImpl< PointerT >::Lock().

◆ GetLightManager()

SharedPtr< LightManager > carla::client::World::GetLightManager ( ) const

◆ GetMap()

SharedPtr< Map > carla::client::World::GetMap ( ) const

◆ GetNamesOfAllObjects()

std::vector< std::string > carla::client::World::GetNamesOfAllObjects ( ) const

◆ GetPublishTF()

bool carla::client::World::GetPublishTF ( ) const

Get whether ROS2 TF information is being published.

Definition at line 376 of file World.cpp.

References _episode, and carla::client::detail::EpisodeProxyImpl< PointerT >::Lock().

◆ GetRandomLocationFromNavigation()

std::optional< geom::Location > carla::client::World::GetRandomLocationFromNavigation ( ) const

Get a random location from the pedestrians navigation mesh.

Definition at line 46 of file World.cpp.

References _episode, and carla::client::detail::EpisodeProxyImpl< PointerT >::Lock().

◆ GetSettings()

rpc::EpisodeSettings carla::client::World::GetSettings ( ) const

◆ GetSnapshot()

WorldSnapshot carla::client::World::GetSnapshot ( ) const

Return a snapshot of the world at this moment.

Definition at line 114 of file World.cpp.

References _episode, and carla::client::detail::EpisodeProxyImpl< PointerT >::Lock().

Referenced by ApplySettings().

◆ GetSpectator()

SharedPtr< Actor > carla::client::World::GetSpectator ( ) const

Return the spectator actor.

The spectator controls the view in the simulator window.

Definition at line 50 of file World.cpp.

References _episode, and carla::client::detail::EpisodeProxyImpl< PointerT >::Lock().

◆ GetTrafficLight()

SharedPtr< Actor > carla::client::World::GetTrafficLight ( const Landmark & landmark) const

◆ GetTrafficLightFromOpenDRIVE()

SharedPtr< Actor > carla::client::World::GetTrafficLightFromOpenDRIVE ( const road::SignId & sign_id) const

◆ GetTrafficLightsFromWaypoint()

std::vector< SharedPtr< Actor > > carla::client::World::GetTrafficLightsFromWaypoint ( const Waypoint & waypoint,
double distance ) const

◆ GetTrafficLightsInJunction()

std::vector< SharedPtr< Actor > > carla::client::World::GetTrafficLightsInJunction ( const road::JuncId junc_id) const

◆ GetTrafficSign()

SharedPtr< Actor > carla::client::World::GetTrafficSign ( const Landmark & landmark) const

◆ GetVehiclesLightStates()

rpc::VehicleLightStateList carla::client::World::GetVehiclesLightStates ( ) const

Returns a list of pairs where the firts element is the vehicle ID and the second one is the light state.

Definition at line 42 of file World.cpp.

References _episode, and carla::client::detail::EpisodeProxyImpl< PointerT >::Lock().

◆ GetWeather()

rpc::WeatherParameters carla::client::World::GetWeather ( ) const

Retrieve the weather parameters currently active in the world.

Definition at line 94 of file World.cpp.

References _episode, and carla::client::detail::EpisodeProxyImpl< PointerT >::Lock().

◆ GroundProjection()

std::optional< rpc::LabelledPoint > carla::client::World::GroundProjection ( geom::Location location,
float search_distance = 10000.0 ) const

Definition at line 276 of file World.cpp.

References ProjectPoint().

◆ HasSkyLightMap()

bool carla::client::World::HasSkyLightMap ( ) const

◆ IsWeatherEnabled()

bool carla::client::World::IsWeatherEnabled ( ) const

Query if the Weather is enabled or not.

Definition at line 110 of file World.cpp.

References _episode, and carla::client::detail::EpisodeProxyImpl< PointerT >::Lock().

◆ LoadLevelLayer()

void carla::client::World::LoadLevelLayer ( rpc::MapLayer map_layers) const

◆ MakeDebugHelper()

DebugHelper carla::client::World::MakeDebugHelper ( ) const
inline

Definition at line 180 of file World.h.

References _episode.

◆ OnTick()

size_t carla::client::World::OnTick ( std::function< void(WorldSnapshot)> callback)

Register a callback to be called every time a world tick is received.

Returns
ID of the callback, use it to remove the callback.

Definition at line 165 of file World.cpp.

References _episode, and carla::client::detail::EpisodeProxyImpl< PointerT >::Lock().

◆ operator=() [1/2]

World & carla::client::World::operator= ( const World & )
default

References World().

◆ operator=() [2/2]

World & carla::client::World::operator= ( World && )
default

References World().

◆ ProjectPoint()

std::optional< rpc::LabelledPoint > carla::client::World::ProjectPoint ( geom::Location location,
geom::Vector3D direction,
float search_distance = 10000.f ) const

Definition at line 267 of file World.cpp.

References _episode, and carla::client::detail::EpisodeProxyImpl< PointerT >::Lock().

Referenced by GroundProjection().

◆ RemoveOnTick()

void carla::client::World::RemoveOnTick ( size_t callback_id)

Remove a callback registered with OnTick.

Definition at line 169 of file World.cpp.

References _episode, and carla::client::detail::EpisodeProxyImpl< PointerT >::Lock().

◆ ResetAllTrafficLights()

void carla::client::World::ResetAllTrafficLights ( )

◆ SetIMUSensorGravity()

void carla::client::World::SetIMUSensorGravity ( float gravity)

Set gravity value used for the IMU sensor accelerometer calculation.

Definition at line 106 of file World.cpp.

References _episode, and carla::client::detail::EpisodeProxyImpl< PointerT >::Lock().

◆ SetPedestriansCrossFactor()

void carla::client::World::SetPedestriansCrossFactor ( float percentage)

set the probability that an agent could cross the roads in its path following percentage of 0.0f means no pedestrian can cross roads percentage of 0.5f means 50% of all pedestrians can cross roads percentage of 1.0f means all pedestrians can cross roads if needed

Definition at line 179 of file World.cpp.

References _episode, and carla::client::detail::EpisodeProxyImpl< PointerT >::Lock().

◆ SetPedestriansSeed()

void carla::client::World::SetPedestriansSeed ( unsigned int seed)

set the seed to use with random numbers in the pedestrians module

Definition at line 183 of file World.cpp.

References _episode, and carla::client::detail::EpisodeProxyImpl< PointerT >::Lock().

◆ SetPublishTF()

void carla::client::World::SetPublishTF ( bool publish_tf)

Set whether to publish ROS2 TF information.

Definition at line 372 of file World.cpp.

References _episode, and carla::client::detail::EpisodeProxyImpl< PointerT >::Lock().

◆ SetSkyLightMap()

void carla::client::World::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 world frame (column 0 = azimuth 0 = +X, azimuth grows toward +Y; row 0 = zenith) becomes the sky light's cubemap (ambient + reflections) at the given intensity, replacing the real-time atmosphere capture until ClearSkyLightMap.

Persists across weather changes; dropped by a level load (LoadWorld / ReloadWorld), so set it again after loading. face_size is the cubemap resolution.

Definition at line 353 of file World.cpp.

References _episode, and carla::client::detail::EpisodeProxyImpl< PointerT >::Lock().

◆ SetWeather()

void carla::client::World::SetWeather ( const rpc::WeatherParameters & weather)

Change the weather in the simulation.

Definition at line 98 of file World.cpp.

References _episode, and carla::client::detail::EpisodeProxyImpl< PointerT >::Lock().

◆ SpawnActor()

SharedPtr< Actor > carla::client::World::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.

If a parent is provided, the actor is attached to parent.

Definition at line 138 of file World.cpp.

References _episode, and carla::client::detail::EpisodeProxyImpl< PointerT >::Lock().

Referenced by TrySpawnActor().

◆ SpawnCustomMesh()

void carla::client::World::SpawnCustomMesh ( const std::vector< float > & vertices,
const std::vector< uint32_t > & triangles,
const std::string & material )

Spawns a static procedural mesh with collision.

Vertices are a flat (x, y, z) triple list in metres, client coordinate frame; triangles index vertex triples. Material is a semantic hint ("grass", "road", "dirt", "sidewalk") or a full UE object path. The mesh lives until the world is reloaded.

Definition at line 238 of file World.cpp.

References _episode, and carla::client::detail::EpisodeProxyImpl< PointerT >::Lock().

◆ Tick()

uint64_t carla::client::World::Tick ( time_duration timeout)

Signal the simulator to continue to next tick (only has effect on synchronous mode).

Returns
The id of the frame that this call started.

Definition at line 173 of file World.cpp.

References _episode, carla::client::detail::EpisodeProxyImpl< PointerT >::Lock(), and carla::time_duration::milliseconds().

Referenced by ApplySettings().

◆ TrySpawnActor()

SharedPtr< Actor > carla::client::World::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.

Definition at line 146 of file World.cpp.

References SpawnActor().

◆ UnloadLevelLayer()

void carla::client::World::UnloadLevelLayer ( rpc::MapLayer map_layers) const

◆ WaitForTick()

WorldSnapshot carla::client::World::WaitForTick ( time_duration timeout) const

Block calling thread until a world tick is received.

Definition at line 158 of file World.cpp.

References _episode, carla::client::detail::EpisodeProxyImpl< PointerT >::Lock(), and carla::time_duration::milliseconds().

Referenced by ApplySettings().

Member Data Documentation

◆ _episode


The documentation for this class was generated from the following files: