#Python API reference This reference contains all the details the Python API. To consult a previous reference for a specific CARLA release, change the documentation version using the panel in the bottom right corner.
This will change the whole documentation to a previous state. Remember that the latest version is the `dev` branch and may show features not available in any packaged versions of CARLA.
## carla.AckermannControllerSettings Manages the settings of the Ackermann PID controller. ### Instance Variables - **speed_kp** (_float_) Proportional term of the speed PID controller. - **speed_ki** (_float_) Integral term of the speed PID controller. - **speed_kd** (_float_) Derivative term of the speed PID controller. - **accel_kp** (_float_) Proportional term of the acceleration PID controller. - **accel_ki** (_float_) Integral term of the acceleration PID controller. - **accel_kd** (_float_) Derivative term of the acceleration PID controller. ### Methods - **\__init__**(**self**, **speed_kp**=0.15, **speed_ki**=0.0, **speed_kd**=0.25, **accel_kp**=0.01, **accel_ki**=0.0, **accel_kd**=0.01) - **Parameters:** - `speed_kp` (_float_) - `speed_ki` (_float_) - `speed_kd` (_float_) - `accel_kp` (_float_) - `accel_ki` (_float_) - `accel_kd` (_float_) ##### Dunder methods - **\__eq__**(**self**, **other**=[carla.AckermannControllerSettings](#carla.AckermannControllerSettings)) - **\__ne__**(**self**, **other**=[carla.AckermannControllerSettings](#carla.AckermannControllerSettings)) - **\__str__**(**self**) --- ## carla.Actor CARLA defines actors as anything that plays a role in the simulation or can be moved around. That includes: pedestrians, vehicles, sensors and traffic signs (considering traffic lights as part of these). Actors are spawned in the simulation by [carla.World](#carla.World) and they need for a [carla.ActorBlueprint](#carla.ActorBlueprint) to be created. These blueprints belong into a library provided by CARLA, find more about them [here](bp_library.md). ### Instance Variables - **attributes** (_dict_) A dictionary containing the attributes of the blueprint this actor was based on. - **id** (_int_) Identifier for this actor. Unique during a given episode. - **type_id** (_str_) The identifier of the blueprint this actor was based on, e.g. `vehicle.ford.mustang`. - **is_alive** (_bool_) Returns whether this object was destroyed using this actor handle. - **is_active** (_bool_) Returns whether this actor is active (True) or not (False). - **is_dormant** (_bool_) Returns whether this actor is dormant (True) or not (False) - the opposite of is_active. - **parent** (_[carla.Actor](#carla.Actor)_) Actors may be attached to a parent actor that they will follow around. This is said actor. - **semantic_tags** (_list(int)_) A list of semantic tags provided by the blueprint listing components for this actor. E.g. a traffic light could be tagged with `Pole` and `TrafficLight`. These tags are used by the semantic segmentation sensor. Find more about this and other sensors [here](ref_sensors.md#semantic-segmentation-camera). - **actor_state** (_[carla.ActorState](#carla.ActorState)_) Returns the [carla.ActorState](#carla.ActorState), which can identify if the actor is Active, Dormant or Invalid. - **bounding_box** (_[carla.BoundingBox](#carla.BoundingBox)_) Bounding box containing the geometry of the actor. Its location and rotation are relative to the actor it is attached to. ### Methods - **add_angular_impulse**(**self**, **angular_impulse**) Applies an angular impulse at the center of mass of the actor. This method should be used for instantaneous torques, usually applied once. Use __add_torque()__ to apply rotation forces over a period of time. - **Parameters:** - `angular_impulse` (_[carla.Vector3D](#carla.Vector3D) - degrees*s_) - Angular impulse vector in global coordinates. - **add_force**(**self**, **force**) Applies a force at the center of mass of the actor. This method should be used for forces that are applied over a certain period of time. Use __add_impulse()__ to apply an impulse that only lasts an instant. - **Parameters:** - `force` (_[carla.Vector3D](#carla.Vector3D) - N_) - Force vector in global coordinates. - **add_impulse**(**self**, **impulse**) Applies an impulse at the center of mass of the actor. This method should be used for instantaneous forces, usually applied once. Use __add_force()__ to apply forces over a period of time. - **Parameters:** - `impulse` (_[carla.Vector3D](#carla.Vector3D) - N*s_) - Impulse vector in global coordinates. - **add_torque**(**self**, **torque**) Applies a torque at the center of mass of the actor. This method should be used for torques that are applied over a certain period of time. Use __add_angular_impulse()__ to apply a torque that only lasts an instant. - **Parameters:** - `torque` (_[carla.Vector3D](#carla.Vector3D) - degrees_) - Torque vector in global coordinates. - **destroy**(**self**) Tells the simulator to destroy this actor and returns True if it was successful. It has no effect if it was already destroyed. - **Return:** _bool_ - **Warning:** _This method blocks the script until the destruction is completed by the simulator. _ - **disable_constant_velocity**(**self**) Disables any constant velocity previously set for a [carla.Vehicle](#carla.Vehicle) actor. - **enable_constant_velocity**(**self**, **velocity**) Sets a vehicle's velocity vector to a constant value over time. The resulting velocity will be approximately the `velocity` being set, as with __set_target_velocity()__. - **Parameters:** - `velocity` (_[carla.Vector3D](#carla.Vector3D) - m/s_) - Velocity vector in local space. - **Note:** _Only [carla.Vehicle](#carla.Vehicle) actors can use this method. _ - **Warning:** _Enabling a constant velocity for a vehicle managed by the [Traffic Manager](https://[carla.readthedocs.io](#carla.readthedocs.io)/en/latest/adv_traffic_manager/) may cause conflicts. This method overrides any changes in velocity by the TM. _ ##### Getters - **get_acceleration**(**self**) Returns the actor's 3D acceleration vector the client recieved during last tick. The method does not call the simulator. - **Return:** _[carla.Vector3D](#carla.Vector3D) - m/s2_ - **get_angular_velocity**(**self**) Returns the actor's angular velocity vector the client recieved during last tick. The method does not call the simulator. - **Return:** _[carla.Vector3D](#carla.Vector3D) - deg/s_ - **get_location**(**self**) Returns the actor's location the client recieved during last tick. The method does not call the simulator. - **Return:** _[carla.Location](#carla.Location) - meters_ - **Setter:** _[carla.Actor.set_location](#carla.Actor.set_location)_ - **get_transform**(**self**) Returns the actor's transform (location and rotation) the client recieved during last tick. The method does not call the simulator. - **Return:** _[carla.Transform](#carla.Transform)_ - **Setter:** _[carla.Actor.set_transform](#carla.Actor.set_transform)_ - **get_velocity**(**self**) Returns the actor's velocity vector the client recieved during last tick. The method does not call the simulator. - **Return:** _[carla.Vector3D](#carla.Vector3D) - m/s_ - **get_world**(**self**) Returns the world this actor belongs to. - **Return:** _[carla.World](#carla.World)_ ##### Setters - **set_enable_gravity**(**self**, **enabled**) Enables or disables gravity for the actor. __Default__ is True. - **Parameters:** - `enabled` (_bool_) - **set_location**(**self**, **location**) Teleports the actor to a given location. - **Parameters:** - `location` (_[carla.Location](#carla.Location) - meters_) - **Getter:** _[carla.Actor.get_location](#carla.Actor.get_location)_ - **set_simulate_physics**(**self**, **enabled**=True) Enables or disables the simulation of physics on this actor. - **Parameters:** - `enabled` (_bool_) - **set_target_angular_velocity**(**self**, **angular_velocity**) Sets the actor's angular velocity vector. This is applied before the physics step so the resulting angular velocity will be affected by external forces such as friction. - **Parameters:** - `angular_velocity` (_[carla.Vector3D](#carla.Vector3D) - deg/s_) - **set_target_velocity**(**self**, **velocity**) Sets the actor's velocity vector. This is applied before the physics step so the resulting angular velocity will be affected by external forces such as friction. - **Parameters:** - `velocity` (_[carla.Vector3D](#carla.Vector3D)_) - **set_transform**(**self**, **transform**) Teleports the actor to a given transform (location and rotation). - **Parameters:** - `transform` (_[carla.Transform](#carla.Transform)_) - **Getter:** _[carla.Actor.get_transform](#carla.Actor.get_transform)_ ##### Dunder methods - **\__str__**(**self**) --- ## carla.ActorAttribute CARLA provides a library of blueprints for actors that can be accessed as [carla.BlueprintLibrary](#carla.BlueprintLibrary). Each of these blueprints has a series of attributes defined internally. Some of these are modifiable, others are not. A list of recommended values is provided for those that can be set. ### Instance Variables - **id** (_str_) The attribute's name and identifier in the library. - **is_modifiable** (_bool_) It is True if the attribute's value can be modified. - **recommended_values** (_list(str)_) A list of values suggested by those who designed the blueprint. - **type** (_[carla.ActorAttributeType](#carla.ActorAttributeType)_) The attribute's parameter type. ### Methods - **as_bool**(**self**) Reads the attribute as boolean value. - **as_color**(**self**) Reads the attribute as [carla.Color](#carla.Color). - **as_float**(**self**) Reads the attribute as float. - **as_int**(**self**) Reads the attribute as int. - **as_str**(**self**) Reads the attribute as string. ##### Dunder methods - **\__bool__**(**self**) - **\__eq__**(**self**, **other**=bool / int / float / str / [carla.Color](#carla.Color) / [carla.ActorAttribute](#carla.ActorAttribute)) Returns true if this actor's attribute and `other` are the same. - **Return:** _bool_ - **\__float__**(**self**) - **\__int__**(**self**) - **\__ne__**(**self**, **other**=bool / int / float / str / [carla.Color](#carla.Color) / [carla.ActorAttribute](#carla.ActorAttribute)) Returns true if this actor's attribute and `other` are different. - **Return:** _bool_ - **\__nonzero__**(**self**) Returns true if this actor's attribute is not zero or null. - **Return:** _bool_ - **\__str__**(**self**) --- ## carla.ActorAttributeType CARLA provides a library of blueprints for actors in [carla.BlueprintLibrary](#carla.BlueprintLibrary) with different attributes each. This class defines the types those at [carla.ActorAttribute](#carla.ActorAttribute) can be as a series of enum. All this information is managed internally and listed here for a better comprehension of how CARLA works. ### Instance Variables - **Bool** - **Int** - **Float** - **String** - **RGBColor** --- ## carla.ActorBlueprint CARLA provides a blueprint library for actors that can be consulted through [carla.BlueprintLibrary](#carla.BlueprintLibrary). Each of these consists of an identifier for the blueprint and a series of attributes that may be modifiable or not. This class is the intermediate step between the library and the actor creation. Actors need an actor blueprint to be spawned. These store the information for said blueprint in an object with its attributes and some tags to categorize them. The user can then customize some attributes and eventually spawn the actors through [carla.World](#carla.World). ### Instance Variables - **id** (_str_) The identifier of said blueprint inside the library. E.g. `walker.pedestrian.0001`. - **tags** (_list(str)_) A list of tags each blueprint has that helps describing them. E.g. `['0001', 'pedestrian', 'walker']`. ### Methods - **has_attribute**(**self**, **id**) Returns True if the blueprint contains the attribute `id`. - **Parameters:** - `id` (_str_) - e.g. `gender` would return **True** for pedestrians' blueprints. - **Return:** _bool_ - **has_tag**(**self**, **tag**) Returns True if the blueprint has the specified `tag` listed. - **Parameters:** - `tag` (_str_) - e.g. 'walker'. - **Return:** _bool_ - **match_tags**(**self**, **wildcard_pattern**) Returns True if any of the tags listed for this blueprint matches `wildcard_pattern`. Matching follows [fnmatch](https://docs.python.org/2/library/fnmatch.html) standard. - **Parameters:** - `wildcard_pattern` (_str_) - **Return:** _bool_ ##### Getters - **get_attribute**(**self**, **id**) Returns the actor's attribute with `id` as identifier if existing. - **Parameters:** - `id` (_str_) - **Return:** _[carla.ActorAttribute](#carla.ActorAttribute)_ - **Setter:** _[carla.ActorBlueprint.set_attribute](#carla.ActorBlueprint.set_attribute)_ ##### Setters - **set_attribute**(**self**, **id**, **value**) If the `id` attribute is modifiable, changes its value to `value`. - **Parameters:** - `id` (_str_) - The identifier for the attribute that is intended to be changed. - `value` (_str_) - The new value for said attribute. - **Getter:** _[carla.ActorBlueprint.get_attribute](#carla.ActorBlueprint.get_attribute)_ ##### Dunder methods - **\__iter__**(**self**) Iterate over the [carla.ActorAttribute](#carla.ActorAttribute) that this blueprint has. - **\__len__**(**self**) Returns the amount of attributes for this blueprint. - **\__str__**(**self**) --- ## carla.ActorList A class that contains every actor present on the scene and provides access to them. The list is automatically created and updated by the server and it can be returned using [carla.World](#carla.World). ### Methods - **filter**(**self**, **wildcard_pattern**) Filters a list of Actors matching `wildcard_pattern` against their variable __type_id__ (which identifies the blueprint used to spawn them). Matching follows [fnmatch](https://docs.python.org/2/library/fnmatch.html) standard. - **Parameters:** - `wildcard_pattern` (_str_) - **Return:** _list_ - **find**(**self**, **actor_id**) Finds an actor using its identifier and returns it or None if it is not present. - **Parameters:** - `actor_id` (_int_) - **Return:** _[carla.Actor](#carla.Actor)_ ##### Dunder methods - **\__getitem__**(**self**, **pos**=int) Returns the actor corresponding to `pos` position in the list. - **Return:** _[carla.Actor](#carla.Actor)_ - **\__iter__**(**self**) Iterate over the [carla.Actor](#carla.Actor) contained in the list. - **\__len__**(**self**) Returns the amount of actors listed. - **Return:** _int_ - **\__str__**(**self**) Parses to the ID for every actor listed. - **Return:** _str_ --- ## carla.ActorSnapshot A class that comprises all the information for an actor at a certain moment in time. These objects are contained in a [carla.WorldSnapshot](#carla.WorldSnapshot) and sent to the client once every tick. ### Instance Variables - **id** (_int_) An identifier for the snapshot itself. ### Methods ##### Getters - **get_acceleration**(**self**) Returns the acceleration vector registered for an actor in that tick. - **Return:** _[carla.Vector3D](#carla.Vector3D) - m/s2_ - **get_angular_velocity**(**self**) Returns the angular velocity vector registered for an actor in that tick. - **Return:** _[carla.Vector3D](#carla.Vector3D) - rad/s_ - **get_transform**(**self**) Returns the actor's transform (location and rotation) for an actor in that tick. - **Return:** _[carla.Transform](#carla.Transform)_ - **get_velocity**(**self**) Returns the velocity vector registered for an actor in that tick. - **Return:** _[carla.Vector3D](#carla.Vector3D) - m/s_ --- ## carla.ActorState Class that defines the state of an actor. ### Instance Variables - **Invalid** An actor is Invalid if a problem has occurred. - **Active** An actor is Active when it visualized and can affect other actors. - **Dormant** An actor is Dormant when it is not visualized and will not affect other actors through physics. For example, actors are dormant if they are on an unloaded tile in a large map. --- ## carla.AttachmentType Class that defines attachment options between an actor and its parent. When spawning actors, these can be attached to another actor so their position changes accordingly. This is specially useful for sensors. The snipet in [carla.World.spawn_actor](#carla.World.spawn_actor) shows some sensors being attached to a car when spawned. Note that the attachment type is declared as an enum within the class. ### Instance Variables - **Rigid** With this fixed attachment the object follow its parent position strictly. This is the recommended attachment to retrieve precise data from the simulation. - **SpringArm** An attachment that expands or retracts the position of the actor, depending on its parent. This attachment is only recommended to record videos from the simulation where a smooth movement is needed. SpringArms are an Unreal Engine component so [check the UE docs](https://docs.unrealengine.com/en-US/Gameplay/HowTo/UsingCameras/SpringArmComponents/index.html) to learn more about them.
Warning: The SpringArm attachment presents weird behaviors when an actor is spawned with a relative translation in the Z-axis (e.g. child_location = Location(0,0,2)). - **SpringArmGhost** An attachment like the previous one but that does not make the collision test, and that means that it does not expands or retracts the position of the actor. The term **ghost** is because then the camera can cross walls and other geometries. This attachment is only recommended to record videos from the simulation where a smooth movement is needed. SpringArms are an Unreal Engine component so [check the UE docs](https://docs.unrealengine.com/en-US/Gameplay/HowTo/UsingCameras/SpringArmComponents/index.html) to learn more about them.
Warning: The SpringArm attachment presents weird behaviors when an actor is spawned with a relative translation in the Z-axis (e.g. child_location = Location(0,0,2)). --- ## carla.BlueprintLibrary A class that contains the blueprints provided for actor spawning. Its main application is to return [carla.ActorBlueprint](#carla.ActorBlueprint) objects needed to spawn actors. Each blueprint has an identifier and attributes that may or may not be modifiable. The library is automatically created by the server and can be accessed through [carla.World](#carla.World). [Here](bp_library.md) is a reference containing every available blueprint and its specifics. ### Methods - **filter**(**self**, **wildcard_pattern**) Filters a list of blueprints matching the `wildcard_pattern` against the id and tags of every blueprint contained in this library and returns the result as a new one. Matching follows [fnmatch](https://docs.python.org/2/library/fnmatch.html) standard. - **Parameters:** - `wildcard_pattern` (_str_) - **Return:** _[carla.BlueprintLibrary](#carla.BlueprintLibrary)_ - **filter_by_attribute**(**self**, **name**, **value**) Filters a list of blueprints with a given attribute matching the `value` against every blueprint contained in this library and returns the result as a new one. Matching follows [fnmatch](https://docs.python.org/2/library/fnmatch.html) standard. - **Parameters:** - `name` (_str_) - `value` (_str_) - **Return:** _[carla.BlueprintLibrary](#carla.BlueprintLibrary)_ - **find**(**self**, **id**) Returns the blueprint corresponding to that identifier. - **Parameters:** - `id` (_str_) - **Return:** _[carla.ActorBlueprint](#carla.ActorBlueprint)_ ##### Dunder methods - **\__getitem__**(**self**, **pos**=int) Returns the blueprint stored in `pos` position inside the data structure containing them. - **Return:** _[carla.ActorBlueprint](#carla.ActorBlueprint)_ - **\__iter__**(**self**) Iterate over the [carla.ActorBlueprint](#carla.ActorBlueprint) stored in the library. - **\__len__**(**self**) Returns the amount of blueprints comprising the library. - **Return:** _int_ - **\__str__**(**self**) Parses the identifiers for every blueprint to string. - **Return:** _string_ --- ## carla.BoundingBox Bounding boxes contain the geometry of an actor or an element in the scene. They can be used by [carla.DebugHelper](#carla.DebugHelper) or a [carla.Client](#carla.Client) to draw their shapes for debugging. Check out the snipet in [carla.DebugHelper.draw_box](#carla.DebugHelper.draw_box) where a snapshot of the world is used to draw bounding boxes for traffic lights. ### Instance Variables - **extent** (_[carla.Vector3D](#carla.Vector3D) - meters_) Vector from the center of the box to one vertex. The value in each axis equals half the size of the box for that axis. `extent.x * 2` would return the size of the box in the X-axis. - **location** (_[carla.Location](#carla.Location) - meters_) The center of the bounding box. - **rotation** (_[carla.Rotation](#carla.Rotation)_) The orientation of the bounding box. ### Methods - **\__init__**(**self**, **location**, **extent**) - **Parameters:** - `location` (_[carla.Location](#carla.Location)_) - Center of the box, relative to its parent. - `extent` (_[carla.Vector3D](#carla.Vector3D) - meters_) - Vector containing half the size of the box for every axis. - **contains**(**self**, **world_point**, **transform**) Returns **True** if a point passed in world space is inside this bounding box. - **Parameters:** - `world_point` (_[carla.Location](#carla.Location) - meters_) - The point in world space to be checked. - `transform` (_[carla.Transform](#carla.Transform)_) - Contains location and rotation needed to convert this object's local space to world space. - **Return:** _bool_ ##### Getters - **get_local_vertices**(**self**) Returns a list containing the locations of this object's vertices in local space. - **Return:** _list([carla.Location](#carla.Location))_ - **get_world_vertices**(**self**, **transform**) Returns a list containing the locations of this object's vertices in world space. - **Parameters:** - `transform` (_[carla.Transform](#carla.Transform)_) - Contains location and rotation needed to convert this object's local space to world space. - **Return:** _list([carla.Location](#carla.Location))_ ##### Dunder methods - **\__eq__**(**self**, **other**=[carla.BoundingBox](#carla.BoundingBox)) Returns true if both location and extent are equal for this and `other`. - **Return:** _bool_ - **\__ne__**(**self**, **other**=[carla.BoundingBox](#carla.BoundingBox)) Returns true if either location or extent are different for this and `other`. - **Return:** _bool_ - **\__str__**(**self**) Parses the location and extent of the bounding box to string. - **Return:** _str_ --- ## carla.CityObjectLabel Enum declaration that contains the different tags available to filter the bounding boxes returned by [carla.World.get_level_bbs](#carla.World.get_level_bbs)(). These values correspond to the [semantic tag](ref_sensors.md#semantic-segmentation-camera) that the elements in the scene have. ### Instance Variables - **None** - **Buildings** - **Fences** - **Other** - **Pedestrians** - **Poles** - **RoadLines** - **Roads** - **Sidewalks** - **TrafficSigns** - **Vegetation** - **Vehicles** - **Walls** - **Sky** - **Ground** - **Bridge** - **RailTrack** - **GuardRail** - **TrafficLight** - **Static** - **Dynamic** - **Water** - **Terrain** - **Any** --- ## carla.Client The Client connects CARLA to the server which runs the simulation. Both server and client contain a CARLA library (libcarla) with some differences that allow communication between them. Many clients can be created and each of these will connect to the RPC server inside the simulation to send commands. The simulation runs server-side. Once the connection is established, the client will only receive data retrieved from the simulation. Walkers are the exception. The client is in charge of managing pedestrians so, if you are running a simulation with multiple clients, some issues may arise. For example, if you spawn walkers through different clients, collisions may happen, as each client is only aware of the ones it is in charge of. The client also has a recording feature that saves all the information of a simulation while running it. This allows the server to replay it at will to obtain information and experiment with it. [Here](adv_recorder.md) is some information about how to use this recorder. ### Methods - **\__init__**(**self**, **host**=127.0.0.1, **port**=2000, **worker_threads**=0) Client constructor. - **Parameters:** - `host` (_str_) - IP address where a CARLA Simulator instance is running. Default is localhost (127.0.0.1). - `port` (_int_) - TCP port where the CARLA Simulator instance is running. Default are 2000 and the subsequent 2001. - `worker_threads` (_int_) - Number of working threads used for background updates. If 0, use all available concurrency. - **apply_batch**(**self**, **commands**) Executes a list of commands on a single simulation step and retrieves no information. If you need information about the response of each command, use the __apply_batch_sync()__ method. [Here](https://github.com/carla-simulator/carla/blob/master/PythonAPI/examples/generate_traffic.py) is an example on how to delete the actors that appear in [carla.ActorList](#carla.ActorList) all at once. - **Parameters:** - `commands` (_list_) - A list of commands to execute in batch. Each command is different and has its own parameters. They appear listed at the bottom of this page. - **apply_batch_sync**(**self**, **commands**, **due_tick_cue**=False) Executes a list of commands on a single simulation step, blocks until the commands are linked, and returns a list of command.Response that can be used to determine whether a single command succeeded or not. [Here](https://github.com/carla-simulator/carla/blob/master/PythonAPI/examples/generate_traffic.py) is an example of it being used to spawn actors. - **Parameters:** - `commands` (_list_) - A list of commands to execute in batch. The commands available are listed right above, in the method **apply_batch()**. - `due_tick_cue` (_bool_) - A boolean parameter to specify whether or not to perform a [carla.World.tick](#carla.World.tick) after applying the batch in _synchronous mode_. It is __False__ by default. - **Return:** _list(command.Response)_ - **generate_opendrive_world**(**self**, **opendrive**, **parameters**=(2.0, 50.0, 1.0, 0.6, true, true), **reset_settings**=True) Loads a new world with a basic 3D topology generated from the content of an OpenDRIVE file. This content is passed as a `string` parameter. It is similar to `client.load_world(map_name)` but allows for custom OpenDRIVE maps in server side. Cars can drive around the map, but there are no graphics besides the road and sidewalks. - **Parameters:** - `opendrive` (_str_) - Content of an OpenDRIVE file as `string`, __not the path to the `.xodr`__. - `parameters` (_[carla.OpendriveGenerationParameters](#carla.OpendriveGenerationParameters)_) - Additional settings for the mesh generation. If none are provided, default values will be used. - `reset_settings` (_bool_) - Option to reset the episode setting to default values, set to false to keep the current settings. This is useful to keep sync mode when changing map and to keep deterministic scenarios. - **load_world**(**self**, **map_name**, **reset_settings**=True, **map_layers**=[carla.MapLayer.All](#carla.MapLayer.All)) Creates a new world with default settings using `map_name` map. All actors in the current world will be destroyed. - **Parameters:** - `map_name` (_str_) - Name of the map to be used in this world. Accepts both full paths and map names, e.g. '/Game/Carla/Maps/Town01' or 'Town01'. Remember that these paths are dynamic. - `reset_settings` (_bool_) - Option to reset the episode setting to default values, set to false to keep the current settings. This is useful to keep sync mode when changing map and to keep deterministic scenarios. - `map_layers` (_[carla.MapLayer](#carla.MapLayer)_) - Layers of the map that will be loaded. By default all layers are loaded. This parameter works like a flag mask. - **Warning:** _`map_layers` are only available for "Opt" maps _ - **reload_world**(**self**, **reset_settings**=True) Reload the current world, note that a new world is created with default settings using the same map. All actors present in the world will be destroyed, __but__ traffic manager instances will stay alive. - **Parameters:** - `reset_settings` (_bool_) - Option to reset the episode setting to default values, set to false to keep the current settings. This is useful to keep sync mode when changing map and to keep deterministic scenarios. - **Raises:** RuntimeError when corresponding. - **replay_file**(**self**, **name**, **start**, **duration**, **follow_id**, **replay_sensors**) Load a new world with default settings using `map_name` map. All actors present in the current world will be destroyed, __but__ traffic manager instances will stay alive. - **Parameters:** - `name` (_str_) - Name of the file containing the information of the simulation. - `start` (_float - seconds_) - Time where to start playing the simulation. Negative is read as beginning from the end, being -10 just 10 seconds before the recording finished. - `duration` (_float - seconds_) - Time that will be reenacted using the information `name` file. If the end is reached, the simulation will continue. - `follow_id` (_int_) - ID of the actor to follow. If this is 0 then camera is disabled. - `replay_sensors` (_bool_) - Flag to enable or disable the spawn of sensors during playback. - **request_file**(**self**, **name**) Requests one of the required files returned by [carla.Client.get_required_files](#carla.Client.get_required_files). - **Parameters:** - `name` (_str_) - Name of the file you are requesting. - **show_recorder_actors_blocked**(**self**, **filename**, **min_time**, **min_distance**) The terminal will show the information registered for actors considered blocked. An actor is considered blocked when it does not move a minimum distance in a period of time, being these `min_distance` and `min_time`. - **Parameters:** - `filename` (_str_) - Name of the recorded file to load. - `min_time` (_float - seconds_) - Minimum time the actor has to move a minimum distance before being considered blocked. Default is 60 seconds. - `min_distance` (_float - centimeters_) - Minimum distance the actor has to move to not be considered blocked. Default is 100 centimeters. - **Return:** _string_ - **show_recorder_collisions**(**self**, **filename**, **category1**, **category2**) The terminal will show the collisions registered by the recorder. These can be filtered by specifying the type of actor involved. The categories will be specified in `category1` and `category2` as follows: 'h' = Hero, the one vehicle that can be controlled manually or managed by the user. 'v' = Vehicle 'w' = Walker 't' = Traffic light 'o' = Other 'a' = Any If you want to see only collisions between a vehicles and a walkers, use for `category1` as 'v' and `category2` as 'w' or vice versa. If you want to see all the collisions (filter off) you can use 'a' for both parameters. - **Parameters:** - `filename` (_str_) - Name or absolute path of the file recorded, depending on your previous choice. - `category1` (_single char_) - Character variable specifying a first type of actor involved in the collision. - `category2` (_single char_) - Character variable specifying the second type of actor involved in the collision. - **Return:** _string_ - **show_recorder_file_info**(**self**, **filename**, **show_all**) The information saved by the recorder will be parsed and shown in your terminal as text (frames, times, events, state, positions...). The information shown can be specified by using the `show_all` parameter. [Here](ref_recorder_binary_file_format.md) is some more information about how to read the recorder file. - **Parameters:** - `filename` (_str_) - Name or absolute path of the file recorded, depending on your previous choice. - `show_all` (_bool_) - If __True__, returns all the information stored for every frame (traffic light states, positions of all actors, orientation and animation data...). If __False__, returns a summary of key events and frames. - **Return:** _string_ - **start_recorder**(**self**, **filename**, **additional_data**=False) Enables the recording feature, which will start saving every information possible needed by the server to replay the simulation. - **Parameters:** - `filename` (_str_) - Name of the file to write the recorded data. A simple name will save the recording in 'CarlaUnreal/Saved/recording.log'. Otherwise, if some folder appears in the name, it will be considered an absolute path. - `additional_data` (_bool_) - Enables or disable recording non-essential data for reproducing the simulation (bounding box location, physics control parameters, etc). - **stop_recorder**(**self**) Stops the recording in progress. If you specified a path in `filename`, the recording will be there. If not, look inside `CarlaUnreal/Saved/`. - **stop_replayer**(**self**, **keep_actors**) Stop current replayer. - **Parameters:** - `keep_actors` (_bool_) - True if you want autoremove all actors from the replayer, or False to keep them. ##### Getters - **get_available_maps**(**self**) Returns a list of strings containing the paths of the maps available on server. These paths are dynamic, they will be created during the simulation and so you will not find them when looking up in your files. One of the possible returns for this method would be: ['/Game/Carla/Maps/Town01', '/Game/Carla/Maps/Town02', '/Game/Carla/Maps/Town03', '/Game/Carla/Maps/Town04', '/Game/Carla/Maps/Town05', '/Game/Carla/Maps/Town06', '/Game/Carla/Maps/Town07']. - **Return:** _list(str)_ - **get_client_version**(**self**) Returns the client libcarla version by consulting it in the "Version.h" file. Both client and server can use different libcarla versions but some issues may arise regarding unexpected incompatibilities. - **Return:** _str_ - **get_required_files**(**self**, **folder**, **download**=True) Asks the server which files are required by the client to use the current map. Option to download files automatically if they are not already in the cache. - **Parameters:** - `folder` (_str_) - Folder where files required by the client will be downloaded to. - `download` (_bool_) - If True, downloads files that are not already in cache. - **get_server_version**(**self**) Returns the server libcarla version by consulting it in the "Version.h" file. Both client and server should use the same libcarla version. - **Return:** _str_ - **get_trafficmanager**(**self**, **client_connection**=8000) Returns an instance of the traffic manager related to the specified port. If it does not exist, this will be created. - **Parameters:** - `client_connection` (_int_) - Port that will be used by the traffic manager. Default is `8000`. - **Return:** _[carla.TrafficManager](#carla.TrafficManager)_ - **get_world**(**self**) Returns the world object currently active in the simulation. This world will be later used for example to load maps. - **Return:** _[carla.World](#carla.World)_ ##### Setters - **set_files_base_folder**(**self**, **path**) - **Parameters:** - `path` (_str_) - Specifies the base folder where the local cache for required files will be placed. - **set_replayer_ignore_hero**(**self**, **ignore_hero**) - **Parameters:** - `ignore_hero` (_bool_) - Enables or disables playback of the hero vehicle during a playback of a recorded simulation. - **set_replayer_ignore_spectator**(**self**, **ignore_spectator**) - **Parameters:** - `ignore_spectator` (_bool_) - Determines whether the recorded spectator movements will be replicated by the replayer. - **set_replayer_time_factor**(**self**, **time_factor**=1.0) When used, the time speed of the reenacted simulation is modified at will. It can be used several times while a playback is in curse. - **Parameters:** - `time_factor` (_float_) - 1.0 means normal time speed. Greater than 1.0 means fast motion (2.0 would be double speed) and lesser means slow motion (0.5 would be half speed). - **set_timeout**(**self**, **seconds**) Sets the maximum time a network call is allowed before blocking it and raising a timeout exceeded error. - **Parameters:** - `seconds` (_float - seconds_) - New timeout value. Default is 5 seconds. --- ## carla.CollisionEvent Inherited from _[carla.SensorData](#carla.SensorData)_
Class that defines a collision data for sensor.other.collision. The sensor creates one of these for every collision detected. Each collision sensor produces one collision event per collision per frame. Multiple collision events may be produced in a single frame by collisions with multiple other actors. Learn more about this [here](ref_sensors.md#collision-detector). ### Instance Variables - **actor** (_[carla.Actor](#carla.Actor)_) The actor the sensor is attached to, the one that measured the collision. - **other_actor** (_[carla.Actor](#carla.Actor)_) The second actor involved in the collision. - **normal_impulse** (_[carla.Vector3D](#carla.Vector3D) - N*s_) Normal impulse resulting of the collision. --- ## carla.Color Class that defines a 32-bit RGBA color. ### Instance Variables - **r** (_int_) Red color (0-255). - **g** (_int_) Green color (0-255). - **b** (_int_) Blue color (0-255). - **a** (_int_) Alpha channel (0-255). ### Methods - **\__init__**(**self**, **r**=0, **g**=0, **b**=0, **a**=255) Initializes a color, black by default. - **Parameters:** - `r` (_int_) - `g` (_int_) - `b` (_int_) - `a` (_int_) ##### Dunder methods - **\__eq__**(**self**, **other**=[carla.Color](#carla.Color)) - **\__ne__**(**self**, **other**=[carla.Color](#carla.Color)) - **\__str__**(**self**) --- ## carla.ColorConverter Class that defines conversion patterns that can be applied to a [carla.Image](#carla.Image) in order to show information provided by [carla.Sensor](#carla.Sensor). Depth conversions cause a loss of accuracy, as sensors detect depth as float that is then converted to a grayscale value between 0 and 255. Take a look at the snipet in [carla.Sensor.listen](#carla.Sensor.listen) to see an example of how to create and save image data for sensor.camera.semantic_segmentation. ### Instance Variables - **CityScapesPalette** Converts the image to a segmented map using tags provided by the blueprint library. Used by the [semantic segmentation camera](ref_sensors.md#semantic-segmentation-camera). - **Depth** Converts the image to a linear depth map. Used by the [depth camera](ref_sensors.md#depth-camera). - **LogarithmicDepth** Converts the image to a depth map using a logarithmic scale, leading to better precision for small distances at the expense of losing it when further away. - **Raw** No changes applied to the image. Used by the [RGB camera](ref_sensors.md#rgb-camera). --- ## carla.DVSEvent Class that defines a DVS event. An event is a quadruple, so a tuple of 4 elements, with `x`, `y` pixel coordinate location, timestamp `t` and polarity `pol` of the event. Learn more about them [here](ref_sensors.md). ### Instance Variables - **x** (_int_) X pixel coordinate. - **y** (_int_) Y pixel coordinate. - **t** (_int_) Timestamp of the moment the event happened. - **pol** (_bool_) Polarity of the event. __True__ for positive and __False__ for negative. ### Methods ##### Dunder methods - **\__str__**(**self**) --- ## carla.DVSEventArray Class that defines a stream of events in [carla.DVSEvent](#carla.DVSEvent). Such stream is an array of arbitrary size depending on the number of events. This class also stores the field of view, the height and width of the image and the timestamp from convenience. Learn more about them [here](ref_sensors.md). ### Instance Variables - **fov** (_float - degrees_) Horizontal field of view of the image. - **height** (_int_) Image height in pixels. - **width** (_int_) Image width in pixels. - **raw_data** (_bytes_) ### Methods - **to_array**(**self**) Converts the stream of events to an array of int values in the following order [x, y, t, pol]. - **to_array_pol**(**self**) Returns an array with the polarity of all the events in the stream. - **to_array_t**(**self**) Returns an array with the timestamp of all the events in the stream. - **to_array_x**(**self**) Returns an array with X pixel coordinate of all the events in the stream. - **to_array_y**(**self**) Returns an array with Y pixel coordinate of all the events in the stream. - **to_image**(**self**) Converts the image following this pattern: blue indicates positive events, red indicates negative events. ##### Dunder methods - **\__getitem__**(**self**, **pos**=int) - **\__iter__**(**self**) Iterate over the [carla.DVSEvent](#carla.DVSEvent) retrieved as data. - **\__len__**(**self**) - **\__setitem__**(**self**, **pos**=int, **color**=[carla.Color](#carla.Color)) - **\__str__**(**self**) --- ## carla.DebugHelper Helper class part of [carla.World](#carla.World) that defines methods for creating debug shapes. By default, shapes last one second. They can be permanent, but take into account the resources needed to do so. Take a look at the snipets available for this class to learn how to debug easily in CARLA. ### Methods - **draw_arrow**(**self**, **begin**, **end**, **thickness**=0.1, **arrow_size**=0.1, **color**=(255,0,0), **life_time**=-1.0) Draws an arrow from `begin` to `end` pointing in that direction. - **Parameters:** - `begin` (_[carla.Location](#carla.Location) - meters_) - Point in the coordinate system where the arrow starts. - `end` (_[carla.Location](#carla.Location) - meters_) - Point in the coordinate system where the arrow ends and points towards to. - `thickness` (_float - meters_) - Density of the line. - `arrow_size` (_float - meters_) - Size of the tip of the arrow. - `color` (_[carla.Color](#carla.Color)_) - RGB code to color the object. Red by default. - `life_time` (_float - seconds_) - Shape's lifespan. By default it only lasts one frame. Set this to 0 for permanent shapes. - **draw_box**(**self**, **box**, **rotation**, **thickness**=0.1, **color**=(255,0,0), **life_time**=-1.0) Draws a box, ussually to act for object colliders. - **Parameters:** - `box` (_[carla.BoundingBox](#carla.BoundingBox)_) - Object containing a location and the length of a box for every axis. - `rotation` (_[carla.Rotation](#carla.Rotation) - degrees (pitch,yaw,roll)_) - Orientation of the box according to Unreal Engine's axis system. - `thickness` (_float - meters_) - Density of the lines that define the box. - `color` (_[carla.Color](#carla.Color)_) - RGB code to color the object. Red by default. - `life_time` (_float - seconds_) - Shape's lifespan. By default it only lasts one frame. Set this to 0 for permanent shapes. - **draw_line**(**self**, **begin**, **end**, **thickness**=0.1, **color**=(255,0,0), **life_time**=-1.0) Draws a line in between `begin` and `end`. - **Parameters:** - `begin` (_[carla.Location](#carla.Location) - meters_) - Point in the coordinate system where the line starts. - `end` (_[carla.Location](#carla.Location) - meters_) - Spot in the coordinate system where the line ends. - `thickness` (_float - meters_) - Density of the line. - `color` (_[carla.Color](#carla.Color)_) - RGB code to color the object. Red by default. - `life_time` (_float - seconds_) - Shape's lifespan. By default it only lasts one frame. Set this to 0 for permanent shapes. - **draw_point**(**self**, **location**, **size**=0.1, **color**=(255,0,0), **life_time**=-1.0) Draws a point `location`. - **Parameters:** - `location` (_[carla.Location](#carla.Location) - meters_) - Spot in the coordinate system to center the object. - `size` (_float - meters_) - Density of the point. - `color` (_[carla.Color](#carla.Color)_) - RGB code to color the object. Red by default. - `life_time` (_float - seconds_) - Shape's lifespan. By default it only lasts one frame. Set this to 0 for permanent shapes. - **draw_string**(**self**, **location**, **text**, **draw_shadow**=False, **color**=(255,0,0), **life_time**=-1.0) Draws a string in a given location of the simulation which can only be seen server-side. - **Parameters:** - `location` (_[carla.Location](#carla.Location) - meters_) - Spot in the simulation where the text will be centered. - `text` (_str_) - Text intended to be shown in the world. - `draw_shadow` (_bool_) - Casts a shadow for the string that could help in visualization. It is disabled by default. - `color` (_[carla.Color](#carla.Color)_) - RGB code to color the string. Red by default. - `life_time` (_float - seconds_) - Shape's lifespan. By default it only lasts one frame. Set this to 0 for permanent shapes. --- ## carla.EnvironmentObject Class that represents a geometry in the level, this geometry could be part of an actor formed with other EnvironmentObjects (ie: buildings). ### Instance Variables - **transform** (_[carla.Transform](#carla.Transform)_) Contains the location and orientation of the EnvironmentObject in world space. - **bounding_box** (_[carla.BoundingBox](#carla.BoundingBox)_) Object containing a location, rotation and the length of a box for every axis in world space. - **id** (_int_) Unique ID to identify the object in the level. - **name** (_string_) Name of the EnvironmentObject. - **type** (_[carla.CityObjectLabel](#carla.CityObjectLabel)_) Semantic tag. ### Methods ##### Dunder methods - **\__str__**(**self**) Parses the EnvironmentObject to a string and shows them in command line. - **Return:** _str_ --- ## carla.FloatColor Class that defines a float RGBA color. ### Instance Variables - **r** (_float_) Red color. - **g** (_float_) Green color. - **b** (_float_) Blue color. - **a** (_float_) Alpha channel. ### Methods - **\__init__**(**self**, **r**=0, **g**=0, **b**=0, **a**=1.0) Initializes a color, black by default. - **Parameters:** - `r` (_float_) - `g` (_float_) - `b` (_float_) - `a` (_float_) ##### Dunder methods - **\__eq__**(**self**, **other**=[carla.FloatColor](#carla.FloatColor)) - **\__ne__**(**self**, **other**=[carla.FloatColor](#carla.FloatColor)) --- ## carla.GBufferTextureID Defines the identifiers of each GBuffer texture (See the method `[carla.Sensor.listen_to_gbuffer](#carla.Sensor.listen_to_gbuffer)`). ### Instance Variables - **SceneColor** The texture "SceneColor" contains the final color of the image. - **SceneDepth** The texture "SceneDepth" contains the depth buffer - linear in world units. - **SceneStencil** The texture "SceneStencil" contains the stencil buffer. - **GBufferA** The texture "GBufferA" contains the world-space normal vectors in the RGB channels. The alpha channel contains "per-object data". - **GBufferB** The texture "GBufferB" contains the metallic, specular and roughness in the RGB channels, respectively. The alpha channel contains a mask where the lower 4 bits indicate the shading model and the upper 4 bits contain the selective output mask. - **GBufferC** The texture "GBufferC" contains the diffuse color in the RGB channels, with the indirect irradiance in the alpha channel.
If static lightning is not allowed, the alpha channel will contain the ambient occlusion instead. - **GBufferD** The contents of the "GBufferD" varies depending on the rendered object's material shading model (GBufferB):
- MSM_Subsurface (2), MSM_PreintegratedSkin (3), MSM_TwoSidedFoliage (6):
RGB: Subsurface color.
A: Opacity.
- MSM_ClearCoat (4):
R: Clear coat.
G: Roughness.
- MSM_SubsurfaceProfile (5):
RGB: Subsurface profile.
- MSM_Hair (7):
RG: World normal.
B: Backlit value.
- MSM_Cloth (8):
RGB: Subsurface color.
A: Cloth value.
- MSM_Eye (9):
RG: Eye tangent.
B: Iris mask.
A: Iris distance. - **GBufferE** The texture "GBufferE" contains the precomputed shadow factors in the RGBA channels. This texture is unavailable if the selective output mask (GBufferB) does not have its 4th bit set. - **GBufferF** The texture "GBufferF" contains the world-space tangent in the RGB channels and the anisotropy in the alpha channel. This texture is unavailable if the selective output mask (GBufferB) does not have its 5th bit set. - **Velocity** The texture "Velocity" contains the screen-space velocity of the scene objects. - **SSAO** The texture "SSAO" contains the screen-space ambient occlusion texture. - **CustomDepth** The texture "CustomDepth" contains the Unreal Engine custom depth data. - **CustomStencil** The texture "CustomStencil" contains the Unreal Engine custom stencil data. --- ## carla.GeoLocation Class that contains geographical coordinates simulated data. The [carla.Map](#carla.Map) can convert simulation locations by using the tag in the OpenDRIVE file. ### Instance Variables - **latitude** (_float - degrees_) North/South value of a point on the map. - **longitude** (_float - degrees_) West/East value of a point on the map. - **altitude** (_float - meters_) Height regarding ground level. ### Methods - **\__init__**(**self**, **latitude**=0.0, **longitude**=0.0, **altitude**=0.0) - **Parameters:** - `latitude` (_float - degrees_) - `longitude` (_float - degrees_) - `altitude` (_float - meters_) ##### Dunder methods - **\__eq__**(**self**, **other**=[carla.GeoLocation](#carla.GeoLocation)) - **\__ne__**(**self**, **other**=[carla.GeoLocation](#carla.GeoLocation)) - **\__str__**(**self**) --- ## carla.GnssMeasurement Inherited from _[carla.SensorData](#carla.SensorData)_
Class that defines the Gnss data registered by a sensor.other.gnss. It essentially reports its position with the position of the sensor and an OpenDRIVE geo-reference. ### Instance Variables - **altitude** (_float - meters_) Height regarding ground level. - **latitude** (_float - degrees_) North/South value of a point on the map. - **longitude** (_float - degrees_) West/East value of a point on the map. ### Methods ##### Dunder methods - **\__str__**(**self**) --- ## carla.IMUMeasurement Inherited from _[carla.SensorData](#carla.SensorData)_
Class that defines the data registered by a sensor.other.imu, regarding the sensor's transformation according to the current [carla.World](#carla.World). It essentially acts as accelerometer, gyroscope and compass. ### Instance Variables - **accelerometer** (_[carla.Vector3D](#carla.Vector3D) - m/s2_) Linear acceleration. - **compass** (_float - radians_) Orientation with regard to the North ([0.0, -1.0, 0.0] in Unreal Engine). - **gyroscope** (_[carla.Vector3D](#carla.Vector3D) - rad/s_) Angular velocity. ### Methods ##### Dunder methods - **\__str__**(**self**) --- ## carla.Image Inherited from _[carla.SensorData](#carla.SensorData)_
Class that defines an image of 32-bit BGRA colors that will be used as initial data retrieved by camera sensors. There are different camera sensors (currently three, RGB, depth and semantic segmentation) and each of these makes different use for the images. Learn more about them [here](ref_sensors.md). ### Instance Variables - **fov** (_float - degrees_) Horizontal field of view of the image. - **height** (_int_) Image height in pixels. - **width** (_int_) Image width in pixels. - **raw_data** (_bytes_) Flattened array of pixel data, use reshape to create an image array. ### Methods - **convert**(**self**, **color_converter**) Converts the image following the `color_converter` pattern. - **Parameters:** - `color_converter` (_[carla.ColorConverter](#carla.ColorConverter)_) - **save_to_disk**(**self**, **path**, **color_converter**=Raw) Saves the image to disk using a converter pattern stated as `color_converter`. The default conversion pattern is Raw that will make no changes to the image. - **Parameters:** - `path` (_str_) - Path that will contain the image. - `color_converter` (_[carla.ColorConverter](#carla.ColorConverter)_) - Default Raw will make no changes. ##### Dunder methods - **\__getitem__**(**self**, **pos**=int) - **\__iter__**(**self**) Iterate over the [carla.Color](#carla.Color) that form the image. - **\__len__**(**self**) - **\__setitem__**(**self**, **pos**=int, **color**=[carla.Color](#carla.Color)) - **\__str__**(**self**) --- ## carla.Junction Class that embodies the intersections on the road described in the OpenDRIVE file according to OpenDRIVE 1.4 standards. ### Instance Variables - **id** (_int_) Identifier found in the OpenDRIVE file. - **bounding_box** (_[carla.BoundingBox](#carla.BoundingBox)_) Bounding box encapsulating the junction lanes. ### Methods ##### Getters - **get_waypoints**(**self**, **lane_type**) Returns a list of pairs of waypoints. Every tuple on the list contains first an initial and then a final waypoint within the intersection boundaries that describe the beginning and the end of said lane along the junction. Lanes follow their OpenDRIVE definitions so there may be many different tuples with the same starting waypoint due to possible deviations, as this are considered different lanes. - **Parameters:** - `lane_type` (_[carla.LaneType](#carla.LaneType)_) - Type of lanes to get the waypoints. - **Return:** _list(tuple([carla.Waypoint](#carla.Waypoint)))_ --- ## carla.LabelledPoint Class that represent a position in space with a semantic label. ### Instance Variables - **location** Position in 3D space. - **label** Semantic tag of the point. --- ## carla.Landmark Class that defines any type of traffic landmark or sign affecting a road. These class mediates between the [OpenDRIVE 1.4 standard](http://www.opendrive.org/docs/OpenDRIVEFormatSpecRev1.4H.pdf) definition of the landmarks and their representation in the simulation. This class retrieves all the information defining a landmark in OpenDRIVE and facilitates information about which lanes does it affect and when. Landmarks will be accessed by [carla.Waypoint](#carla.Waypoint) objects trying to retrieve the regulation of their lane. Therefore some attributes depend on the waypoint that is consulting the landmark and so, creating the object. ### Instance Variables - **road_id** (_int_) The OpenDRIVE ID of the road where this landmark is defined. Due to OpenDRIVE road definitions, this road may be different from the road the landmark is currently affecting. It is mostly the case in junctions where the road diverges in different routes. Example: a traffic light is defined in one of the divergent roads in a junction, but it affects all the possible routes. - **distance** (_float - meters_) Distance between the landmark and the waypoint creating the object (querying `get_landmarks` or `get_landmarks_of_type`). - **s** (_float - meters_) Distance where the landmark is positioned along the geometry of the road `road_id`. - **t** (_float - meters_) Lateral distance where the landmark is positioned from the edge of the road `road_id`. - **id** (_str_) Unique ID of the landmark in the OpenDRIVE file. - **name** (_str_) Name of the landmark in the in the OpenDRIVE file. - **is_dynamic** (_bool_) Indicates if the landmark has state changes over time such as traffic lights. - **orientation** (_[carla.LandmarkOrientation](#carla.LandmarkOrientation) - degrees_) Indicates which lanes the landmark is facing towards to. - **z_offset** (_float - meters_) Height where the landmark is placed. - **country** (_str_) Country code where the landmark is defined (default to OpenDRIVE is Germany 2017). - **type** (_str_) Type identifier of the landmark according to the country code. - **sub_type** (_str_) Subtype identifier of the landmark according to the country code. - **value** (_float_) Value printed in the signal (e.g. speed limit, maximum weight, etc). - **unit** (_str_) Units of measurement for the attribute `value`. - **height** (_float - meters_) Total height of the signal. - **width** (_float - meters_) Total width of the signal. - **text** (_str_) Additional text in the signal. - **h_offset** (_float - meters_) Orientation offset of the signal relative to the the definition of `road_id` at `s` in OpenDRIVE. - **pitch** (_float - meters_) Pitch rotation of the signal (Y-axis in [UE coordinates system](https://[carla.readthedocs.io](#carla.readthedocs.io)/en/latest/python_api/#carlarotation)). - **roll** (_float_) Roll rotation of the signal (X-axis in [UE coordinates system](https://[carla.readthedocs.io](#carla.readthedocs.io)/en/latest/python_api/#carlarotation)). - **waypoint** (_[carla.Waypoint](#carla.Waypoint)_) A waypoint placed in the lane of the one that made the query and at the `s` of the landmark. It is the first waypoint for which the landmark will be effective. - **transform** (_[carla.Transform](#carla.Transform)_) The location and orientation of the landmark in the simulation. ### Methods ##### Getters - **get_lane_validities**(**self**) Returns which lanes the landmark is affecting to. As there may be specific lanes where the landmark is not effective, the return is a list of pairs containing ranges of the __lane_id__ affected: Example: In a road with 5 lanes, being 3 not affected: [(from_lane1,to_lane2),(from_lane4,to_lane5)]. - **Return:** _list(tuple(int))_ --- ## carla.LandmarkOrientation Helper class to define the orientation of a landmark in the road. The definition is not directly translated from OpenDRIVE but converted for the sake of understanding. ### Instance Variables - **Positive** The landmark faces towards vehicles going on the same direction as the road's geometry definition (lanes 0 and negative in OpenDRIVE). - **Negative** The landmark faces towards vehicles going on the opposite direction to the road's geometry definition (positive lanes in OpenDRIVE). - **Both** Affects vehicles going in both directions of the road. --- ## carla.LandmarkType Helper class containing a set of commonly used landmark types as defined by the default country code in the [OpenDRIVE standard](http://opendrive.org/docs/OpenDRIVEFormatSpecRev1.5M.pdf) (Germany 2017). __[carla.Landmark](#carla.Landmark) does not reference this class__. The landmark type is a string that varies greatly depending on the country code being used. This class only makes it easier to manage some of the most commonly used in the default set by describing them as an enum. ### Instance Variables - **Danger** Type 101. - **LanesMerging** Type 121. - **CautionPedestrian** Type 133. - **CautionBicycle** Type 138. - **LevelCrossing** Type 150. - **StopSign** Type 206. - **YieldSign** Type 205. - **MandatoryTurnDirection** Type 209. - **MandatoryLeftRightDirection** Type 211. - **TwoChoiceTurnDirection** Type 214. - **Roundabout** Type 215. - **PassRightLeft** Type 222. - **AccessForbidden** Type 250. - **AccessForbiddenMotorvehicles** Type 251. - **AccessForbiddenTrucks** Type 253. - **AccessForbiddenBicycle** Type 254. - **AccessForbiddenWeight** Type 263. - **AccessForbiddenWidth** Type 264. - **AccessForbiddenHeight** Type 265. - **AccessForbiddenWrongDirection** Type 267. - **ForbiddenUTurn** Type 272. - **MaximumSpeed** Type 274. - **ForbiddenOvertakingMotorvehicles** Type 276. - **ForbiddenOvertakingTrucks** Type 277. - **AbsoluteNoStop** Type 283. - **RestrictedStop** Type 286. - **HasWayNextIntersection** Type 301. - **PriorityWay** Type 306. - **PriorityWayEnd** Type 307. - **CityBegin** Type 310. - **CityEnd** Type 311. - **Highway** Type 330. - **DeadEnd** Type 357. - **RecomendedSpeed** Type 380. - **RecomendedSpeedEnd** Type 381. --- ## carla.LaneChange Class that defines the permission to turn either left, right, both or none (meaning only going straight is allowed). This information is stored for every [carla.Waypoint](#carla.Waypoint) according to the OpenDRIVE file. The snipet in [carla.Map.get_waypoint](#carla.Map.get_waypoint) shows how a waypoint can be used to learn which turns are permitted. ### Instance Variables - **NONE** Traffic rules do not allow turning right or left, only going straight. - **Right** Traffic rules allow turning right. - **Left** Traffic rules allow turning left. - **Both** Traffic rules allow turning either right or left. --- ## carla.LaneInvasionEvent Inherited from _[carla.SensorData](#carla.SensorData)_
Class that defines lanes invasion for sensor.other.lane_invasion. It works only client-side and is dependant on OpenDRIVE to provide reliable information. The sensor creates one of this every time there is a lane invasion, which may be more than once per simulation step. Learn more about this [here](ref_sensors.md#lane-invasion-detector). ### Instance Variables - **actor** (_[carla.Actor](#carla.Actor)_) Gets the actor the sensor is attached to, the one that invaded another lane. - **crossed_lane_markings** (_list([carla.LaneMarking](#carla.LaneMarking))_) List of lane markings that have been crossed and detected by the sensor. ### Methods ##### Dunder methods - **\__str__**(**self**) --- ## carla.LaneMarking Class that gathers all the information regarding a lane marking according to [OpenDRIVE 1.4 standard](http://www.opendrive.org/docs/OpenDRIVEFormatSpecRev1.4H.pdf) standard. ### Instance Variables - **color** (_[carla.LaneMarkingColor](#carla.LaneMarkingColor)_) Actual color of the marking. - **lane_change** (_[carla.LaneChange](#carla.LaneChange)_) Permissions for said lane marking to be crossed. - **type** (_[carla.LaneMarkingType](#carla.LaneMarkingType)_) Lane marking type. - **width** (_float_) Horizontal lane marking thickness. --- ## carla.LaneMarkingColor Class that defines the lane marking colors according to OpenDRIVE 1.4. ### Instance Variables - **Standard** White by default. - **Blue** - **Green** - **Red** - **White** - **Yellow** - **Other** --- ## carla.LaneMarkingType Class that defines the lane marking types accepted by OpenDRIVE 1.4. The snipet in [carla.Map.get_waypoint](#carla.Map.get_waypoint) shows how a waypoint can be used to retrieve the information about adjacent lane markings.

__Note on double types:__ Lane markings are defined under the OpenDRIVE standard that determines whereas a line will be considered "BrokenSolid" or "SolidBroken". For each road there is a center lane marking, defined from left to right regarding the lane's directions. The rest of the lane markings are defined in order from the center lane to the closest outside of the road. ### Instance Variables - **NONE** - **Other** - **Broken** - **Solid** - **SolidSolid** - **SolidBroken** - **BrokenSolid** - **BrokenBroken** - **BottsDots** - **Grass** - **Curb** --- ## carla.LaneType Class that defines the possible lane types accepted by OpenDRIVE 1.4. This standards define the road information. The snipet in [carla.Map.get_waypoint](#carla.Map.get_waypoint) makes use of a waypoint to get the current and adjacent lane types. ### Instance Variables - **NONE** - **Driving** - **Stop** - **Shoulder** - **Biking** - **Sidewalk** - **Border** - **Restricted** - **Parking** - **Bidirectional** - **Median** - **Special1** - **Special2** - **Special3** - **RoadWorks** - **Tram** - **Rail** - **Entry** - **Exit** - **OffRamp** - **OnRamp** - **Any** Every type except for NONE. --- ## carla.LidarDetection Data contained inside a [carla.LidarMeasurement](#carla.LidarMeasurement). Each of these represents one of the points in the cloud with its location and its associated intensity. ### Instance Variables - **point** (_[carla.Location](#carla.Location) - meters_) Point in xyz coordinates. - **intensity** (_float_) Computed intensity for this point as a scalar value between [0.0 , 1.0]. ### Methods ##### Dunder methods - **\__str__**(**self**) --- ## carla.LidarMeasurement Inherited from _[carla.SensorData](#carla.SensorData)_
Class that defines the LIDAR data retrieved by a sensor.lidar.ray_cast. This essentially simulates a rotating LIDAR using ray-casting. Learn more about this [here](ref_sensors.md#lidar-raycast-sensor). ### Instance Variables - **channels** (_int_) Number of lasers shot. - **horizontal_angle** (_float - radians_) Horizontal angle the LIDAR is rotated at the time of the measurement. - **raw_data** (_bytes_) Received list of 4D points. Each point consists of [x,y,z] coordinates plus the intensity computed for that point. ### Methods - **save_to_disk**(**self**, **path**) Saves the point cloud to disk as a .ply file describing data from 3D scanners. The files generated are ready to be used within [MeshLab](http://www.meshlab.net/), an open source system for processing said files. Just take into account that axis may differ from Unreal Engine and so, need to be reallocated. - **Parameters:** - `path` (_str_) ##### Getters - **get_point_count**(**self**, **channel**) Retrieves the number of points sorted by channel that are generated by this measure. Sorting by channel allows to identify the original channel for every point. - **Parameters:** - `channel` (_int_) ##### Dunder methods - **\__getitem__**(**self**, **pos**=int) - **\__iter__**(**self**) Iterate over the [carla.LidarDetection](#carla.LidarDetection) retrieved as data. - **\__len__**(**self**) - **\__setitem__**(**self**, **pos**=int, **detection**=[carla.LidarDetection](#carla.LidarDetection)) - **\__str__**(**self**) --- ## carla.Light This class exposes the lights that exist in the scene, except for vehicle lights. The properties of a light can be queried and changed at will. Lights are automatically turned on when the simulator enters night mode (sun altitude is below zero). ### Instance Variables - **color** (_[carla.Color](#carla.Color)_) Color of the light. - **id** (_int_) Identifier of the light. - **intensity** (_float - lumens_) Intensity of the light. - **is_on** (_bool_) Switch of the light. It is __True__ when the light is on. When the night mode starts, this is set to __True__. - **location** (_[carla.Location](#carla.Location) - meters_) Position of the light. - **light_group** (_[carla.LightGroup](#carla.LightGroup)_) Group the light belongs to. - **light_state** (_[carla.LightState](#carla.LightState)_) State of the light. Summarizes its attributes, group, and if it is on/off. ### Methods - **turn_off**(**self**) Switches off the light. - **turn_on**(**self**) Switches on the light. ##### Setters - **set_color**(**self**, **color**) Changes the color of the light to `color`. - **Parameters:** - `color` (_[carla.Color](#carla.Color)_) - **set_intensity**(**self**, **intensity**) Changes the intensity of the light to `intensity`. - **Parameters:** - `intensity` (_float - lumens_) - **set_light_group**(**self**, **light_group**) Changes the light to the group `light_group`. - **Parameters:** - `light_group` (_[carla.LightGroup](#carla.LightGroup)_) - **set_light_state**(**self**, **light_state**) Changes the state of the light to `light_state`. This may change attributes, group and turn the light on/off all at once. - **Parameters:** - `light_state` (_[carla.LightState](#carla.LightState)_) --- ## carla.LightGroup This class categorizes the lights on scene into different groups. These groups available are provided as a enum values that can be used as flags. __Note.__ So far, though there is a `vehicle` group, vehicle lights are not available as [carla.Light](#carla.Light) objects. These have to be managed using [carla.Vehicle](#carla.Vehicle) and [carla.VehicleLightState](#carla.VehicleLightState). ### Instance Variables - **None** All lights. - **Vehicle** - **Street** - **Building** - **Other** --- ## carla.LightManager This class handles the lights in the scene. Its main use is to get and set the state of groups or lists of lights in one call. An instance of this class can be retrieved by the [carla.World.get_lightmanager](#carla.World.get_lightmanager)(). __Note.__ So far, though there is a `vehicle` group, vehicle lights are not available as [carla.Light](#carla.Light) objects. These have to be managed using [carla.Vehicle](#carla.Vehicle) and [carla.VehicleLightState](#carla.VehicleLightState). ### Methods - **is_active**(**self**, **lights**) Returns a list with booleans stating if the elements in `lights` are switched on/off. - **Parameters:** - `lights` (_list([carla.Light](#carla.Light))_) - List of lights to be queried. - **Return:** _list(bool)_ - **turn_off**(**self**, **lights**) Switches off all the lights in `lights`. - **Parameters:** - `lights` (_list([carla.Light](#carla.Light))_) - List of lights to be switched off. - **turn_on**(**self**, **lights**) Switches on all the lights in `lights`. - **Parameters:** - `lights` (_list([carla.Light](#carla.Light))_) - List of lights to be switched on. ##### Getters - **get_all_lights**(**self**, **light_group**=[carla.LightGroup.None](#carla.LightGroup.None)) Returns a list containing the lights in a certain group. By default, the group is `None`. - **Parameters:** - `light_group` (_[carla.LightGroup](#carla.LightGroup)_) - Group to filter the lights returned. Default is `None`. - **Return:** _list([carla.Light](#carla.Light))_ - **get_color**(**self**, **lights**) Returns a list with the colors of every element in `lights`. - **Parameters:** - `lights` (_list([carla.Light](#carla.Light))_) - List of lights to be queried. - **Return:** _list([carla.Color](#carla.Color))_ - **Setter:** _[carla.LightManager.set_color](#carla.LightManager.set_color)_ - **get_intensity**(**self**, **lights**) Returns a list with the intensity of every element in `lights`. - **Parameters:** - `lights` (_list([carla.Light](#carla.Light))_) - List of lights to be queried. - **Return:** _list(float) - lumens_ - **Setter:** _[carla.LightManager.set_intensity](#carla.LightManager.set_intensity)_ - **get_light_group**(**self**, **lights**) Returns a list with the group of every element in `lights`. - **Parameters:** - `lights` (_list([carla.Light](#carla.Light))_) - List of lights to be queried. - **Return:** _list([carla.LightGroup](#carla.LightGroup))_ - **Setter:** _[carla.LightManager.set_light_group](#carla.LightManager.set_light_group)_ - **get_light_state**(**self**, **lights**) Returns a list with the state of all the attributes of every element in `lights`. - **Parameters:** - `lights` (_list([carla.Light](#carla.Light))_) - List of lights to be queried. - **Return:** _list([carla.LightState](#carla.LightState))_ - **Setter:** _[carla.LightManager.set_light_state](#carla.LightManager.set_light_state)_ - **get_turned_off_lights**(**self**, **light_group**) Returns a list containing lights switched off in the scene, filtered by group. - **Parameters:** - `light_group` (_[carla.LightGroup](#carla.LightGroup)_) - List of lights to be queried. - **Return:** _list([carla.Light](#carla.Light))_ - **get_turned_on_lights**(**self**, **light_group**) Returns a list containing lights switched on in the scene, filtered by group. - **Parameters:** - `light_group` (_[carla.LightGroup](#carla.LightGroup)_) - List of lights to be queried. - **Return:** _list([carla.Light](#carla.Light))_ ##### Setters - **set_active**(**self**, **lights**, **active**) Switches on/off the elements in `lights`. - **Parameters:** - `lights` (_list([carla.Light](#carla.Light))_) - List of lights to be switched on/off. - `active` (_list(bool)_) - List of booleans to be applied. - **set_color**(**self**, **lights**, **color**) Changes the color of the elements in `lights` to `color`. - **Parameters:** - `lights` (_list([carla.Light](#carla.Light))_) - List of lights to be changed. - `color` (_[carla.Color](#carla.Color)_) - Color to be applied. - **Getter:** _[carla.LightManager.get_color](#carla.LightManager.get_color)_ - **set_colors**(**self**, **lights**, **colors**) Changes the color of each element in `lights` to the corresponding in `colors`. - **Parameters:** - `lights` (_list([carla.Light](#carla.Light))_) - List of lights to be changed. - `colors` (_list([carla.Color](#carla.Color))_) - List of colors to be applied. - **set_day_night_cycle**(**self**, **active**) All scene lights have a day-night cycle, automatically turning on and off with the altitude of the sun. This interferes in cases where full control of the scene lights is required, so setting this to __False__ deactivates it. It can reactivated by setting it to __True__. - **Parameters:** - `active` (_bool_) - (De)activation of the day-night cycle. - **set_intensities**(**self**, **lights**, **intensities**) Changes the intensity of each element in `lights` to the corresponding in `intensities`. - **Parameters:** - `lights` (_list([carla.Light](#carla.Light))_) - List of lights to be changed. - `intensities` (_list(float) - lumens_) - List of intensities to be applied. - **set_intensity**(**self**, **lights**, **intensity**) Changes the intensity of every element in `lights` to `intensity`. - **Parameters:** - `lights` (_list([carla.Light](#carla.Light))_) - List of lights to be changed. - `intensity` (_float - lumens_) - Intensity to be applied. - **Getter:** _[carla.LightManager.get_intensity](#carla.LightManager.get_intensity)_ - **set_light_group**(**self**, **lights**, **light_group**) Changes the group of every element in `lights` to `light_group`. - **Parameters:** - `lights` (_list([carla.Light](#carla.Light))_) - List of lights to be changed. - `light_group` (_[carla.LightGroup](#carla.LightGroup)_) - Group to be applied. - **Getter:** _[carla.LightManager.get_light_group](#carla.LightManager.get_light_group)_ - **set_light_groups**(**self**, **lights**, **light_groups**) Changes the group of each element in `lights` to the corresponding in `light_groups`. - **Parameters:** - `lights` (_list([carla.Light](#carla.Light))_) - List of lights to be changed. - `light_groups` (_list([carla.LightGroup](#carla.LightGroup))_) - List of groups to be applied. - **set_light_state**(**self**, **lights**, **light_state**) Changes the state of the attributes of every element in `lights` to `light_state`. - **Parameters:** - `lights` (_list([carla.Light](#carla.Light))_) - List of lights to be changed. - `light_state` (_[carla.LightState](#carla.LightState)_) - State of the attributes to be applied. - **Getter:** _[carla.LightManager.get_light_state](#carla.LightManager.get_light_state)_ - **set_light_states**(**self**, **lights**, **light_states**) Changes the state of the attributes of each element in `lights` to the corresponding in `light_states`. - **Parameters:** - `lights` (_list([carla.Light](#carla.Light))_) - List of lights to be changed. - `light_states` (_list([carla.LightState](#carla.LightState))_) - List of state of the attributes to be applied. --- ## carla.LightState This class represents all the light variables except the identifier and the location, which are should to be static. Using this class allows to manage all the parametrization of the light in one call. ### Instance Variables - **intensity** (_float - lumens_) Intensity of a light. - **color** (_[carla.Color](#carla.Color)_) Color of a light. - **group** (_[carla.LightGroup](#carla.LightGroup)_) Group a light belongs to. - **active** (_bool_) Switch of a light. It is __True__ when the light is on. ### Methods - **\__init__**(**self**, **intensity**=0.0, **color**=[carla.Color](#carla.Color)(), **group**=[carla.LightGroup.None](#carla.LightGroup.None), **active**=False) - **Parameters:** - `intensity` (_float - lumens_) - Intensity of the light. Default is `0.0`. - `color` (_[carla.Color](#carla.Color)_) - Color of the light. Default is black. - `group` (_[carla.LightGroup](#carla.LightGroup)_) - Group the light belongs to. Default is the generic group `None`. - `active` (_bool_) - Swith of the light. Default is `False`, light is off. --- ## carla.Location Inherited from _[carla.Vector3D](#carla.Vector3D)_
Represents a spot in the world. ### Instance Variables - **x** (_float - meters_) Distance from origin to spot on X axis. - **y** (_float - meters_) Distance from origin to spot on Y axis. - **z** (_float - meters_) Distance from origin to spot on Z axis. ### Methods - **\__init__**(**self**, **x**=0.0, **y**=0.0, **z**=0.0) - **Parameters:** - `x` (_float_) - `y` (_float_) - `z` (_float_) - **distance**(**self**, **location**) Returns Euclidean distance from this location to another one. - **Parameters:** - `location` (_[carla.Location](#carla.Location)_) - The other point to compute the distance with. - **Return:** _float - meters_ ##### Dunder methods - **\__abs__**(**self**) Returns a Location with the absolute value of the components x, y and z. - **Return:** _[carla.Location](#carla.Location)_ - **\__eq__**(**self**, **other**=[carla.Location](#carla.Location)) Returns __True__ if both locations are the same point in space. - **Return:** _bool_ - **\__ne__**(**self**, **other**=[carla.Location](#carla.Location)) Returns __True__ if both locations are different points in space. - **Return:** _bool_ - **\__str__**(**self**) Parses the axis' values to string. - **Return:** _str_ --- ## carla.Map Class containing the road information and waypoint managing. Data is retrieved from an OpenDRIVE file that describes the road. A query system is defined which works hand in hand with [carla.Waypoint](#carla.Waypoint) to translate geometrical information from the .xodr to natural world points. CARLA is currently working with [OpenDRIVE 1.4 standard](http://www.opendrive.org/docs/OpenDRIVEFormatSpecRev1.4H.pdf). ### Instance Variables - **name** (_str_) The name of the map. It corresponds to the .umap from Unreal Engine that is loaded from a CARLA server, which then references to the .xodr road description. ### Methods - **\__init__**(**self**, **name**, **xodr_content**) Constructor for this class. Though a map is automatically generated when initializing the world, using this method in no-rendering mode facilitates working with an .xodr without any CARLA server running. - **Parameters:** - `name` (_str_) - Name of the current map. - `xodr_content` (_str_) - .xodr content in string format. - **Return:** _list([carla.Transform](#carla.Transform))_ - **cook_in_memory_map**(**self**, **path**) Generates a binary file from the CARLA map containing information used by the Traffic Manager. This method is only used during the import process for maps. - **Parameters:** - `path` (_str_) - Path to the intended location of the stored binary map file. - **generate_waypoints**(**self**, **distance**) Returns a list of waypoints with a certain distance between them for every lane and centered inside of it. Waypoints are not listed in any particular order. Remember that waypoints closer than 2cm within the same road, section and lane will have the same identificator. - **Parameters:** - `distance` (_float - meters_) - Approximate distance between waypoints. - **Return:** _list([carla.Waypoint](#carla.Waypoint))_ - **save_to_disk**(**self**, **path**) Saves the .xodr OpenDRIVE file of the current map to disk. - **Parameters:** - `path` - Path where the file will be saved. - **to_opendrive**(**self**) Returns the .xodr OpenDRIVe file of the current map as string. - **Return:** _str_ - **transform_to_geolocation**(**self**, **location**) Converts a given `location`, a point in the simulation, to a [carla.GeoLocation](#carla.GeoLocation), which represents world coordinates. The geographical location of the map is defined inside OpenDRIVE within the tag . - **Parameters:** - `location` (_[carla.Location](#carla.Location)_) - **Return:** _[carla.GeoLocation](#carla.GeoLocation)_ ##### Getters - **get_all_landmarks**(**self**) Returns all the landmarks in the map. Landmarks retrieved using this method have a __null__ waypoint. - **Return:** _list([carla.Landmark](#carla.Landmark))_ - **get_all_landmarks_from_id**(**self**, **opendrive_id**) Returns the landmarks with a certain OpenDRIVE ID. Landmarks retrieved using this method have a __null__ waypoint. - **Parameters:** - `opendrive_id` (_string_) - The OpenDRIVE ID of the landmarks. - **Return:** _list([carla.Landmark](#carla.Landmark))_ - **get_all_landmarks_of_type**(**self**, **type**) Returns the landmarks of a specific type. Landmarks retrieved using this method have a __null__ waypoint. - **Parameters:** - `type` (_string_) - The type of the landmarks. - **Return:** _list([carla.Landmark](#carla.Landmark))_ - **get_crosswalks**(**self**) Returns a list of locations with all crosswalk zones in the form of closed polygons. The first point is repeated, symbolizing where the polygon begins and ends. - **Return:** _list([carla.Location](#carla.Location))_ - **get_landmark_group**(**self**, **landmark**) Returns the landmarks in the same group as the specified landmark (including itself). Returns an empty list if the landmark does not belong to any group. - **Parameters:** - `landmark` (_[carla.Landmark](#carla.Landmark)_) - A landmark that belongs to the group. - **Return:** _list([carla.Landmark](#carla.Landmark))_ - **get_spawn_points**(**self**) Returns a list of recommendations made by the creators of the map to be used as spawning points for the vehicles. The list includes [carla.Transform](#carla.Transform) objects with certain location and orientation. Said locations are slightly on-air in order to avoid Z-collisions, so vehicles fall for a bit before starting their way. - **Return:** _list([carla.Transform](#carla.Transform))_ - **get_topology**(**self**) Returns a list of tuples describing a minimal graph of the topology of the OpenDRIVE file. The tuples contain pairs of waypoints located either at the point a road begins or ends. The first one is the origin and the second one represents another road end that can be reached. This graph can be loaded into [NetworkX](https://networkx.github.io/) to work with. Output could look like this: [(w0, w1), (w0, w2), (w1, w3), (w2, w3), (w0, w4)]. - **Return:** _list(tuple([carla.Waypoint](#carla.Waypoint), [carla.Waypoint](#carla.Waypoint)))_ - **get_waypoint**(**self**, **location**, **project_to_road**=True, **lane_type**=[carla.LaneType.Driving](#carla.LaneType.Driving)) Returns a waypoint that can be located in an exact location or translated to the center of the nearest lane. Said lane type can be defined using flags such as `LaneType.Driving & LaneType.Shoulder`. The method will return None if the waypoint is not found, which may happen only when trying to retrieve a waypoint for an exact location. That eases checking if a point is inside a certain road, as otherwise, it will return the corresponding waypoint. - **Parameters:** - `location` (_[carla.Location](#carla.Location) - meters_) - Location used as reference for the [carla.Waypoint](#carla.Waypoint). - `project_to_road` (_bool_) - If **True**, the waypoint will be at the center of the closest lane. This is the default setting. If **False**, the waypoint will be exactly in `location`. None means said location does not belong to a road. - `lane_type` (_[carla.LaneType](#carla.LaneType)_) - Limits the search for nearest lane to one or various lane types that can be flagged. - **Return:** _[carla.Waypoint](#carla.Waypoint)_ - **get_waypoint_xodr**(**self**, **road_id**, **lane_id**, **s**) Returns a waypoint if all the parameters passed are correct. Otherwise, returns __None__. - **Parameters:** - `road_id` (_int_) - ID of the road to get the waypoint. - `lane_id` (_int_) - ID of the lane to get the waypoint. - `s` (_float - meters_) - Specify the length from the road start. - **Return:** _[carla.Waypoint](#carla.Waypoint)_ ##### Dunder methods - **\__str__**(**self**) --- ## carla.MapLayer Class that represents each manageable layer of the map. Can be used as flags. __WARNING: Only "Opt" maps are able to work with map layers.__. ### Instance Variables - **NONE** No layers selected. - **Buildings** - **Decals** - **Foliage** - **Ground** - **ParkedVehicles** - **Particles** - **Props** - **StreetLights** - **Walls** - **All** All layers selected. --- ## carla.MaterialParameter Class that represents material parameters. Not all objects in the scene contain all parameters. ### Instance Variables - **Normal** The Normal map of the object. Present in all objects. - **Diffuse** The Diffuse texture of the object. Present in all objects. - **AO_Roughness_Metallic_Emissive** A texture where each color channel represent a property of the material (R: Ambien oclusion, G: Roughness, B: Metallic, A: Emissive/Height map in some objects). - **Emissive** Emissive texture. Present in a few objects. --- ## carla.ObstacleDetectionEvent Inherited from _[carla.SensorData](#carla.SensorData)_
Class that defines the obstacle data for sensor.other.obstacle. Learn more about this [here](ref_sensors.md#obstacle-detector). ### Instance Variables - **actor** (_[carla.Actor](#carla.Actor)_) The actor the sensor is attached to. - **other_actor** (_[carla.Actor](#carla.Actor)_) The actor or object considered to be an obstacle. - **distance** (_float - meters_) Distance between `actor` and `other`. ### Methods ##### Dunder methods - **\__str__**(**self**) --- ## carla.OpendriveGenerationParameters This class defines the parameters used when generating a world using an OpenDRIVE file. ### Instance Variables - **vertex_distance** (_float_) Distance between vertices of the mesh generated. __Default is `2.0`__. - **max_road_length** (_float_) Max road length for a single mesh portion. The mesh of the map is divided into portions, in order to avoid propagating issues. __Default is `50.0`__. - **wall_height** (_float_) Height of walls created on the boundaries of the road. These prevent vehicles from falling off the road. __Default is `1.0`__. - **additional_width** (_float_) Additional with applied junction lanes. Complex situations tend to occur at junctions, and a little increase can prevent vehicles from falling off the road. __Default is `0.6`__. - **smooth_junctions** (_bool_) If __True__, the mesh at junctions will be smoothed to prevent issues where roads blocked other roads. __Default is `True`__. - **enable_mesh_visibility** (_bool_) If __True__, the road mesh will be rendered. Setting this to __False__ should reduce the rendering overhead. __Default is `True`__. - **enable_pedestrian_navigation** (_bool_) If __True__, Pedestrian navigation will be enabled using Recast tool. For very large maps it is recomended to disable this option. __Default is `True`__. --- ## carla.OpticalFlowImage Inherited from _[carla.SensorData](#carla.SensorData)_
Class that defines an optical flow image of 2-Dimension float (32-bit) vectors representing the optical flow detected in the field of view. The components of the vector represents the displacement of an object in the image plane. Each component outputs values in the normalized range [-2,2] which scales to [-2 size, 2 size] with size being the total resolution in the corresponding component. ### Instance Variables - **fov** (_float - degrees_) Horizontal field of view of the image. - **height** (_int_) Image height in pixels. - **width** (_int_) Image width in pixels. - **raw_data** (_bytes_) Flattened array of pixel data, use reshape to create an image array. ### Methods ##### Getters - **get_color_coded_flow**(**self**) Visualization helper. Converts the optical flow image to an RGB image. - **Return:** _[carla.Image](#carla.Image)_ ##### Dunder methods - **\__getitem__**(**self**, **pos**=int) - **\__iter__**(**self**) Iterate over the [carla.OpticalFlowPixel](#carla.OpticalFlowPixel) that form the image. - **\__len__**(**self**) - **\__setitem__**(**self**, **pos**=int, **color**=[carla.Color](#carla.Color)) - **\__str__**(**self**) --- ## carla.OpticalFlowPixel Class that defines a 2 dimensional vector representing an optical flow pixel. ### Instance Variables - **x** (_float_) Optical flow in the x component. - **y** (_float_) Optical flow in the y component. ### Methods - **\__init__**(**self**, **x**=0, **y**=0) Initializes the Optical Flow Pixel. Zero by default. - **Parameters:** - `x` (_float_) - `y` (_float_) ##### Dunder methods - **\__eq__**(**self**, **other**=[carla.OpticalFlowPixel](#carla.OpticalFlowPixel)) - **\__ne__**(**self**, **other**=[carla.OpticalFlowPixel](#carla.OpticalFlowPixel)) - **\__str__**(**self**) --- ## carla.Osm2Odr Class that converts an OpenStreetMap map to OpenDRIVE format, so that it can be loaded in CARLA. Find out more about this feature in the [docs](tuto_G_openstreetmap.md). ### Methods - **convert**(**osm_file**, **settings**) Takes the content of an .osm file (OpenStreetMap format) and returns the content of the .xodr (OpenDRIVE format) describing said map. Some parameterization is passed to do the conversion. - **Parameters:** - `osm_file` (_str_) - The content of the input OpenStreetMap file parsed as string. - `settings` (_[carla.OSM2ODRSettings](#carla.OSM2ODRSettings)_) - Parameterization for the conversion. - **Return:** _str_ --- ## carla.Osm2OdrSettings Helper class that contains the parameterization that will be used by [carla.Osm2Odr](#carla.Osm2Odr) to convert an OpenStreetMap map to OpenDRIVE format. Find out more about this feature in the [docs](tuto_G_openstreetmap.md). ### Instance Variables - **use_offsets** (_bool_) Enables the use of offset for the conversion. The offset will move the origin position of the map. Default value is __False__. - **offset_x** (_float - meters_) Offset in the X axis. Default value is __0.0__. - **offset_y** (_float - meters_) Offset in the Y axis. Default value is __0.0__. - **default_lane_width** (_float - meters_) Width of the lanes described in the resulting XODR map. Default value is __4.0__. - **elevation_layer_height** (_float - meters_) Defines the height separating two different [OpenStreetMap layers](https://wiki.openstreetmap.org/wiki/Key:layer). Default value is __0.0__. - **center_map** (_bool_) When this option is enabled, the geometry of the map will be displaced so that the origin of coordinates matches the center of the bounding box of the entire road map. - **proj_string** (_str_) Defines the [proj4](https://github.com/OSGeo/proj.4) string that will be used to compute the projection from geocoordinates to cartesian coordinates. This string will be written in the resulting OpenDRIVE unless the options `use_offsets` or `center_map` are enabled as these options override some of the definitions in the string. - **generate_traffic_lights** (_bool_) Indicates wether to generate traffic light data in the OpenDRIVE. Road types defined by `set_traffic_light_excluded_way_types(way_types)` will not generate traffic lights. - **all_junctions_with_traffic_lights** (_bool_) When disabled, the converter will generate traffic light data from the OpenStreetMaps data only. When enabled, all junctions will generate traffic lights. ### Methods ##### Setters - **set_osm_way_types**(**self**, **way_types**) Defines the OpenStreetMaps road types that will be imported to OpenDRIVE. By default the road types imported are `motorway, motorway_link, trunk, trunk_link, primary, primary_link, secondary, secondary_link, tertiary, tertiary_link, unclassified, residential`. For a full list of road types check [here](https://wiki.openstreetmap.org/wiki/Main_Page). - **Parameters:** - `way_types` (_list(str)_) - The list of road types. - **set_traffic_light_excluded_way_types**(**self**, **way_types**) Defines the OpenStreetMaps road types that will not generate traffic lights even if `generate_traffic_lights` is enabled. By default the road types excluded are `motorway_link, primary_link, secondary_link, tertiary_link`. - **Parameters:** - `way_types` (_list(str)_) - The list of road types. --- ## carla.RadarDetection Data contained inside a [carla.RadarMeasurement](#carla.RadarMeasurement). Each of these represents one of the points in the cloud that a sensor.other.radar registers and contains the distance, angle and velocity in relation to the radar. ### Instance Variables - **altitude** (_float - radians_) Altitude angle of the detection. - **azimuth** (_float - radians_) Azimuth angle of the detection. - **depth** (_float - meters_) Distance from the sensor to the detection position. - **velocity** (_float - m/s_) The velocity of the detected object towards the sensor. ### Methods ##### Dunder methods - **\__str__**(**self**) --- ## carla.RadarMeasurement Inherited from _[carla.SensorData](#carla.SensorData)_
Class that defines and gathers the measures registered by a sensor.other.radar, representing a wall of points in front of the sensor with a distance, angle and velocity in relation to it. The data consists of a [carla.RadarDetection](#carla.RadarDetection) array. Learn more about this [here](ref_sensors.md#radar-sensor). ### Instance Variables - **raw_data** (_bytes_) The complete information of the [carla.RadarDetection](#carla.RadarDetection) the radar has registered. ### Methods ##### Getters - **get_detection_count**(**self**) Retrieves the number of entries generated, same as **\__str__()**. ##### Dunder methods - **\__getitem__**(**self**, **pos**=int) - **\__iter__**(**self**) Iterate over the [carla.RadarDetection](#carla.RadarDetection) retrieved as data. - **\__len__**(**self**) - **\__setitem__**(**self**, **pos**=int, **detection**=[carla.RadarDetection](#carla.RadarDetection)) - **\__str__**(**self**) --- ## carla.Rotation Class that represents a 3D rotation and therefore, an orientation in space. CARLA uses the Unreal Engine coordinates system. This is a Z-up left-handed system.

The constructor method follows a specific order of declaration: `(pitch, yaw, roll)`, which corresponds to `(Y-rotation,Z-rotation,X-rotation)`.

![UE4_Rotation](https://d26ilriwvtzlb.cloudfront.net/8/83/BRMC_9.jpg) *Unreal Engine's coordinates system*. ### Instance Variables - **pitch** (_float - degrees_) Y-axis rotation angle. - **yaw** (_float - degrees_) Z-axis rotation angle. - **roll** (_float - degrees_) X-axis rotation angle. ### Methods - **\__init__**(**self**, **pitch**=0.0, **yaw**=0.0, **roll**=0.0) - **Parameters:** - `pitch` (_float - degrees_) - Y-axis rotation angle. - `yaw` (_float - degrees_) - Z-axis rotation angle. - `roll` (_float - degrees_) - X-axis rotation angle. - **Warning:** _The declaration order is different in CARLA (pitch,yaw,roll), and in the Unreal Engine Editor (roll,pitch,yaw). When working in a build from source, don't mix up the axes' rotations._ ##### Getters - **get_forward_vector**(**self**) Computes the vector pointing forward according to the rotation of the object. - **Return:** _[carla.Vector3D](#carla.Vector3D)_ - **get_right_vector**(**self**) Computes the vector pointing to the right according to the rotation of the object. - **Return:** _[carla.Vector3D](#carla.Vector3D)_ - **get_up_vector**(**self**) Computes the vector pointing upwards according to the rotation of the object. - **Return:** _[carla.Vector3D](#carla.Vector3D)_ ##### Dunder methods - **\__eq__**(**self**, **other**=[carla.Rotation](#carla.Rotation)) Returns __True__ if both rotations represent the same orientation for every axis. - **Return:** _bool_ - **\__ne__**(**self**, **other**=[carla.Rotation](#carla.Rotation)) Returns __True__ if both rotations represent the same orientation for every axis. - **Return:** _bool_ - **\__str__**(**self**) Parses the axis' orientations to string. --- ## carla.RssActorConstellationData Data structure that is provided within the callback registered by RssSensor.register_actor_constellation_callback(). ### Instance Variables - **ego_match_object** (_ad.map.match.Object_) The ego map matched information. - **ego_route** (_ad.map.route.FullRoute_) The ego route. - **ego_dynamics_on_route** (_[carla.RssEgoDynamicsOnRoute](#carla.RssEgoDynamicsOnRoute)_) Current ego vehicle dynamics regarding the route. - **other_match_object** (_ad.map.match.Object_) The other object's map matched information. This is only valid if 'other_actor' is not 'None'. - **other_actor** (_[carla.Actor](#carla.Actor)_) The other actor. This is 'None' in case of query of default parameters or articial objects of kind ad.rss.world.ObjectType.ArtificialObject with no dedicated '[carla.Actor](#carla.Actor)' (as e.g. for the [road boundaries](ref_sensors.md#rss-sensor) at the moment). ### Methods ##### Dunder methods - **\__str__**(**self**) --- ## carla.RssActorConstellationResult Data structure that should be returned by the callback registered by RssSensor.register_actor_constellation_callback(). ### Instance Variables - **rss_calculation_mode** (_ad.rss.map.RssMode_) The calculation mode to be applied with the actor. - **restrict_speed_limit_mode** (_ad.rss.map.RestrictSpeedLimitMode_) The mode for restricting speed limit. - **ego_vehicle_dynamics** (_ad.rss.world.RssDynamics_) The RSS dynamics to be applied for the ego vehicle. - **actor_object_type** (_ad.rss.world.ObjectType_) The RSS object type to be used for the actor. - **actor_dynamics** (_ad.rss.world.RssDynamics_) The RSS dynamics to be applied for the actor. ### Methods ##### Dunder methods - **\__str__**(**self**) --- ## carla.RssEgoDynamicsOnRoute Part of the data contained inside a [carla.RssResponse](#carla.RssResponse) describing the state of the vehicle. The parameters include its current dynamics, and how it is heading regarding the target route. ### Instance Variables - **ego_speed** (_ad.physics.Speed_) The ego vehicle's speed. - **min_stopping_distance** (_ad.physics.Distance_) The current minimum stopping distance. - **ego_center** (_ad.map.point.ENUPoint_) The considered enu position of the ego vehicle. - **ego_heading** (_ad.map.point.ENUHeading_) The considered heading of the ego vehicle. - **ego_center_within_route** (_bool_) States if the ego vehicle's center is within the route. - **crossing_border** (_bool_) States if the vehicle is already crossing one of the lane borders. - **route_heading** (_ad.map.point.ENUHeading_) The considered heading of the route. - **route_nominal_center** (_ad.map.point.ENUPoint_) The considered nominal center of the current route. - **heading_diff** (_ad.map.point.ENUHeading_) The considered heading diff towards the route. - **route_speed_lat** (_ad.physics.Speed_) The ego vehicle's speed component _lat_ regarding the route. - **route_speed_lon** (_ad.physics.Speed_) The ego vehicle's speed component _lon_ regarding the route. - **route_accel_lat** (_ad.physics.Acceleration_) The ego vehicle's acceleration component _lat_ regarding the route. - **route_accel_lon** (_ad.physics.Acceleration_) The ego vehicle's acceleration component _lon_ regarding the route. - **avg_route_accel_lat** (_ad.physics.Acceleration_) The ego vehicle's acceleration component _lat_ regarding the route smoothened by an average filter. - **avg_route_accel_lon** (_ad.physics.Acceleration_) The ego acceleration component _lon_ regarding the route smoothened by an average filter. ### Methods ##### Dunder methods - **\__str__**(**self**) --- ## carla.RssLogLevel Enum declaration used in [carla.RssSensor](#carla.RssSensor) to set the log level. ### Instance Variables - **trace** - **debug** - **info** - **warn** - **err** - **critical** - **off** --- ## carla.RssResponse Inherited from _[carla.SensorData](#carla.SensorData)_
Class that contains the output of a [carla.RssSensor](#carla.RssSensor). This is the result of the RSS calculations performed for the parent vehicle of the sensor. A [carla.RssRestrictor](#carla.RssRestrictor) will use the data to modify the [carla.VehicleControl](#carla.VehicleControl) of the vehicle. ### Instance Variables - **response_valid** (_bool_) States if the response is valid. It is __False__ if calculations failed or an exception occured. - **proper_response** (_ad.rss.state.ProperResponse_) The proper response that the RSS calculated for the vehicle. - **rss_state_snapshot** (_ad.rss.state.RssStateSnapshot_) Detailed RSS states at the current moment in time. - **ego_dynamics_on_route** (_[carla.RssEgoDynamicsOnRoute](#carla.RssEgoDynamicsOnRoute)_) Current ego vehicle dynamics regarding the route. - **world_model** (_ad.rss.world.WorldModel_) World model used for calculations. - **situation_snapshot** (_ad.rss.situation.SituationSnapshot_) Detailed RSS situations extracted from the world model. ### Methods ##### Dunder methods - **\__str__**(**self**) --- ## carla.RssRestrictor These objects apply restrictions to a [carla.VehicleControl](#carla.VehicleControl). It is part of the CARLA implementation of the [C++ Library for Responsibility Sensitive Safety](https://github.com/intel/ad-rss-lib). This class works hand in hand with a [rss sensor](ref_sensors.md#rss-sensor), which provides the data of the restrictions to be applied. ### Methods - **restrict_vehicle_control**(**self**, **vehicle_control**, **proper_response**, **ego_dynamics_on_route**, **vehicle_physics**) Applies the safety restrictions given by a [carla.RssSensor](#carla.RssSensor) to a [carla.VehicleControl](#carla.VehicleControl). - **Parameters:** - `vehicle_control` (_[carla.VehicleControl](#carla.VehicleControl)_) - The input vehicle control to be restricted. - `proper_response` (_ad.rss.state.ProperResponse_) - Part of the response generated by the sensor. Contains restrictions to be applied to the acceleration of the vehicle. - `ego_dynamics_on_route` (_[carla.RssEgoDynamicsOnRoute](#carla.RssEgoDynamicsOnRoute)_) - Part of the response generated by the sensor. Contains dynamics and heading of the vehicle regarding its route. - `vehicle_physics` (_[carla.VehiclePhysicsControl](#carla.VehiclePhysicsControl)_) - The current physics of the vehicle. Used to apply the restrictions properly. - **Return:** _[carla.VehicleControl](#carla.VehicleControl)_ ##### Setters - **set_log_level**(**self**, **log_level**) Sets the log level. - **Parameters:** - `log_level` (_[carla.RssLogLevel](#carla.RssLogLevel)_) - New log level. --- ## carla.RssRoadBoundariesMode Enum declaration used in [carla.RssSensor](#carla.RssSensor) to enable or disable the [stay on road](https://intel.github.io/ad-rss-lib/ad_rss_map_integration/HandleRoadBoundaries/) feature. In summary, this feature considers the road boundaries as virtual objects. The minimum safety distance check is applied to these virtual walls, in order to make sure the vehicle does not drive off the road. ### Instance Variables - **On** Enables the _stay on road_ feature. - **Off** Disables the _stay on road_ feature. --- ## carla.RssSensor Inherited from _[carla.Sensor](#carla.Sensor)_
This sensor works a bit differently than the rest. Take look at the [specific documentation](adv_rss.md), and the [rss sensor reference](ref_sensors.md#rss-sensor) to gain full understanding of it. The RSS sensor uses world information, and a [RSS library](https://github.com/intel/ad-rss-lib) to make safety checks on a vehicle. The output retrieved by the sensor is a [carla.RssResponse](#carla.RssResponse). This will be used by a [carla.RssRestrictor](#carla.RssRestrictor) to modify a [carla.VehicleControl](#carla.VehicleControl) before applying it to a vehicle. ### Instance Variables - **ego_vehicle_dynamics** (_ad.rss.world.RssDynamics_) States the [RSS parameters](https://intel.github.io/ad-rss-lib/ad_rss/Appendix-ParameterDiscussion/) that the sensor will consider for the ego vehicle if no actor constellation callback is registered. - **other_vehicle_dynamics** (_ad.rss.world.RssDynamics_) States the [RSS parameters](https://intel.github.io/ad-rss-lib/ad_rss/Appendix-ParameterDiscussion/) that the sensor will consider for the rest of vehicles if no actor constellation callback is registered. - **pedestrian_dynamics** (_ad.rss.world.RssDynamics_) States the [RSS parameters](https://intel.github.io/ad-rss-lib/ad_rss/Appendix-ParameterDiscussion/) that the sensor will consider for pedestrians if no actor constellation callback is registered. - **road_boundaries_mode** (_[carla.RssRoadBoundariesMode](#carla.RssRoadBoundariesMode)_) Switches the [stay on road](https://intel.github.io/ad-rss-lib/ad_rss_map_integration/HandleRoadBoundaries/) feature. By default is __Off__. - **routing_targets** (_vector<[carla.Transform](#carla.Transform)>_) The current list of targets considered to route the vehicle. If no routing targets are defined, a route is generated at random. ### Methods - **append_routing_target**(**self**, **routing_target**) Appends a new target position to the current route of the vehicle. - **Parameters:** - `routing_target` (_[carla.Transform](#carla.Transform)_) - New target point for the route. Choose these after the intersections to force the route to take the desired turn. - **drop_route**(**self**) Discards the current route. If there are targets remaining in **routing_targets**, creates a new route using those. Otherwise, a new route is created at random. - **register_actor_constellation_callback**(**self**, **callback**) Register a callback to customize a [carla.RssActorConstellationResult](#carla.RssActorConstellationResult). By this callback the settings of RSS parameters are done per actor constellation and the settings (ego_vehicle_dynamics, other_vehicle_dynamics and pedestrian_dynamics) have no effect. - **Parameters:** - `callback` - The function to be called whenever a RSS situation is about to be calculated. - **reset_routing_targets**(**self**) Erases the targets that have been appended to the route. ##### Setters - **set_log_level**(**self**, **log_level**) Sets the log level. - **Parameters:** - `log_level` (_[carla.RssLogLevel](#carla.RssLogLevel)_) - New log level. - **set_map_log_level**(**self**, **log_level**) Sets the map log level. - **Parameters:** - `log_level` (_[carla.RssLogLevel](#carla.RssLogLevel)_) - New map log level. ##### Dunder methods - **\__str__**(**self**) --- ## carla.SemanticLidarDetection Data contained inside a [carla.SemanticLidarMeasurement](#carla.SemanticLidarMeasurement). Each of these represents one of the points in the cloud with its location, the cosine of the incident angle, index of the object hit, and its semantic tag. ### Instance Variables - **point** (_[carla.Location](#carla.Location) - meters_) [x,y,z] coordinates of the point. - **cos_inc_angle** (_float_) Cosine of the incident angle between the ray, and the normal of the hit object. - **object_idx** (_uint_) ID of the actor hit by the ray. - **object_tag** (_uint_) [Semantic tag](https://[carla.readthedocs.io](#carla.readthedocs.io)/en/latest/ref_sensors/#semantic-segmentation-camera) of the component hit by the ray. ### Methods ##### Dunder methods - **\__str__**(**self**) --- ## carla.SemanticLidarMeasurement Inherited from _[carla.SensorData](#carla.SensorData)_
Class that defines the semantic LIDAR data retrieved by a sensor.lidar.ray_cast_semantic. This essentially simulates a rotating LIDAR using ray-casting. Learn more about this [here](ref_sensors.md#semanticlidar-raycast-sensor). ### Instance Variables - **channels** (_int_) Number of lasers shot. - **horizontal_angle** (_float - radians_) Horizontal angle the LIDAR is rotated at the time of the measurement. - **raw_data** (_bytes_) Received list of raw detection points. Each point consists of [x,y,z] coordinates plus the cosine of the incident angle, the index of the hit actor, and its semantic tag. ### Methods - **save_to_disk**(**self**, **path**) Saves the point cloud to disk as a .ply file describing data from 3D scanners. The files generated are ready to be used within [MeshLab](http://www.meshlab.net/), an open-source system for processing said files. Just take into account that axis may differ from Unreal Engine and so, need to be reallocated. - **Parameters:** - `path` (_str_) ##### Getters - **get_point_count**(**self**, **channel**) Retrieves the number of points sorted by channel that are generated by this measure. Sorting by channel allows to identify the original channel for every point. - **Parameters:** - `channel` (_int_) ##### Dunder methods - **\__getitem__**(**self**, **pos**=int) - **\__iter__**(**self**) Iterate over the [carla.SemanticLidarDetection](#carla.SemanticLidarDetection) retrieved as data. - **\__len__**(**self**) - **\__setitem__**(**self**, **pos**=int, **detection**=[carla.SemanticLidarDetection](#carla.SemanticLidarDetection)) - **\__str__**(**self**) --- ## carla.Sensor Inherited from _[carla.Actor](#carla.Actor)_
Sensors compound a specific family of actors quite diverse and unique. They are normally spawned as attachment/sons of a vehicle (take a look at [carla.World](#carla.World) to learn about actor spawning). Sensors are thoroughly designed to retrieve different types of data that they are listening to. The data they receive is shaped as different subclasses inherited from [carla.SensorData](#carla.SensorData) (depending on the sensor). Most sensors can be divided in two groups: those receiving data on every tick (cameras, point clouds and some specific sensors) and those who only receive under certain circumstances (trigger detectors). CARLA provides a specific set of sensors and their blueprint can be found in [carla.BlueprintLibrary](#carla.BlueprintLibrary). All the information on their preferences and settlement can be found [here](ref_sensors.md), but the list of those available in CARLA so far goes as follow.
Receive data on every tick. - [Depth camera](ref_sensors.md#depth-camera). - [Gnss sensor](ref_sensors.md#gnss-sensor). - [IMU sensor](ref_sensors.md#imu-sensor). - [Lidar raycast](ref_sensors.md#lidar-raycast-sensor). - [SemanticLidar raycast](ref_sensors.md#semanticlidar-raycast-sensor). - [Radar](ref_sensors.md#radar-sensor). - [RGB camera](ref_sensors.md#rgb-camera). - [RSS sensor](ref_sensors.md#rss-sensor). - [Semantic Segmentation camera](ref_sensors.md#semantic-segmentation-camera).
Only receive data when triggered. - [Collision detector](ref_sensors.md#collision-detector). - [Lane invasion detector](ref_sensors.md#lane-invasion-detector). - [Obstacle detector](ref_sensors.md#obstacle-detector). ### Instance Variables - **is_listening** (_boolean_) When True the sensor will be waiting for data. ### Methods - **is_listening**(**self**) Returns whether the sensor is in a listening state. - **is_listening_gbuffer**(**self**, **gbuffer_id**) Returns whether the sensor is in a listening state for a specific GBuffer texture. - **Parameters:** - `gbuffer_id` (_[carla.GBufferTextureID](#carla.GBufferTextureID)_) - The ID of the target Unreal Engine GBuffer texture. - **listen**(**self**, **callback**) The function the sensor will be calling to every time a new measurement is received. This function needs for an argument containing an object type [carla.SensorData](#carla.SensorData) to work with. - **Parameters:** - `callback` (_function_) - The called function with one argument containing the sensor data. - **listen_to_gbuffer**(**self**, **gbuffer_id**, **callback**) The function the sensor will be calling to every time the desired GBuffer texture is received.
This function needs for an argument containing an object type [carla.SensorData](#carla.SensorData) to work with. - **Parameters:** - `gbuffer_id` (_[carla.GBufferTextureID](#carla.GBufferTextureID)_) - The ID of the target Unreal Engine GBuffer texture. - `callback` (_function_) - The called function with one argument containing the received GBuffer texture. - **stop**(**self**) Commands the sensor to stop listening for data. - **stop_gbuffer**(**self**, **gbuffer_id**) Commands the sensor to stop listening for the specified GBuffer texture. - **Parameters:** - `gbuffer_id` (_[carla.GBufferTextureID](#carla.GBufferTextureID)_) - The ID of the Unreal Engine GBuffer texture. ##### Dunder methods - **\__str__**(**self**) --- ## carla.SensorData Base class for all the objects containing data generated by a [carla.Sensor](#carla.Sensor). This objects should be the argument of the function said sensor is listening to, in order to work with them. Each of these sensors needs for a specific type of sensor data. Hereunder is a list of the sensors and their corresponding data.
- Cameras (RGB, depth and semantic segmentation): [carla.Image](#carla.Image).
- Collision detector: [carla.CollisionEvent](#carla.CollisionEvent).
- GNSS sensor: [carla.GnssMeasurement](#carla.GnssMeasurement).
- IMU sensor: [carla.IMUMeasurement](#carla.IMUMeasurement).
- Lane invasion detector: [carla.LaneInvasionEvent](#carla.LaneInvasionEvent).
- LIDAR sensor: [carla.LidarMeasurement](#carla.LidarMeasurement).
- Obstacle detector: [carla.ObstacleDetectionEvent](#carla.ObstacleDetectionEvent).
- Radar sensor: [carla.RadarMeasurement](#carla.RadarMeasurement).
- RSS sensor: [carla.RssResponse](#carla.RssResponse).
- Semantic LIDAR sensor: [carla.SemanticLidarMeasurement](#carla.SemanticLidarMeasurement). ### Instance Variables - **frame** (_int_) Frame count when the data was generated. - **timestamp** (_float - seconds_) Simulation-time when the data was generated. - **transform** (_[carla.Transform](#carla.Transform)_) Sensor's transform when the data was generated. --- ## carla.TextureColor Class representing a texture object to be uploaded to the server. Pixel format is RGBA, uint8 per channel. ### Instance Variables - **width** (_int_) X-coordinate size of the texture. - **height** (_int_) Y-coordinate size of the texture. ### Methods - **\__init__**(**self**, **width**, **height**) Initializes a the texture with a (`width`, `height`) size. - **Parameters:** - `width` (_int_) - `height` (_int_) - **get**(**self**, **x**, **y**) Get the (x,y) pixel data. - **Parameters:** - `x` (_int_) - `y` (_int_) - **Return:** _[carla.Color](#carla.Color)_ - **set**(**self**, **x**, **y**, **value**) Sets the (x,y) pixel data with `value`. - **Parameters:** - `x` (_int_) - `y` (_int_) - `value` (_[carla.Color](#carla.Color)_) ##### Setters - **set_dimensions**(**self**, **width**, **height**) Resizes the texture to te specified dimensions. - **Parameters:** - `width` (_int_) - `height` (_int_) --- ## carla.TextureFloatColor Class representing a texture object to be uploaded to the server. Pixel format is RGBA, float per channel. ### Instance Variables - **width** (_int_) X-coordinate size of the texture. - **height** (_int_) Y-coordinate size of the texture. ### Methods - **\__init__**(**self**, **width**, **height**) Initializes a the texture with a (`width`, `height`) size. - **Parameters:** - `width` (_int_) - `height` (_int_) - **get**(**self**, **x**, **y**) Get the (x,y) pixel data. - **Parameters:** - `x` (_int_) - `y` (_int_) - **Return:** _[carla.FloatColor](#carla.FloatColor)_ - **set**(**self**, **x**, **y**, **value**) Sets the (x,y) pixel data with `value`. - **Parameters:** - `x` (_int_) - `y` (_int_) - `value` (_[carla.FloatColor](#carla.FloatColor)_) ##### Setters - **set_dimensions**(**self**, **width**, **height**) Resizes the texture to te specified dimensions. - **Parameters:** - `width` (_int_) - `height` (_int_) --- ## carla.Timestamp Class that contains time information for simulated data. This information is automatically retrieved as part of the [carla.WorldSnapshot](#carla.WorldSnapshot) the client gets on every frame, but might also be used in many other situations such as a [carla.Sensor](#carla.Sensor) retrieveing data. ### Instance Variables - **frame** (_int_) The number of frames elapsed since the simulator was launched. - **elapsed_seconds** (_float - seconds_) Simulated seconds elapsed since the beginning of the current episode. - **delta_seconds** (_float - seconds_) Simulated seconds elapsed since the previous frame. - **platform_timestamp** (_float - seconds_) Time register of the frame at which this measurement was taken given by the OS in seconds. ### Methods - **\__init__**(**self**, **frame**, **elapsed_seconds**, **delta_seconds**, **platform_timestamp**) - **Parameters:** - `frame` (_int_) - `elapsed_seconds` (_float - seconds_) - `delta_seconds` (_float - seconds_) - `platform_timestamp` (_float - seconds_) ##### Dunder methods - **\__eq__**(**self**, **other**=[carla.Timestamp](#carla.Timestamp)) - **\__ne__**(**self**, **other**=[carla.Timestamp](#carla.Timestamp)) - **\__str__**(**self**) --- ## carla.TrafficLight Inherited from _[carla.TrafficSign](#carla.TrafficSign)_
A traffic light actor, considered a specific type of traffic sign. As traffic lights will mostly appear at junctions, they belong to a group which contains the different traffic lights in it. Inside the group, traffic lights are differenciated by their pole index. Within a group the state of traffic lights is changed in a cyclic pattern: one index is chosen and it spends a few seconds in green, yellow and eventually red. The rest of the traffic lights remain frozen in red this whole time, meaning that there is a gap in the last seconds of the cycle where all the traffic lights are red. However, the state of a traffic light can be changed manually. ### Instance Variables - **state** (_[carla.TrafficLightState](#carla.TrafficLightState)_) Current state of the traffic light. ### Methods - **freeze**(**self**, **freeze**) Stops all the traffic lights in the scene at their current state. - **Parameters:** - `freeze` (_bool_) - **is_frozen**(**self**) The client returns True if a traffic light is frozen according to last tick. The method does not call the simulator. - **Return:** _bool_ - **reset_group**(**self**) Resets the state of the traffic lights of the group to the initial state at the start of the simulation. - **Note:** _This method calls the simulator. _ ##### Getters - **get_affected_lane_waypoints**(**self**) Returns a list of waypoints indicating the positions and lanes where the traffic light is having an effect. - **Return:** _list([carla.Waypoint](#carla.Waypoint))_ - **get_elapsed_time**(**self**) The client returns the time in seconds since current light state started according to last tick. The method does not call the simulator. - **Return:** _float - seconds_ - **get_green_time**(**self**) The client returns the time set for the traffic light to be green, according to last tick. The method does not call the simulator. - **Return:** _float - seconds_ - **Setter:** _[carla.TrafficLight.set_green_time](#carla.TrafficLight.set_green_time)_ - **get_group_traffic_lights**(**self**) Returns all traffic lights in the group this one belongs to. - **Return:** _list([carla.TrafficLight](#carla.TrafficLight))_ - **Note:** _This method calls the simulator. _ - **get_light_boxes**(**self**) Returns a list of the bounding boxes encapsulating each light box of the traffic light. - **Return:** _list([carla.BoundingBox](#carla.BoundingBox))_ - **get_opendrive_id**(**self**) Returns the OpenDRIVE id of this traffic light. - **Return:** _str_ - **get_pole_index**(**self**) Returns the index of the pole that identifies it as part of the traffic light group of a junction. - **Return:** _int_ - **get_red_time**(**self**) The client returns the time set for the traffic light to be red, according to last tick. The method does not call the simulator. - **Return:** _float - seconds_ - **Setter:** _[carla.TrafficLight.set_red_time](#carla.TrafficLight.set_red_time)_ - **get_state**(**self**) The client returns the state of the traffic light according to last tick. The method does not call the simulator. - **Return:** _[carla.TrafficLightState](#carla.TrafficLightState)_ - **Setter:** _[carla.TrafficLight.set_state](#carla.TrafficLight.set_state)_ - **get_stop_waypoints**(**self**) Returns a list of waypoints indicating the stop position for the traffic light. These waypoints are computed from the trigger boxes of the traffic light that indicate where a vehicle should stop. - **Return:** _list([carla.Waypoint](#carla.Waypoint))_ - **get_yellow_time**(**self**) The client returns the time set for the traffic light to be yellow, according to last tick. The method does not call the simulator. - **Return:** _float - seconds_ - **Setter:** _[carla.TrafficLight.set_yellow_time](#carla.TrafficLight.set_yellow_time)_ ##### Setters - **set_green_time**(**self**, **green_time**) - **Parameters:** - `green_time` (_float - seconds_) - Sets a given time for the green light to be active. - **Getter:** _[carla.TrafficLight.get_green_time](#carla.TrafficLight.get_green_time)_ - **set_red_time**(**self**, **red_time**) Sets a given time for the red state to be active. - **Parameters:** - `red_time` (_float - seconds_) - **Getter:** _[carla.TrafficLight.get_red_time](#carla.TrafficLight.get_red_time)_ - **set_state**(**self**, **state**) Sets a given state to a traffic light actor. - **Parameters:** - `state` (_[carla.TrafficLightState](#carla.TrafficLightState)_) - **Getter:** _[carla.TrafficLight.get_state](#carla.TrafficLight.get_state)_ - **set_yellow_time**(**self**, **yellow_time**) Sets a given time for the yellow light to be active. - **Parameters:** - `yellow_time` (_float - seconds_) - **Getter:** _[carla.TrafficLight.get_yellow_time](#carla.TrafficLight.get_yellow_time)_ ##### Dunder methods - **\__str__**(**self**) --- ## carla.TrafficLightState All possible states for traffic lights. These can either change at a specific time step or be changed manually. The snipet in [carla.TrafficLight.set_state](#carla.TrafficLight.set_state) changes the state of a traffic light on the fly. ### Instance Variables - **Red** - **Yellow** - **Green** - **Off** - **Unknown** --- ## carla.TrafficManager The traffic manager is a module built on top of the CARLA API in C++. It handles any group of vehicles set to autopilot mode to populate the simulation with realistic urban traffic conditions and give the chance to user to customize some behaviours. The architecture of the traffic manager is divided in five different goal-oriented stages and a PID controller where the information flows until eventually, a [carla.VehicleControl](#carla.VehicleControl) is applied to every vehicle registered in a traffic manager. In order to learn more, visit the [documentation](adv_traffic_manager.md) regarding this module. ### Methods - **auto_lane_change**(**self**, **actor**, **enable**) Turns on or off lane changing behaviour for a vehicle. - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor)_) - The vehicle whose settings are changed. - `enable` (_bool_) - __True__ is default and enables lane changes. __False__ will disable them. - **collision_detection**(**self**, **reference_actor**, **other_actor**, **detect_collision**) Tunes on/off collisions between a vehicle and another specific actor. In order to ignore all other vehicles, traffic lights or walkers, use the specific __ignore__ methods described in this same section. - **Parameters:** - `reference_actor` (_[carla.Actor](#carla.Actor)_) - Vehicle that is going to ignore collisions. - `other_actor` (_[carla.Actor](#carla.Actor)_) - The actor that `reference_actor` is going to ignore collisions with. - `detect_collision` (_bool_) - __True__ is default and enables collisions. __False__ will disable them. - **distance_to_leading_vehicle**(**self**, **actor**, **distance**) Sets the minimum distance in meters that a vehicle has to keep with the others. The distance is in meters and will affect the minimum moving distance. It is computed from front to back of the vehicle objects. - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor)_) - Vehicle whose minimum distance is being changed. - `distance` (_float - meters_) - Meters between both vehicles. - **force_lane_change**(**self**, **actor**, **direction**) Forces a vehicle to change either to the lane on its left or right, if existing, as indicated in `direction`. This method applies the lane change no matter what, disregarding possible collisions. - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor)_) - Vehicle being forced to change lanes. - `direction` (_bool_) - Destination lane. __True__ is the one on the right and __False__ is the left one. - **global_lane_offset**(**self**, **offset**) Sets a global lane offset displacement from the center line. Positive values imply a right offset while negative ones mean a left one. Default is 0. Numbers high enough to cause the vehicle to drive through other lanes might break the controller. - **Parameters:** - `offset` (_float_) - Lane offset displacement from the center line. - **global_percentage_speed_difference**(**self**, **percentage**) Sets the difference the vehicle's intended speed and its current speed limit. Speed limits can be exceeded by setting the `perc` to a negative value. Default is 30. Exceeding a speed limit can be done using negative percentages. - **Parameters:** - `percentage` (_float_) - Percentage difference between intended speed and the current limit. - **ignore_lights_percentage**(**self**, **actor**, **perc**) During the traffic light stage, which runs every frame, this method sets the percent chance that traffic lights will be ignored for a vehicle. - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor)_) - The actor that is going to ignore traffic lights. - `perc` (_float_) - Between 0 and 100. Amount of times traffic lights will be ignored. - **ignore_signs_percentage**(**self**, **actor**, **perc**) During the traffic light stage, which runs every frame, this method sets the percent chance that stop signs will be ignored for a vehicle. - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor)_) - The actor that is going to ignore stop signs. - `perc` (_float_) - Between 0 and 100. Amount of times stop signs will be ignored. - **ignore_vehicles_percentage**(**self**, **actor**, **perc**) During the collision detection stage, which runs every frame, this method sets a percent chance that collisions with another vehicle will be ignored for a vehicle. - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor)_) - The vehicle that is going to ignore other vehicles. - `perc` (_float_) - Between 0 and 100. Amount of times collisions will be ignored. - **ignore_walkers_percentage**(**self**, **actor**, **perc**) During the collision detection stage, which runs every frame, this method sets a percent chance that collisions with walkers will be ignored for a vehicle. - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor)_) - The vehicle that is going to ignore walkers on scene. - `perc` (_float_) - Between 0 and 100. Amount of times collisions will be ignored. - **keep_right_rule_percentage**(**self**, **actor**, **perc**) During the localization stage, this method sets a percent chance that vehicle will follow the *keep right* rule, and stay in the right lane. - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor)_) - Vehicle whose behaviour is being changed. - `perc` (_float_) - Between 0 and 100. Amount of times the vehicle will follow the keep right rule. - **random_left_lanechange_percentage**(**self**, **actor**, **percentage**) Adjust probability that in each timestep the actor will perform a left lane change, dependent on lane change availability. - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor)_) - The actor that you wish to query. - `percentage` (_float_) - The probability of lane change in percentage units (between 0 and 100). - **random_right_lanechange_percentage**(**self**, **actor**, **percentage**) Adjust probability that in each timestep the actor will perform a right lane change, dependent on lane change availability. - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor)_) - The actor that you wish to query. - `percentage` (_float_) - The probability of lane change in percentage units (between 0 and 100). - **shut_down**(**self**) Shuts down the traffic manager. - **update_vehicle_lights**(**self**, **actor**, **do_update**) Sets if the Traffic Manager is responsible of updating the vehicle lights, or not. Default is __False__. The traffic manager will not change the vehicle light status of a vehicle, unless its auto_update_status is st to __True__. - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor)_) - Vehicle whose lights status is being changed. - `do_update` (_bool_) - If __True__ the traffic manager will manage the vehicle lights for the specified vehicle. - **vehicle_lane_offset**(**self**, **actor**, **offset**) Sets a lane offset displacement from the center line. Positive values imply a right offset while negative ones mean a left one. Default is 0. Numbers high enough to cause the vehicle to drive through other lanes might break the controller. - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor)_) - Vehicle whose lane offset behaviour is being changed. - `offset` (_float_) - Lane offset displacement from the center line. - **vehicle_percentage_speed_difference**(**self**, **actor**, **percentage**) Sets the difference the vehicle's intended speed and its current speed limit. Speed limits can be exceeded by setting the `perc` to a negative value. Default is 30. Exceeding a speed limit can be done using negative percentages. - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor)_) - Vehicle whose speed behaviour is being changed. - `percentage` (_float_) - Percentage difference between intended speed and the current limit. ##### Getters - **get_all_actions**(**self**, **actor**) Returns all known actions (i.e. road options and waypoints) that an actor controlled by the Traffic Manager will perform in its next steps. - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor)_) - The actor that you wish to query. - **Return:** _list of lists with each element as follows - [Road option (string e.g. 'Left', 'Right', 'Straight'), Next waypoint ([carla.Waypoint](#carla.Waypoint))]_ - **get_next_action**(**self**, **actor**) Returns the next known road option and waypoint that an actor controlled by the Traffic Manager will follow. - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor)_) - The actor that you wish to query. - **Return:** _list of two elements - [Road option (string e.g. 'Left', 'Right', 'Straight'), Next waypoint ([carla.Waypoint](#carla.Waypoint))]_ - **get_port**(**self**) Returns the port where the Traffic Manager is connected. If the object is a TM-Client, it will return the port of its TM-Server. Read the [documentation](#adv_traffic_manager.md#multiclient-and-multitm-management) to learn the difference. - **Return:** _uint16_ ##### Setters - **set_boundaries_respawn_dormant_vehicles**(**self**, **lower_bound**=25.0, **upper_bound**=actor_active_distance) Sets the upper and lower boundaries for dormant actors to be respawned near the hero vehicle. - **Parameters:** - `lower_bound` (_float_) - The minimum distance in meters from the hero vehicle that a dormant actor will be respawned. - `upper_bound` (_float_) - The maximum distance in meters from the hero vehicle that a dormant actor will be respawned. - **Warning:** _The `upper_bound` cannot be higher than the `actor_active_distance`. The `lower_bound` cannot be less than 25. _ - **set_desired_speed**(**self**, **actor**, **speed**) Sets the speed of a vehicle to the specified value. - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor)_) - Vehicle whose speed is being changed. - `speed` (_float_) - Desired speed at which the vehicle will move. - **set_global_distance_to_leading_vehicle**(**self**, **distance**) Sets the minimum distance in meters that vehicles have to keep with the rest. The distance is in meters and will affect the minimum moving distance. It is computed from center to center of the vehicle objects. - **Parameters:** - `distance` (_float - meters_) - Meters between vehicles. - **set_hybrid_physics_mode**(**self**, **enabled**=False) Enables or disables the hybrid physics mode. In this mode, vehicle's farther than a certain radius from the ego vehicle will have their physics disabled. Computation cost will be reduced by not calculating vehicle dynamics. Vehicles will be teleported. - **Parameters:** - `enabled` (_bool_) - If __True__, enables the hybrid physics. - **set_hybrid_physics_radius**(**self**, **r**=50.0) With hybrid physics on, changes the radius of the area of influence where physics are enabled. - **Parameters:** - `r` (_float - meters_) - New radius where physics are enabled. - **set_osm_mode**(**self**, **mode_switch**=True) Enables or disables the OSM mode. This mode allows the user to run TM in a map created with the [OSM feature](tuto_G_openstreetmap.md). These maps allow having dead-end streets. Normally, if vehicles cannot find the next waypoint, TM crashes. If OSM mode is enabled, it will show a warning, and destroy vehicles when necessary. - **Parameters:** - `mode_switch` (_bool_) - If __True__, the OSM mode is enabled. - **set_path**(**self**, **actor**, **path**) Sets a list of locations for a vehicle to follow while controlled by the Traffic Manager. - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor)_) - The actor that must follow the given path. - `path` (_list_) - The list of [carla.Locations](#carla.Locations) for the actor to follow. - **Warning:** _Ensure that the road topology doesn't impede the given path. _ - **set_random_device_seed**(**self**, **value**) Sets a specific random seed for the Traffic Manager, thereby setting it to be deterministic. - **Parameters:** - `value` (_int_) - Seed value for the random number generation of the Traffic Manager. - **set_respawn_dormant_vehicles**(**self**, **mode_switch**=False) If __True__, vehicles in large maps will respawn near the hero vehicle when they become dormant. Otherwise, they will stay dormant until they are within `actor_active_distance` of the hero vehicle again. - **Parameters:** - `mode_switch` (_bool_) - **set_route**(**self**, **actor**, **path**) Sets a list of route instructions for a vehicle to follow while controlled by the Traffic Manager. The possible route instructions are 'Left', 'Right', 'Straight'. - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor)_) - The actor that must follow the given route instructions. - `path` (_list_) - The list of route instructions (string) for the vehicle to follow. - **Warning:** _Ensure that the lane topology doesn't impede the given route. _ - **set_synchronous_mode**(**self**, **mode_switch**=True) Sets the Traffic Manager to [synchronous mode](adv_traffic_manager.md#synchronous-mode). In a [multiclient situation](adv_traffic_manager.md#multiclient), only the TM-Server can tick. Similarly, in a [multiTM situation](adv_traffic_manager.md#multitm), only one TM-Server must tick. Use this method in the client that does the world tick, and right after setting the world to synchronous mode, to set which TM will be the master while in sync. - **Parameters:** - `mode_switch` (_bool_) - If __True__, the TM synchronous mode is enabled. - **Warning:** _If the server is set to synchronous mode, the TM must be set to synchronous mode too in the same client that does the tick. _ --- ## carla.TrafficSign Inherited from _[carla.Actor](#carla.Actor)_
Traffic signs appearing in the simulation except for traffic lights. These have their own class inherited from this in [carla.TrafficLight](#carla.TrafficLight). Right now, speed signs, stops and yields are mainly the ones implemented, but many others are borne in mind. ### Instance Variables - **trigger_volume** A [carla.BoundingBox](#carla.BoundingBox) situated near a traffic sign where the [carla.Actor](#carla.Actor) who is inside can know about it. --- ## carla.Transform Class that defines a transformation, a combination of location and rotation, without scaling. ### Instance Variables - **location** (_[carla.Location](#carla.Location)_) Describes a point in the coordinate system. - **rotation** (_[carla.Rotation](#carla.Rotation) - degrees (pitch, yaw, roll)_) Describes a rotation for an object according to Unreal Engine's axis system. ### Methods - **\__init__**(**self**, **location**, **rotation**) - **Parameters:** - `location` (_[carla.Location](#carla.Location)_) - `rotation` (_[carla.Rotation](#carla.Rotation) - degrees (pitch, yaw, roll)_) - **transform**(**self**, **in_point**) Translates a 3D point from local to global coordinates using the current transformation as frame of reference. - **Parameters:** - `in_point` (_[carla.Location](#carla.Location)_) - Location in the space to which the transformation will be applied. - **transform_vector**(**self**, **in_vector**) Rotates a vector using the current transformation as frame of reference, without applying translation. Use this to transform, for example, a velocity. - **Parameters:** - `in_vector` (_[carla.Vector3D](#carla.Vector3D)_) - Vector to which the transformation will be applied. ##### Getters - **get_forward_vector**(**self**) Computes a forward vector using the rotation of the object. - **Return:** _[carla.Vector3D](#carla.Vector3D)_ - **get_inverse_matrix**(**self**) Computes the 4-matrix representation of the inverse transformation. - **Return:** _list(list(float))_ - **get_matrix**(**self**) Computes the 4-matrix representation of the transformation. - **Return:** _list(list(float))_ - **get_right_vector**(**self**) Computes a right vector using the rotation of the object. - **Return:** _[carla.Vector3D](#carla.Vector3D)_ - **get_up_vector**(**self**) Computes an up vector using the rotation of the object. - **Return:** _[carla.Vector3D](#carla.Vector3D)_ ##### Dunder methods - **\__eq__**(**self**, **other**=[carla.Transform](#carla.Transform)) Returns __True__ if both location and rotation are equal for this and `other`. - **Return:** _bool_ - **\__ne__**(**self**, **other**=[carla.Transform](#carla.Transform)) Returns __True__ if any location and rotation are not equal for this and `other`. - **Return:** _bool_ - **\__str__**(**self**) Parses both location and rotation to string. - **Return:** _str_ --- ## carla.Vector2D Helper class to perform 2D operations. ### Instance Variables - **x** (_float_) X-axis value. - **y** (_float_) Y-axis value. ### Methods - **\__init__**(**self**, **x**=0.0, **y**=0.0) - **Parameters:** - `x` (_float_) - `y` (_float_) - **length**(**self**) Computes the length of the vector. - **Return:** _float_ - **make_unit_vector**(**self**) Returns a vector with the same direction and unitary length. - **Return:** _[carla.Vector3D](#carla.Vector3D)_ - **squared_length**(**self**) Computes the squared length of the vector. - **Return:** _float_ ##### Dunder methods - **\__add__**(**self**, **other**=[carla.Vector2D](#carla.Vector2D)) - **\__eq__**(**self**, **other**=[carla.Vector2D](#carla.Vector2D)) Returns __True__ if values for every axis are equal. - **Return:** _bool_ - **\__mul__**(**self**, **other**=[carla.Vector2D](#carla.Vector2D)) - **\__ne__**(**self**, **bool**=[carla.Vector2D](#carla.Vector2D)) Returns __True__ if the value for any axis is different. - **Return:** _bool_ - **\__str__**(**self**) Returns the axis values for the vector parsed as string. - **Return:** _str_ - **\__sub__**(**self**, **other**=[carla.Vector2D](#carla.Vector2D)) - **\__truediv__**(**self**, **other**=[carla.Vector2D](#carla.Vector2D)) --- ## carla.Vector3D Helper class to perform 3D operations. ### Instance Variables - **x** (_float_) X-axis value. - **y** (_float_) Y-axis value. - **z** (_float_) Z-axis value. ### Methods - **\__init__**(**self**, **x**=0.0, **y**=0.0, **z**=0.0) - **Parameters:** - `x` (_float_) - `y` (_float_) - `z` (_float_) - **cross**(**self**, **vector**) Computes the cross product between two vectors. - **Parameters:** - `vector` (_[carla.Vector3D](#carla.Vector3D)_) - **Return:** _[carla.Vector3D](#carla.Vector3D)_ - **distance**(**self**, **vector**) Computes the distance between two vectors. - **Parameters:** - `vector` (_[carla.Vector3D](#carla.Vector3D)_) - **Return:** _float_ - **distance_2d**(**self**, **vector**) Computes the 2-dimensional distance between two vectors. - **Parameters:** - `vector` (_[carla.Vector3D](#carla.Vector3D)_) - **Return:** _float_ - **distance_squared**(**self**, **vector**) Computes the squared distance between two vectors. - **Parameters:** - `vector` (_[carla.Vector3D](#carla.Vector3D)_) - **Return:** _float_ - **distance_squared_2d**(**self**, **vector**) Computes the 2-dimensional squared distance between two vectors. - **Parameters:** - `vector` (_[carla.Vector3D](#carla.Vector3D)_) - **Return:** _float_ - **dot**(**self**, **vector**) Computes the dot product between two vectors. - **Parameters:** - `vector` (_[carla.Vector3D](#carla.Vector3D)_) - **Return:** _float_ - **dot_2d**(**self**, **vector**) Computes the 2-dimensional dot product between two vectors. - **Parameters:** - `vector` (_[carla.Vector3D](#carla.Vector3D)_) - **Return:** _float_ - **length**(**self**) Computes the length of the vector. - **Return:** _float_ - **make_unit_vector**(**self**) Returns a vector with the same direction and unitary length. - **Return:** _[carla.Vector3D](#carla.Vector3D)_ - **squared_length**(**self**) Computes the squared length of the vector. - **Return:** _float_ ##### Getters - **get_vector_angle**(**self**, **vector**) Computes the angle between a pair of 3D vectors in radians. - **Parameters:** - `vector` (_[carla.Vector3D](#carla.Vector3D)_) - **Return:** _float_ ##### Dunder methods - **\__abs__**(**self**) Returns a Vector3D with the absolute value of the components x, y and z. - **Return:** _[carla.Vector3D](#carla.Vector3D)_ - **\__add__**(**self**, **other**=[carla.Vector3D](#carla.Vector3D)) - **\__eq__**(**self**, **other**=[carla.Vector3D](#carla.Vector3D)) Returns __True__ if values for every axis are equal. - **Return:** _bool_ - **\__mul__**(**self**, **other**=[carla.Vector3D](#carla.Vector3D)) - **\__ne__**(**self**, **other**=[carla.Vector3D](#carla.Vector3D)) Returns __True__ if the value for any axis is different. - **Return:** _bool_ - **\__str__**(**self**) Returns the axis values for the vector parsed as string. - **Return:** _str_ - **\__sub__**(**self**, **other**=[carla.Vector3D](#carla.Vector3D)) - **\__truediv__**(**self**, **other**=[carla.Vector3D](#carla.Vector3D)) --- ## carla.Vehicle Inherited from _[carla.Actor](#carla.Actor)_
One of the most important groups of actors in CARLA. These include any type of vehicle from cars to trucks, motorbikes, vans, bycicles and also official vehicles such as police cars. A wide set of these actors is provided in [carla.BlueprintLibrary](#carla.BlueprintLibrary) to facilitate differente requirements. Vehicles can be either manually controlled or set to an autopilot mode that will be conducted client-side by the traffic manager. ### Instance Variables - **bounding_box** (_[carla.BoundingBox](#carla.BoundingBox)_) Bounding box containing the geometry of the vehicle. Its location and rotation are relative to the vehicle it is attached to. ### Methods - **apply_ackermann_control**(**self**, **control**) Applies an Ackermann control object on the next tick. - **Parameters:** - `control` (_[carla.VehicleAckermannControl](#carla.VehicleAckermannControl)_) - **apply_ackermann_controller_settings**(**self**, **settings**) Applies a new Ackermann control settings to this vehicle in the next tick. - **Parameters:** - `settings` (_[carla.AckermannControllerSettings](#carla.AckermannControllerSettings)_) - **Warning:** _This method does call the simulator._ - **apply_control**(**self**, **control**) Applies a control object on the next tick, containing driving parameters such as throttle, steering or gear shifting. - **Parameters:** - `control` (_[carla.VehicleControl](#carla.VehicleControl)_) - **apply_physics_control**(**self**, **physics_control**) Applies a physics control object in the next tick containing the parameters that define the vehicle as a corporeal body. E.g.: moment of inertia, mass, drag coefficient and many more. - **Parameters:** - `physics_control` (_[carla.VehiclePhysicsControl](#carla.VehiclePhysicsControl)_) - **close_door**(**self**, **door_idx**) Close the door `door_idx` if the vehicle has it. Use [carla.VehicleDoor.All](#carla.VehicleDoor.All) to close all available doors. - **Parameters:** - `door_idx` (_[carla.VehicleDoor](#carla.VehicleDoor)_) - door index. - **enable_carsim**(**self**, **simfile_path**) Enables the CarSim physics solver for this particular vehicle. In order for this function to work, there needs to be a valid license manager running on the server side. The control inputs are redirected to CarSim which will provide the position and orientation of the vehicle for every frame. - **Parameters:** - `simfile_path` (_str_) - Path to the `.simfile` file with the parameters of the simulation. - **enable_chrono_physics**(**self**, **max_substeps**, **max_substep_delta_time**, **vehicle_json**, **powertrain_json**, **tire_json**, **base_json_path**) Enables Chrono physics on a spawned vehicle. - **Parameters:** - `max_substeps` (_int_) - Max number of Chrono substeps. - `max_substep_delta_time` (_int_) - Max size of substep. - `vehicle_json` (_str_) - Path to vehicle json file relative to `base_json_path`. - `powertrain_json` (_str_) - Path to powertrain json file relative to `base_json_path`. - `tire_json` (_str_) - Path to tire json file relative to `base_json_path`. - `base_json_path` (_str_) - Path to `chrono/data/vehicle` folder. E.g., `/home/user/carla/Build/chrono-install/share/chrono/data/vehicle/` (the final `/` character is required). - **Note:** _Ensure that you have started the CARLA server with the `ARGS="--chrono"` flag. You will not be able to use Chrono physics without this flag set. _ - **Warning:** _Collisions are not supported. When a collision is detected, physics will revert to the default CARLA physics. _ - **is_at_traffic_light**(**self**) Vehicles will be affected by a traffic light when the light is red and the vehicle is inside its bounding box. The client returns whether a traffic light is affecting this vehicle according to last tick (it does not call the simulator). - **Return:** _bool_ - **open_door**(**self**, **door_idx**) Open the door `door_idx` if the vehicle has it. Use [carla.VehicleDoor.All](#carla.VehicleDoor.All) to open all available doors. - **Parameters:** - `door_idx` (_[carla.VehicleDoor](#carla.VehicleDoor)_) - door index. - **show_debug_telemetry**(**self**, **enabled**=True) Enables or disables the telemetry on this vehicle. This shows information about the vehicles current state and forces applied to it in the spectator window. Only information for one vehicle can be shown so that, if you enable a second one, the previous will be automatically disabled. - **Parameters:** - `enabled` (_bool_) - **use_carsim_road**(**self**, **enabled**) Enables or disables the usage of CarSim vs terrain file specified in the `.simfile`. By default this option is disabled and CarSim uses unreal engine methods to process the geometry of the scene. - **Parameters:** - `enabled` (_bool_) ##### Getters - **get_ackermann_controller_settings**(**self**) Returns the last Ackermann control settings applied to this vehicle. - **Return:** _[carla.AckermannControllerSettings](#carla.AckermannControllerSettings)_ - **Warning:** _This method does call the simulator to retrieve the value._ - **get_control**(**self**) The client returns the control applied in the last tick. The method does not call the simulator. - **Return:** _[carla.VehicleControl](#carla.VehicleControl)_ - **get_failure_state**(**self**) Vehicle have failure states, to indicate that it is incapable of continuing its route. This function returns the vehicle's specific failure state, or in other words, the cause that resulted in it. - **Return:** _[carla.VehicleFailureState](#carla.VehicleFailureState)_ - **get_light_state**(**self**) Returns a flag representing the vehicle light state, this represents which lights are active or not. - **Return:** _[carla.VehicleLightState](#carla.VehicleLightState)_ - **Setter:** _[carla.Vehicle.set_light_state](#carla.Vehicle.set_light_state)_ - **get_physics_control**(**self**) The simulator returns the last physics control applied to this vehicle. - **Return:** _[carla.VehiclePhysicsControl](#carla.VehiclePhysicsControl)_ - **Warning:** _This method does call the simulator to retrieve the value._ - **get_speed_limit**(**self**) The client returns the speed limit affecting this vehicle according to last tick (it does not call the simulator). The speed limit is updated when passing by a speed limit signal, so a vehicle might have none right after spawning. - **Return:** _float - km/h_ - **get_traffic_light**(**self**) Retrieves the traffic light actor affecting this vehicle (if any) according to last tick. The method does not call the simulator. - **Return:** _[carla.TrafficLight](#carla.TrafficLight)_ - **get_traffic_light_state**(**self**) The client returns the state of the traffic light affecting this vehicle according to last tick. The method does not call the simulator. If no traffic light is currently affecting the vehicle, returns green. - **Return:** _[carla.TrafficLightState](#carla.TrafficLightState)_ - **get_wheel_steer_angle**(**self**, **wheel_location**) Returns the physics angle in degrees of a vehicle's wheel. - **Parameters:** - `wheel_location` (_[carla.VehicleWheelLocation](#carla.VehicleWheelLocation)_) - **Return:** _float_ - **Note:** _Returns the angle based on the physics of the wheel, not the visual angle. _ ##### Setters - **set_autopilot**(**self**, **enabled**=True, **port**=8000) Registers or deletes the vehicle from a Traffic Manager's list. When __True__, the Traffic Manager passed as parameter will move the vehicle around. The autopilot takes place client-side. - **Parameters:** - `enabled` (_bool_) - `port` (_uint16_) - The port of the TM-Server where the vehicle is to be registered or unlisted. If __None__ is passed, it will consider a TM at default port `8000`. - **set_light_state**(**self**, **light_state**) Sets the light state of a vehicle using a flag that represents the lights that are on and off. - **Parameters:** - `light_state` (_[carla.VehicleLightState](#carla.VehicleLightState)_) - **Getter:** _[carla.Vehicle.get_light_state](#carla.Vehicle.get_light_state)_ - **set_wheel_steer_direction**(**self**, **wheel_location**, **angle_in_deg**) Sets the angle of a vehicle's wheel visually. - **Parameters:** - `wheel_location` (_[carla.VehicleWheelLocation](#carla.VehicleWheelLocation)_) - `angle_in_deg` (_float_) - **Warning:** _Does not affect the physics of the vehicle. _ ##### Dunder methods - **\__str__**(**self**) --- ## carla.VehicleAckermannControl Manages the basic movement of a vehicle using Ackermann driving controls. ### Instance Variables - **steer** (_float_) Desired steer (rad). Positive value is to the right. Default is 0.0. - **steer_speed** (_float_) Steering velocity (rad/s). Zero steering angle velocity means change the steering angle as quickly as possible. Default is 0.0. - **speed** (_float_) Desired speed (m/s). Default is 0.0. - **acceleration** (_float_) Desired acceleration (m/s2) Default is 0.0. - **jerk** (_float_) Desired jerk (m/s3). Default is 0.0. ### Methods - **\__init__**(**self**, **steer**=0.0, **steer_speed**=0.0, **speed**=0.0, **acceleration**=0.0, **jerk**=0.0) - **Parameters:** - `steer` (_float_) - `steer_speed` (_float_) - `speed` (_float_) - `acceleration` (_float_) - `jerk` (_float_) ##### Dunder methods - **\__eq__**(**self**, **other**=[carla.AckermannVehicleControl](#carla.AckermannVehicleControl)) - **\__ne__**(**self**, **other**=[carla.AckermannVehicleControl](#carla.AckermannVehicleControl)) - **\__str__**(**self**) --- ## carla.VehicleControl Manages the basic movement of a vehicle using typical driving controls. ### Instance Variables - **throttle** (_float_) A scalar value to control the vehicle throttle [0.0, 1.0]. Default is 0.0. - **steer** (_float_) A scalar value to control the vehicle steering [-1.0, 1.0]. Default is 0.0. - **brake** (_float_) A scalar value to control the vehicle brake [0.0, 1.0]. Default is 0.0. - **hand_brake** (_bool_) Determines whether hand brake will be used. Default is False. - **reverse** (_bool_) Determines whether the vehicle will move backwards. Default is False. - **manual_gear_shift** (_bool_) Determines whether the vehicle will be controlled by changing gears manually. Default is False. - **gear** (_int_) States which gear is the vehicle running on. ### Methods - **\__init__**(**self**, **throttle**=0.0, **steer**=0.0, **brake**=0.0, **hand_brake**=False, **reverse**=False, **manual_gear_shift**=False, **gear**=0) - **Parameters:** - `throttle` (_float_) - Scalar value between [0.0,1.0]. - `steer` (_float_) - Scalar value between [0.0,1.0]. - `brake` (_float_) - Scalar value between [0.0,1.0]. - `hand_brake` (_bool_) - `reverse` (_bool_) - `manual_gear_shift` (_bool_) - `gear` (_int_) ##### Dunder methods - **\__eq__**(**self**, **other**=[carla.VehicleControl](#carla.VehicleControl)) - **\__ne__**(**self**, **other**=[carla.VehicleControl](#carla.VehicleControl)) - **\__str__**(**self**) --- ## carla.VehicleDoor Possible index representing the possible doors that can be open. Notice that not all possible doors are able to open in some vehicles. ### Instance Variables - **FL** Front left door. - **FR** Front right door. - **RL** Back left door. - **RR** Back right door. - **All** Represents all doors. --- ## carla.VehicleFailureState Enum containing the different failure states of a vehicle, from which the it cannot recover. These are returned by __get_failure_state()__ and only Rollover is currently implemented. ### Instance Variables - **NONE** - **Rollover** - **Engine** - **TirePuncture** --- ## carla.VehicleLightState Class that recaps the state of the lights of a vehicle, these can be used as a flags. E.g: `VehicleLightState.HighBeam & VehicleLightState.Brake` will return `True` when both are active. Lights are off by default in any situation and should be managed by the user via script. The blinkers blink automatically. _Warning: Right now, not all vehicles have been prepared to work with this functionality, this will be added to all of them in later updates_. ### Instance Variables - **NONE** All lights off. - **Position** - **LowBeam** - **HighBeam** - **Brake** - **RightBlinker** - **LeftBlinker** - **Reverse** - **Fog** - **Interior** - **Special1** This is reserved for certain vehicles that can have special lights, like a siren. - **Special2** This is reserved for certain vehicles that can have special lights, like a siren. - **All** All lights on. --- ## carla.VehiclePhysicsControl Summarizes the parameters that will be used to simulate a [carla.Vehicle](#carla.Vehicle) as a physical object. The specific settings for the wheels though are stipulated using [carla.WheelPhysicsControl](#carla.WheelPhysicsControl). ### Instance Variables - **torque_curve** (_list([carla.Vector2D](#carla.Vector2D))_) Curve that indicates the torque measured in Nm for a specific RPM of the vehicle's engine. - **max_torque** (_float_) The maximum vehicle's engine Torque (Nm). - **max_rpm** (_float_) The maximum RPM of the vehicle's engine. - **moi** (_float - kg*m2_) The moment of inertia of the vehicle's engine. - **rev_down_rate** (_float_) Affects how fast the vehicle's engine RPM slows down. - **differential_type** (int) Type of differential (Undefined = 0, AllWheelDrive = 1, FrontWheelDrive = 2, RearWheelDrive = 3). - **front_rear_split** (_float_) Ratio of torque split between front and rear (<0.5 means more to front, >0.5 means more to rear, works only with 4W type). - **use_gear_autobox** (_bool_) If True, the vehicle will have an automatic transmission. - **gear_switch_time** (_float - seconds_) Switching time between gears. - **final_ratio** (_float_) Fixed ratio from transmission to wheels. - **forward_gears** (_list(float)_) List of floats defining the vehicle's gears. - **reverse_gears** (_list(float)_) List of floats defining the vehicle's reverse gears (there is normally only one). - **change_up_rpm** (_float_) Vehicle's engine RPM at which gear up change ocurrs. - **change_down_rpm** (_float_) Vehicle's engine RPM at which gear down change ocurrs. - **transmission_efficiency** (_float_) Mechanical frictional losses. If set to 0.9 means that the transmission operate at 90% efficiency. - **mass** (_float - kilograms_) Mass of the vehicle. - **drag_coefficient** (_float_) Drag coefficient of the vehicle's chassis. - **center_of_mass** (_[carla.Vector3D](#carla.Vector3D) - meters_) Center of mass of the vehicle. - **steering_curve** (_list([carla.Vector2D](#carla.Vector2D))_) Curve that indicates the maximum steering for a specific forward speed. - **use_sweep_wheel_collision** (_bool_) Enable the use of sweep for wheel collision. By default, it is disabled and it uses a simple raycast from the axis to the floor for each wheel. This option provides a better collision model in which the full volume of the wheel is checked against collisions. - **wheels** (_list([carla.WheelPhysicsControl](#carla.WheelPhysicsControl))_) List of wheel physics objects. This list should have 4 elements, where index 0 corresponds to the front left wheel, index 1 corresponds to the front right wheel, index 2 corresponds to the back left wheel and index 3 corresponds to the back right wheel. For 2 wheeled vehicles, set the same values for both front and back wheels. ### Methods - **\__init__**(**self**, **torque_curve**=[[0.0, 500.0], [5000.0, 500.0]], **max_torque**=300.0, **max_rpm**=5000.0, **moi**=1.0, **rev_down_rate**=600.0, **differential_type**=3, **front_rear_split**=0.5, **use_gear_autobox**=True, **gear_switch_time**=0.5, **final_ratio**=4.0, **forward_gears**=[2.85, 2.02, 1.35, 1.0, 2.85, 2.02, 1.35, 1.0], **reverse_gears**=[2.86, 2.86], **change_up_rpm**=4500.0, **change_down_rpm**=2000.0, **transmission_efficiency**=0.9, **mass**=1000.0, **drag_coefficient**=0.3, **center_of_mass**=[0.0, 0.0, 0.0], **steering_curve**=[[0.0, 1.0], [10.0, 0.5]], **wheels**=list(), **use_sweep_wheel_collision**=False) VehiclePhysicsControl constructor. - **Parameters:** - `torque_curve` (_list([carla.Vector2D](#carla.Vector2D))_) - `max_torque` (_float_) - `max_rpm` (_float_) - `moi` (_float - kg*m2_) - `rev_down_rate` (_float_) - `differential_type` (_int_) - `front_rear_split` (_float_) - `use_gear_autobox` (_bool_) - `gear_switch_time` (_float - seconds_) - `final_ratio` (_float_) - `forward_gears` (_list(float)_) - `reverse_gears` (_list(float)_) - `change_up_rpm` (_float_) - `change_down_rpm` (_float_) - `transmission_efficiency` (_float_) - `mass` (_float - kilograms_) - `drag_coefficient` (_float_) - `center_of_mass` (_[carla.Vector3D](#carla.Vector3D)_) - `steering_curve` (_[carla.Vector2D](#carla.Vector2D)_) - `wheels` (_list([carla.WheelPhysicsControl](#carla.WheelPhysicsControl))_) - `use_sweep_wheel_collision` (_bool_) ##### Dunder methods - **\__eq__**(**self**, **other**=[carla.VehiclePhysicsControl](#carla.VehiclePhysicsControl)) - **\__ne__**(**self**, **other**=[carla.VehiclePhysicsControl](#carla.VehiclePhysicsControl)) - **\__str__**(**self**) --- ## carla.VehicleWheelLocation `enum` representing the position of each wheel on a vehicle. Used to identify the target wheel when setting an angle in [carla.Vehicle.set_wheel_steer_direction](#carla.Vehicle.set_wheel_steer_direction) or [carla.Vehicle.get_wheel_steer_angle](#carla.Vehicle.get_wheel_steer_angle). ### Instance Variables - **FL_Wheel** Front left wheel of a 4 wheeled vehicle. - **FR_Wheel** Front right wheel of a 4 wheeled vehicle. - **BL_Wheel** Back left wheel of a 4 wheeled vehicle. - **BR_Wheel** Back right wheel of a 4 wheeled vehicle. - **Front_Wheel** Front wheel of a 2 wheeled vehicle. - **Back_Wheel** Back wheel of a 2 wheeled vehicle. --- ## carla.Walker Inherited from _[carla.Actor](#carla.Actor)_
This class inherits from the [carla.Actor](#carla.Actor) and defines pedestrians in the simulation. Walkers are a special type of actor that can be controlled either by an AI ([carla.WalkerAIController](#carla.WalkerAIController)) or manually via script, using a series of [carla.WalkerControl](#carla.WalkerControl) to move these and their skeletons. ### Methods - **apply_control**(**self**, **control**) On the next tick, the control will move the walker in a certain direction with a certain speed. Jumps can be commanded too. - **Parameters:** - `control` (_[carla.WalkerControl](#carla.WalkerControl)_) - **blend_pose**(**self**, **blend_value**) Set the blending value of the custom pose with the animation. The values can be: - 0: will show only the animation - 1: will show only the custom pose (set by the user with set_bones()) - any other: will interpolate all the bone positions between animation and the custom pose. - **Parameters:** - `blend_value` (_float - value from 0 to 1 with the blend percentage_) - **hide_pose**(**self**) Hide the custom pose and show the animation (same as calling blend_pose(0)). - **show_pose**(**self**) Show the custom pose and hide the animation (same as calling blend_pose(1)). ##### Getters - **get_bones**(**self**) Return the structure with all the bone transformations from the actor. For each bone, we get the name and its transform in three different spaces: - name: bone name - world: transform in world coordinates - component: transform based on the pivot of the actor - relative: transform based on the bone parent. - **Return:** _[carla.WalkerBoneControlOut](#carla.WalkerBoneControlOut)_ - **Setter:** _[carla.Walker.set_bones](#carla.Walker.set_bones)_ - **get_control**(**self**) The client returns the control applied to this walker during last tick. The method does not call the simulator. - **Return:** _[carla.WalkerControl](#carla.WalkerControl)_ - **get_pose_from_animation**(**self**) Make a copy of the current animation frame as the custom pose. Initially the custom pose is the neutral pedestrian pose. ##### Setters - **set_bones**(**self**, **bones**) Set the bones of the actor. For each bone we want to set we use a relative transform. Only the bones in this list will be set. For each bone you need to setup this info: - name: bone name - relative: transform based on the bone parent. - **Parameters:** - `bones` (_[carla.WalkerBoneControlIn](#carla.WalkerBoneControlIn) - list of pairs (bone_name, transform) for the bones that we want to set_) - **Getter:** _[carla.Walker.get_bones](#carla.Walker.get_bones)_ ##### Dunder methods - **\__str__**(**self**) --- ## carla.WalkerAIController Inherited from _[carla.Actor](#carla.Actor)_
Class that conducts AI control for a walker. The controllers are defined as actors, but they are quite different from the rest. They need to be attached to a parent actor during their creation, which is the walker they will be controlling (take a look at [carla.World](#carla.World) if you are yet to learn on how to spawn actors). They also need for a special blueprint (already defined in [carla.BlueprintLibrary](#carla.BlueprintLibrary) as "controller.ai.walker"). This is an empty blueprint, as the AI controller will be invisible in the simulation but will follow its parent around to dictate every step of the way. ### Methods - **go_to_location**(**self**, **destination**) Sets the destination that the pedestrian will reach. - **Parameters:** - `destination` (_[carla.Location](#carla.Location) - meters_) - **start**(**self**) Enables AI control for its parent walker. - **stop**(**self**) Disables AI control for its parent walker. ##### Setters - **set_max_speed**(**self**, **speed**=1.4) Sets a speed for the walker in meters per second. - **Parameters:** - `speed` (_float - m/s_) - An easy walking speed is set by default. ##### Dunder methods - **\__str__**(**self**) --- ## carla.WalkerBoneControlIn This class grants bone specific manipulation for walker. The skeletons of walkers have been unified for clarity and the transform applied to each bone are always relative to its parent. Take a look [here](tuto_G_control_walker_skeletons.md) to learn more on how to create a walker and define its movement. ### Instance Variables - **bone_transforms** (_list([name,transform])_) List with the data for each bone we want to set: - name: bone name - relative: transform based on the bone parent. ### Methods - **\__init__**(**self**, **list(name,transform)**) Initializes an object containing moves to be applied on tick. These are listed with the name of the bone and the transform that will be applied to it. - **Parameters:** - `list(name,transform)` (_tuple_) ##### Dunder methods - **\__str__**(**self**) --- ## carla.WalkerBoneControlOut This class is used to return all bone positions of a pedestrian. For each bone we get its _name_ and its transform in three different spaces (world, actor and relative). ### Instance Variables - **bone_transforms** (_list([name,world, actor, relative])_) List of one entry per bone with this information: - name: bone name - world: transform in world coordinates - component: transform based on the pivot of the actor - relative: transform based on the bone parent. ### Methods ##### Dunder methods - **\__str__**(**self**) --- ## carla.WalkerControl This class defines specific directions that can be commanded to a [carla.Walker](#carla.Walker) to control it via script. AI control can be settled for walkers, but the control used to do so is [carla.WalkerAIController](#carla.WalkerAIController). ### Instance Variables - **direction** (_[carla.Vector3D](#carla.Vector3D)_) Vector using global coordinates that will correspond to the direction of the walker. - **speed** (_float - m/s_) A scalar value to control the walker's speed. - **jump** (_bool_) If True, the walker will perform a jump. ### Methods - **\__init__**(**self**, **direction**=[1.0, 0.0, 0.0], **speed**=0.0, **jump**=False) - **Parameters:** - `direction` (_[carla.Vector3D](#carla.Vector3D)_) - `speed` (_float - m/s_) - `jump` (_bool_) ##### Dunder methods - **\__eq__**(**self**, **other**=[carla.WalkerControl](#carla.WalkerControl)) Compares every variable with `other` and returns True if these are all the same. - **\__ne__**(**self**, **other**=[carla.WalkerControl](#carla.WalkerControl)) Compares every variable with `other` and returns True if any of these differ. - **\__str__**(**self**) --- ## carla.Waypoint Waypoints in CARLA are described as 3D directed points. They have a [carla.Transform](#carla.Transform) which locates the waypoint in a road and orientates it according to the lane. They also store the road information belonging to said point regarding its lane and lane markings.

All the information regarding waypoints and the [waypoint API](../../core_map/#navigation-in-carla) is retrieved as provided by the OpenDRIVE file. Once the client asks for the map object to the server, no longer communication will be needed. ### Instance Variables - **id** (_int_) The identifier is generated using a hash combination of the road, section, lane and s values that correspond to said point in the OpenDRIVE geometry. The s precision is set to 2 centimeters, so 2 waypoints closer than 2 centimeters in the same road, section and lane, will have the same identificator. - **transform** (_[carla.Transform](#carla.Transform)_) Position and orientation of the waypoint according to the current lane information. This data is computed the first time it is accessed. It is not created right away in order to ease computing costs when lots of waypoints are created but their specific transform is not needed. - **road_id** (_int_) OpenDRIVE road's id. - **section_id** (_int_) OpenDRIVE section's id, based on the order that they are originally defined. - **is_junction** (_bool_) True if the current Waypoint is on a junction as defined by OpenDRIVE. - **junction_id** (_int_) OpenDRIVE junction's id. For more information refer to OpenDRIVE [documentation](http://www.opendrive.org/docs/OpenDRIVEFormatSpecRev1.4H.pdf#page=20). - **lane_id** (_int_) OpenDRIVE lane's id, this value can be positive or negative which represents the direction of the current lane with respect to the road. For more information refer to OpenDRIVE [documentation](http://www.opendrive.org/docs/OpenDRIVEFormatSpecRev1.4H.pdf#page=20). - **s** (_float_) OpenDRIVE s value of the current position. - **lane_width** (_float_) Horizontal size of the road at current s. - **lane_change** (_[carla.LaneChange](#carla.LaneChange)_) Lane change definition of the current Waypoint's location, based on the traffic rules defined in the OpenDRIVE file. It states if a lane change can be done and in which direction. - **lane_type** (_[carla.LaneType](#carla.LaneType)_) The lane type of the current Waypoint, based on OpenDRIVE 1.4 standard. - **right_lane_marking** (_[carla.LaneMarking](#carla.LaneMarking)_) The right lane marking information based on the direction of the Waypoint. - **left_lane_marking** (_[carla.LaneMarking](#carla.LaneMarking)_) The left lane marking information based on the direction of the Waypoint. ### Methods - **next**(**self**, **distance**) Returns a list of waypoints at a certain approximate `distance` from the current one. It takes into account the road and its possible deviations without performing any lane change and returns one waypoint per option. The list may be empty if the lane is not connected to any other at the specified distance. - **Parameters:** - `distance` (_float - meters_) - The approximate distance where to get the next waypoints. - **Return:** _list([carla.Waypoint](#carla.Waypoint))_ - **next_until_lane_end**(**self**, **distance**) Returns a list of waypoints from this to the end of the lane separated by a certain `distance`. - **Parameters:** - `distance` (_float - meters_) - The approximate distance between waypoints. - **Return:** _list([carla.Waypoint](#carla.Waypoint))_ - **previous**(**self**, **distance**) This method does not return the waypoint previously visited by an actor, but a list of waypoints at an approximate `distance` but in the opposite direction of the lane. Similarly to **next()**, it takes into account the road and its possible deviations without performing any lane change and returns one waypoint per option. The list may be empty if the lane is not connected to any other at the specified distance. - **Parameters:** - `distance` (_float - meters_) - The approximate distance where to get the previous waypoints. - **Return:** _list([carla.Waypoint](#carla.Waypoint))_ - **previous_until_lane_start**(**self**, **distance**) Returns a list of waypoints from this to the start of the lane separated by a certain `distance`. - **Parameters:** - `distance` (_float - meters_) - The approximate distance between waypoints. - **Return:** _list([carla.Waypoint](#carla.Waypoint))_ ##### Getters - **get_junction**(**self**) If the waypoint belongs to a junction this method returns the associated junction object. Otherwise returns null. - **Return:** _[carla.Junction](#carla.Junction)_ - **get_landmarks**(**self**, **distance**, **stop_at_junction**=False) Returns a list of landmarks in the road from the current waypoint until the specified distance. - **Parameters:** - `distance` (_float - meters_) - The maximum distance to search for landmarks from the current waypoint. - `stop_at_junction` (_bool_) - Enables or disables the landmark search through junctions. - **Return:** _list([carla.Landmark](#carla.Landmark))_ - **get_landmarks_of_type**(**self**, **distance**, **type**, **stop_at_junction**=False) Returns a list of landmarks in the road of a specified type from the current waypoint until the specified distance. - **Parameters:** - `distance` (_float - meters_) - The maximum distance to search for landmarks from the current waypoint. - `type` (_str_) - The type of landmarks to search. - `stop_at_junction` (_bool_) - Enables or disables the landmark search through junctions. - **Return:** _list([carla.Landmark](#carla.Landmark))_ - **get_left_lane**(**self**) Generates a Waypoint at the center of the left lane based on the direction of the current Waypoint, taking into account if the lane change is allowed in this location. Will return None if the lane does not exist. - **Return:** _[carla.Waypoint](#carla.Waypoint)_ - **get_right_lane**(**self**) Generates a waypoint at the center of the right lane based on the direction of the current waypoint, taking into account if the lane change is allowed in this location. Will return None if the lane does not exist. - **Return:** _[carla.Waypoint](#carla.Waypoint)_ ##### Dunder methods - **\__str__**(**self**) --- ## carla.WeatherParameters This class defines objects containing lighting and weather specifications that can later be applied in [carla.World](#carla.World). So far, these conditions only intervene with [sensor.camera.rgb](ref_sensors.md#rgb-camera). They neither affect the actor's physics nor other sensors. Each of these parameters acts indepently from the rest. Increasing the rainfall will not automatically create puddles nor change the road's humidity. That makes for a better customization but means that realistic conditions need to be scripted. However an example of dynamic weather conditions working realistically can be found [here](https://github.com/carla-simulator/carla/blob/master/PythonAPI/examples/dynamic_weather.py). ### Instance Variables - **cloudiness** (_float_) Values range from 0 to 100, being 0 a clear sky and 100 one completely covered with clouds. - **precipitation** (_float_) Rain intensity values range from 0 to 100, being 0 none at all and 100 a heavy rain. - **precipitation_deposits** (_float_) Determines the creation of puddles. Values range from 0 to 100, being 0 none at all and 100 a road completely capped with water. Puddles are created with static noise, meaning that they will always appear at the same locations. - **wind_intensity** (_float_) Controls the strenght of the wind with values from 0, no wind at all, to 100, a strong wind. The wind does affect rain direction and leaves from trees, so this value is restricted to avoid animation issues. - **sun_azimuth_angle** (_float - degrees_) The azimuth angle of the sun. Values range from 0 to 360. Zero is an origin point in a sphere determined by Unreal Engine. - **sun_altitude_angle** (_float - degrees_) Altitude angle of the sun. Values range from -90 to 90 corresponding to midnight and midday each. - **fog_density** (_float_) Fog concentration or thickness. It only affects the RGB camera sensor. Values range from 0 to 100. - **fog_distance** (_float - meters_) Fog start distance. Values range from 0 to infinite. - **wetness** (_float_) Wetness intensity. It only affects the RGB camera sensor. Values range from 0 to 100. - **fog_falloff** (_float_) Density of the fog (as in specific mass) from 0 to infinity. The bigger the value, the more dense and heavy it will be, and the fog will reach smaller heights. Corresponds to Fog Height Falloff in the UE docs.
If the value is 0, the fog will be lighter than air, and will cover the whole scene.
A value of 1 is approximately as dense as the air, and reaches normal-sized buildings.
For values greater than 5, the air will be so dense that it will be compressed on ground level. - **scattering_intensity** (_float_) Controls how much the light will contribute to volumetric fog. When set to 0, there is no contribution. - **mie_scattering_scale** (_float_) Controls interaction of light with large particles like pollen or air pollution resulting in a hazy sky with halos around the light sources. When set to 0, there is no contribution. - **rayleigh_scattering_scale** (_float_) Controls interaction of light with small particles like air molecules. Dependent on light wavelength, resulting in a blue sky in the day or red sky in the evening. - **dust_storm** (_float_) Determines the strength of the dust storm weather. Values range from 0 to 100. ### Methods - **\__init__**(**self**, **cloudiness**=0.0, **precipitation**=0.0, **precipitation_deposits**=0.0, **wind_intensity**=0.0, **sun_azimuth_angle**=0.0, **sun_altitude_angle**=0.0, **fog_density**=0.0, **fog_distance**=0.0, **wetness**=0.0, **fog_falloff**=0.0, **scattering_intensity**=0.0, **mie_scattering_scale**=0.0, **rayleigh_scattering_scale**=0.0331) Method to initialize an object defining weather conditions. This class has some presets for different noon and sunset conditions listed in a note below. - **Parameters:** - `cloudiness` (_float_) - 0 is a clear sky, 100 complete overcast. - `precipitation` (_float_) - 0 is no rain at all, 100 a heavy rain. - `precipitation_deposits` (_float_) - 0 means no puddles on the road, 100 means roads completely capped by rain. - `wind_intensity` (_float_) - 0 is calm, 100 a strong wind. - `sun_azimuth_angle` (_float - degrees_) - 0 is an arbitrary North, 180 its corresponding South. - `sun_altitude_angle` (_float - degrees_) - 90 is midday, -90 is midnight. - `fog_density` (_float_) - Concentration or thickness of the fog, from 0 to 100. - `fog_distance` (_float - meters_) - Distance where the fog starts in meters. - `wetness` (_float_) - Humidity percentages of the road, from 0 to 100. - `fog_falloff` (_float_) - Density (specific mass) of the fog, from 0 to infinity. - `scattering_intensity` (_float_) - Controls how much the light will contribute to volumetric fog. When set to 0, there is no contribution. - `mie_scattering_scale` (_float_) - Controls interaction of light with large particles like pollen or air pollution resulting in a hazy sky with halos around the light sources. When set to 0, there is no contribution. - `rayleigh_scattering_scale` (_float_) - Controls interaction of light with small particles like air molecules. Dependent on light wavelength, resulting in a blue sky in the day or red sky in the evening. - **Note:** _ClearNoon, CloudyNoon, WetNoon, WetCloudyNoon, SoftRainNoon, MidRainyNoon, HardRainNoon, ClearSunset, CloudySunset, WetSunset, WetCloudySunset, SoftRainSunset, MidRainSunset, HardRainSunset. _ ##### Dunder methods - **\__eq__**(**self**, **other**) Returns True if both objects' variables are the same. - **Return:** _bool_ - **\__ne__**(**self**, **other**) Returns True if both objects' variables are different. - **Return:** _bool_ - **\__str__**(**self**) --- ## carla.WheelPhysicsControl Class that defines specific physical parameters for wheel objects that will be part of a [carla.VehiclePhysicsControl](#carla.VehiclePhysicsControl) to simulate vehicle it as a material object. ### Instance Variables - **tire_friction** (_float_) A scalar value that indicates the friction of the wheel. - **max_steer_angle** (_float - degrees_) Maximum angle that the wheel can steer. - **radius** (_float - centimeters_) Radius of the wheel. - **cornering_stiffness** (_float_) Tyre Cornering Ability. - **abs** (_bool_) Indicates if the Advanced Braking System is enabled. - **traction_control** (_bool_) Indicates if the Straight Line Traction Control is enabled. - **max_brake_torque** (_float - N*m_) Maximum brake torque. - **max_handbrake_torque** (_float - N*m_) Maximum handbrake torque. - **position** (_[carla.Vector3D](#carla.Vector3D)_) World position of the wheel. This is a read-only parameter. ### Methods - **\__init__**(**self**, **tire_friction**=3.0, **max_steer_angle**=70.0, **radius**=30.0, **cornering_stiffness**=1000.0, **abs**=False, **traction_control**=False, **max_brake_torque**=1500.0, **max_handbrake_torque**=3000.0, **position**=(0.0,0.0,0.0)) - **Parameters:** - `tire_friction` (_float_) - `max_steer_angle` (_float - degrees_) - `radius` (_float - centimerers_) - `cornering_stiffness` (_float_) - `abs` (_bool_) - `traction_control` (_bool_) - `max_brake_torque` (_float - N*m_) - `max_handbrake_torque` (_float - N*m_) - `position` (_[carla.Vector3D](#carla.Vector3D) - meters_) ##### Dunder methods - **\__eq__**(**self**, **other**=[carla.WheelPhysicsControl](#carla.WheelPhysicsControl)) - **\__ne__**(**self**, **other**=[carla.WheelPhysicsControl](#carla.WheelPhysicsControl)) - **\__str__**(**self**) --- ## carla.World World objects are created by the client to have a place for the simulation to happen. The world contains the map we can see, meaning the asset, not the navigation map. Navigation maps are part of the [carla.Map](#carla.Map) class. It also manages the weather and actors present in it. There can only be one world per simulation, but it can be changed anytime. ### Instance Variables - **id** (_int_) The ID of the episode associated with this world. Episodes are different sessions of a simulation. These change everytime a world is disabled or reloaded. Keeping track is useful to avoid possible issues. - **debug** (_[carla.DebugHelper](#carla.DebugHelper)_) Responsible for creating different shapes for debugging. Take a look at its class to learn more about it. ### Methods - **apply_color_texture_to_object**(**self**, **object_name**, **material_parameter**, **texture**) Applies a `texture` object in the field corresponfing to `material_parameter` (normal, diffuse, etc) to the object in the scene corresponding to `object_name`. - **Parameters:** - `object_name` (_str_) - `material_parameter` (_[carla.MaterialParameter](#carla.MaterialParameter)_) - `texture` (_TextureColor_) - **apply_color_texture_to_objects**(**self**, **objects_name_list**, **material_parameter**, **texture**) Applies a `texture` object in the field corresponfing to `material_parameter` (normal, diffuse, etc) to the object in the scene corresponding to all objects in `objects_name_list`. - **Parameters:** - `objects_name_list` (_list(str)_) - `material_parameter` (_[carla.MaterialParameter](#carla.MaterialParameter)_) - `texture` (_TextureColor_) - **apply_float_color_texture_to_object**(**self**, **object_name**, **material_parameter**, **texture**) Applies a `texture` object in the field corresponfing to `material_parameter` (normal, diffuse, etc) to the object in the scene corresponding to `object_name`. - **Parameters:** - `object_name` (_str_) - `material_parameter` (_[carla.MaterialParameter](#carla.MaterialParameter)_) - `texture` (_TextureFloatColor_) - **apply_float_color_texture_to_objects**(**self**, **objects_name_list**, **material_parameter**, **texture**) Applies a `texture` object in the field corresponfing to `material_parameter` (normal, diffuse, etc) to the object in the scene corresponding to all objects in `objects_name_list`. - **Parameters:** - `objects_name_list` (_list(str)_) - `material_parameter` (_[carla.MaterialParameter](#carla.MaterialParameter)_) - `texture` (_TextureFloatColor_) - **apply_settings**(**self**, **world_settings**) This method applies settings contained in an object to the simulation running and returns the ID of the frame they were implemented. - **Parameters:** - `world_settings` (_[carla.WorldSettings](#carla.WorldSettings)_) - **Return:** _int_ - **Warning:** _If synchronous mode is enabled, and there is a Traffic Manager running, this must be set to sync mode too. Read [this](adv_traffic_manager.md#synchronous-mode) to learn how to do it. _ - **apply_textures_to_object**(**self**, **object_name**, **diffuse_texture**, **emissive_texture**, **normal_texture**, **ao_roughness_metallic_emissive_texture**) Applies all texture fields in [carla.MaterialParameter](#carla.MaterialParameter) to the object `object_name`. Empty textures here will not be applied. - **Parameters:** - `object_name` (_str_) - `diffuse_texture` (_TextureColor_) - `emissive_texture` (_TextureFloatColor_) - `normal_texture` (_TextureFloatColor_) - `ao_roughness_metallic_emissive_texture` (_TextureFloatColor_) - **apply_textures_to_objects**(**self**, **objects_name_list**, **diffuse_texture**, **emissive_texture**, **normal_texture**, **ao_roughness_metallic_emissive_texture**) Applies all texture fields in [carla.MaterialParameter](#carla.MaterialParameter) to all objects in `objects_name_list`. Empty textures here will not be applied. - **Parameters:** - `objects_name_list` (_list(str)_) - `diffuse_texture` (_TextureColor_) - `emissive_texture` (_TextureFloatColor_) - `normal_texture` (_TextureFloatColor_) - `ao_roughness_metallic_emissive_texture` (_TextureFloatColor_) - **cast_ray**(**self**, **initial_location**, **final_location**) Casts a ray from the specified initial_location to final_location. The function then detects all geometries intersecting the ray and returns a list of [carla.LabelledPoint](#carla.LabelledPoint) in order. - **Parameters:** - `initial_location` (_[carla.Location](#carla.Location)_) - The initial position of the ray. - `final_location` (_[carla.Location](#carla.Location)_) - The final position of the ray. - **Return:** _list([carla.LabelledPoint](#carla.LabelledPoint))_ - **enable_environment_objects**(**self**, **env_objects_ids**, **enable**) Enable or disable a set of EnvironmentObject identified by their id. These objects will appear or disappear from the level. - **Parameters:** - `env_objects_ids` (_set(int)_) - Set of EnvironmentObject ids to change. - `enable` (_bool_) - State to be applied to all the EnvironmentObject of the set. - **freeze_all_traffic_lights**(**self**, **frozen**) Freezes or unfreezes all traffic lights in the scene. Frozen traffic lights can be modified by the user but the time will not update them until unfrozen. - **Parameters:** - `frozen` (_bool_) - **ground_projection**(**self**, **location**, **search_distance**) Projects the specified point downwards in the scene. The functions casts a ray from location in the direction (0,0,-1) (downwards) and returns a [carla.LabelledPoint](#carla.LabelledPoint) object with the first geometry this ray intersects (usually the ground). If no geometry is found in the search_distance range the function returns `None`. - **Parameters:** - `location` (_[carla.Location](#carla.Location)_) - The point to be projected. - `search_distance` (_float_) - The maximum distance to perform the projection. - **Return:** _[carla.LabelledPoint](#carla.LabelledPoint)_ - **load_map_layer**(**self**, **map_layers**) Loads the selected layers to the level. If the layer is already loaded the call has no effect. - **Parameters:** - `map_layers` (_[carla.MapLayer](#carla.MapLayer)_) - Mask of level layers to be loaded. - **Warning:** _This only affects "Opt" maps. The minimum layout includes roads, sidewalks, traffic lights and traffic signs._ - **on_tick**(**self**, **callback**) This method is used in [__asynchronous__ mode](https://[carla.readthedocs.io](#carla.readthedocs.io)/en/latest/adv_synchrony_timestep/). It starts callbacks from the client for the function defined as `callback`, and returns the ID of the callback. The function will be called everytime the server ticks. It requires a [carla.WorldSnapshot](#carla.WorldSnapshot) as argument, which can be retrieved from __wait_for_tick()__. Use __remove_on_tick()__ to stop the callbacks. - **Parameters:** - `callback` (_[carla.WorldSnapshot](#carla.WorldSnapshot)_) - Function with a snapshot as compulsory parameter that will be called when the client receives a tick. - **Return:** _int_ - **project_point**(**self**, **location**, **direction**, **search_distance**) Projects the specified point to the desired direction in the scene. The functions casts a ray from location in a direction and returns a [carla.Labelled](#carla.Labelled) object with the first geometry this ray intersects. If no geometry is found in the search_distance range the function returns `None`. - **Parameters:** - `location` (_[carla.Location](#carla.Location)_) - The point to be projected. - `direction` (_[carla.Vector3D](#carla.Vector3D)_) - The direction of projection. - `search_distance` (_float_) - The maximum distance to perform the projection. - **Return:** _[carla.LabelledPoint](#carla.LabelledPoint)_ - **remove_on_tick**(**self**, **callback_id**) Stops the callback for `callback_id` started with __on_tick()__. - **Parameters:** - `callback_id` (_callback_) - The callback to be removed. The ID is returned when creating the callback. - **reset_all_traffic_lights**(**self**) Resets the cycle of all traffic lights in the map to the initial state. - **spawn_actor**(**self**, **blueprint**, **transform**, **attach_to**=None, **attachment**=Rigid) The method will create, return and spawn an actor into the world. The actor will need an available blueprint to be created and a transform (location and rotation). It can also be attached to a parent with a certain attachment type. - **Parameters:** - `blueprint` (_[carla.ActorBlueprint](#carla.ActorBlueprint)_) - The reference from which the actor will be created. - `transform` (_[carla.Transform](#carla.Transform)_) - Contains the location and orientation the actor will be spawned with. - `attach_to` (_[carla.Actor](#carla.Actor)_) - The parent object that the spawned actor will follow around. - `attachment` (_[carla.AttachmentType](#carla.AttachmentType)_) - Determines how fixed and rigorous should be the changes in position according to its parent object. - **Return:** _[carla.Actor](#carla.Actor)_ - **tick**(**self**, **seconds**=10.0) This method is used in [__synchronous__ mode](https://[carla.readthedocs.io](#carla.readthedocs.io)/en/latest/adv_synchrony_timestep/), when the server waits for a client tick before computing the next frame. This method will send the tick, and give way to the server. It returns the ID of the new frame computed by the server. - **Parameters:** - `seconds` (_float - seconds_) - Maximum time the server should wait for a tick. It is set to 10.0 by default. - **Return:** _int_ - **Note:** _If no tick is received in synchronous mode, the simulation will freeze. Also, if many ticks are received from different clients, there may be synchronization issues. Please read the docs about [synchronous mode](https://[carla.readthedocs.io](#carla.readthedocs.io)/en/latest/adv_synchrony_timestep/) to learn more. _ - **try_spawn_actor**(**self**, **blueprint**, **transform**, **attach_to**=None, **attachment**=Rigid) Same as __spawn_actor()__ but returns None on failure instead of throwing an exception. - **Parameters:** - `blueprint` (_[carla.ActorBlueprint](#carla.ActorBlueprint)_) - The reference from which the actor will be created. - `transform` (_[carla.Transform](#carla.Transform)_) - Contains the location and orientation the actor will be spawned with. - `attach_to` (_[carla.Actor](#carla.Actor)_) - The parent object that the spawned actor will follow around. - `attachment` (_[carla.AttachmentType](#carla.AttachmentType)_) - Determines how fixed and rigorous should be the changes in position according to its parent object. - **Return:** _[carla.Actor](#carla.Actor)_ - **unload_map_layer**(**self**, **map_layers**) Unloads the selected layers to the level. If the layer is already unloaded the call has no effect. - **Parameters:** - `map_layers` (_[carla.MapLayer](#carla.MapLayer)_) - Mask of level layers to be unloaded. - **Warning:** _This only affects "Opt" maps. The minimum layout includes roads, sidewalks, traffic lights and traffic signs._ - **wait_for_tick**(**self**, **seconds**=10.0) This method is used in [__asynchronous__ mode](https://[carla.readthedocs.io](#carla.readthedocs.io)/en/latest/adv_synchrony_timestep/). It makes the client wait for a server tick. When the next frame is computed, the server will tick and return a snapshot describing the new state of the world. - **Parameters:** - `seconds` (_float - seconds_) - Maximum time the server should wait for a tick. It is set to 10.0 by default. - **Return:** _[carla.WorldSnapshot](#carla.WorldSnapshot)_ ##### Getters - **get_actor**(**self**, **actor_id**) Looks up for an actor by ID and returns None if not found. - **Parameters:** - `actor_id` (_int_) - **Return:** _[carla.Actor](#carla.Actor)_ - **get_actors**(**self**, **actor_ids**=None) Retrieves a list of [carla.Actor](#carla.Actor) elements, either using a list of IDs provided or just listing everyone on stage. If an ID does not correspond with any actor, it will be excluded from the list returned, meaning that both the list of IDs and the list of actors may have different lengths. - **Parameters:** - `actor_ids` (_list_) - The IDs of the actors being searched. By default it is set to None and returns every actor on scene. - **Return:** _[carla.ActorList](#carla.ActorList)_ - **get_blueprint_library**(**self**) Returns a list of actor blueprints available to ease the spawn of these into the world. - **Return:** _[carla.BlueprintLibrary](#carla.BlueprintLibrary)_ - **get_environment_objects**(**self**, **object_type**=Any) Returns a list of EnvironmentObject with the requested semantic tag. The method returns all the EnvironmentObjects in the level by default, but the query can be filtered by semantic tags with the argument `object_type`. - **Parameters:** - `object_type` (_[carla.CityObjectLabel](#carla.CityObjectLabel)_) - Semantic tag of the EnvironmentObjects that are returned. - **Return:** _array([carla.EnvironmentObject](#carla.EnvironmentObject))_ - **get_level_bbs**(**self**, **actor_type**=Any) Returns an array of bounding boxes with location and rotation in world space. The method returns all the bounding boxes in the level by default, but the query can be filtered by semantic tags with the argument `actor_type`. - **Parameters:** - `actor_type` (_[carla.CityObjectLabel](#carla.CityObjectLabel)_) - Semantic tag of the elements contained in the bounding boxes that are returned. - **Return:** _array([carla.BoundingBox](#carla.BoundingBox))_ - **get_lightmanager**(**self**) Returns an instance of [carla.LightManager](#carla.LightManager) that can be used to handle the lights in the scene. - **Return:** _[carla.LightManager](#carla.LightManager)_ - **get_map**(**self**) Asks the server for the XODR containing the map file, and returns this parsed as a [carla.Map](#carla.Map). - **Return:** _[carla.Map](#carla.Map)_ - **Warning:** _This method does call the simulation. It is expensive, and should only be called once. _ - **get_names_of_all_objects**(**self**) Returns a list of the names of all objects in the scene that can be painted with the apply texture functions. - **Return:** _list(str)_ - **get_random_location_from_navigation**(**self**) This can only be used with walkers. It retrieves a random location to be used as a destination using the __go_to_location()__ method in [carla.WalkerAIController](#carla.WalkerAIController). This location will be part of a sidewalk. Roads, crosswalks and grass zones are excluded. The method does not take into consideration locations of existing actors so if a collision happens when trying to spawn an actor, it will return an error. Take a look at [`generate_traffic.py`](https://github.com/carla-simulator/carla/blob/master/PythonAPI/examples/generate_traffic.py) for an example. - **Return:** _[carla.Location](#carla.Location)_ - **get_settings**(**self**) Returns an object containing some data about the simulation such as synchrony between client and server or rendering mode. - **Return:** _[carla.WorldSettings](#carla.WorldSettings)_ - **get_snapshot**(**self**) Returns a snapshot of the world at a certain moment comprising all the information about the actors. - **Return:** _[carla.WorldSnapshot](#carla.WorldSnapshot)_ - **get_spectator**(**self**) Returns the spectator actor. The spectator is a special type of actor created by Unreal Engine, usually with ID=0, that acts as a camera and controls the view in the simulator window. - **Return:** _[carla.Actor](#carla.Actor)_ - **get_traffic_light**(**self**, **landmark**) Provided a landmark, returns the traffic light object it describes. - **Parameters:** - `landmark` (_[carla.Landmark](#carla.Landmark)_) - The landmark object describing a traffic light. - **Return:** _[carla.TrafficLight](#carla.TrafficLight)_ - **get_traffic_light_from_opendrive_id**(**self**, **traffic_light_id**) Returns the traffic light actor corresponding to the indicated OpenDRIVE id. - **Parameters:** - `traffic_light_id` (_str_) - The OpenDRIVE id. - **Return:** _[carla.TrafficLight](#carla.TrafficLight)_ - **get_traffic_lights_from_waypoint**(**self**, **waypoint**, **distance**) This function performs a search along the road in front of the specified waypoint and returns a list of traffic light actors found in the specified search distance. - **Parameters:** - `waypoint` (_[carla.Waypoint](#carla.Waypoint)_) - The input waypoint. - `distance` (_float_) - Search distance. - **Return:** _list([carla.TrafficLight](#carla.TrafficLight))_ - **get_traffic_lights_in_junction**(**self**, **junction_id**) Returns the list of traffic light actors affecting the junction indicated in `junction_id`. - **Parameters:** - `junction_id` (_int_) - The id of the junction. - **Return:** _list([carla.TrafficLight](#carla.TrafficLight))_ - **get_traffic_sign**(**self**, **landmark**) Provided a landmark, returns the traffic sign object it describes. - **Parameters:** - `landmark` (_[carla.Landmark](#carla.Landmark)_) - The landmark object describing a traffic sign. - **Return:** _[carla.TrafficSign](#carla.TrafficSign)_ - **get_vehicles_light_states**(**self**) Returns a dict where the keys are [carla.Actor](#carla.Actor) IDs and the values are [carla.VehicleLightState](#carla.VehicleLightState) of that vehicle. - **Return:** _dict_ - **get_weather**(**self**) Retrieves an object containing weather parameters currently active in the simulation, mainly cloudiness, precipitation, wind and sun position. - **Return:** _[carla.WeatherParameters](#carla.WeatherParameters)_ - **Setter:** _[carla.World.set_weather](#carla.World.set_weather)_ ##### Setters - **set_pedestrians_cross_factor**(**self**, **percentage**) - **Parameters:** - `percentage` (_float_) - Sets the percentage of pedestrians that can walk on the road or cross at any point on the road. Value should be between `0.0` and `1.0`. For example, a value of `0.1` would allow 10% of pedestrians to walk on the road. __Default is `0.0`__. - **Note:** _Should be set before pedestrians are spawned. _ - **set_pedestrians_seed**(**self**, **seed**) - **Parameters:** - `seed` (_int_) - Sets the seed to use for any random number generated in relation to pedestrians. - **Note:** _Should be set before pedestrians are spawned. If you want to repeat the same exact bodies (blueprint) for each pedestrian, then use the same seed in the Python code (where the blueprint is choosen randomly) and here, otherwise the pedestrians will repeat the same paths but the bodies will be different. _ - **set_weather**(**self**, **weather**) Changes the weather parameteres ruling the simulation to another ones defined in an object. - **Parameters:** - `weather` (_[carla.WeatherParameters](#carla.WeatherParameters)_) - New conditions to be applied. - **Getter:** _[carla.World.get_weather](#carla.World.get_weather)_ ##### Dunder methods - **\__str__**(**self**) The content of the world is parsed and printed as a brief report of its current state. - **Return:** _string_ --- ## carla.WorldSettings The simulation has some advanced configuration options that are contained in this class and can be managed using [carla.World](#carla.World) and its methods. These allow the user to choose between client-server synchrony/asynchrony, activation of "no rendering mode" and either if the simulation should run with a fixed or variable time-step. Check [this](adv_synchrony_timestep.md) out if you want to learn about it. ### Instance Variables - **synchronous_mode** (_bool_) States the synchrony between client and server. When set to true, the server will wait for a client tick in order to move forward. It is false by default. - **no_rendering_mode** (_bool_) When enabled, the simulation will run no rendering at all. This is mainly used to avoid overhead during heavy traffic simulations. It is false by default. - **fixed_delta_seconds** (_float_) Ensures that the time elapsed between two steps of the simulation is fixed. Set this to 0.0 to work with a variable time-step, as happens by default. - **substepping** (_bool_) Enable the physics substepping. This option allows computing some physics substeps between two render frames. If synchronous mode is set, the number of substeps and its time interval are fixed and computed are so they fulfilled the requirements of [carla.WorldSettings.max_substep](#carla.WorldSettings.max_substep) and [carla.WorldSettings.max_substep_delta_time](#carla.WorldSettings.max_substep_delta_time). These last two parameters need to be compatible with [carla.WorldSettings.fixed_delta_seconds](#carla.WorldSettings.fixed_delta_seconds). Enabled by default. - **max_substep_delta_time** (_float_) Maximum delta time of the substeps. If the [carla.WorldSettingsmax_substep](#carla.WorldSettingsmax_substep) is high enough, the substep delta time would be always below or equal to this value. By default, the value is set to 0.01. - **max_substeps** (_int_) The maximum number of physics substepping that are allowed. By default, the value is set to 10. - **max_culling_distance** (_float_) Configure the max draw distance for each mesh of the level. - **deterministic_ragdolls** (_bool_) Defines wether to use deterministic physics for pedestrian death animations or physical ragdoll simulation. When enabled, pedestrians have less realistic death animation but ensures determinism. When disabled, pedestrians are simulated as ragdolls with more realistic simulation and collision but no determinsm can be ensured. - **tile_stream_distance** (_float_) Used for large maps only. Configures the maximum distance from the hero vehicle to stream tiled maps. Regions of the map within this range will be visible (and capable of simulating physics). Regions outside this region will not be loaded. - **actor_active_distance** (_float_) Used for large maps only. Configures the distance from the hero vehicle to convert actors to dormant. Actors within this range will be active, and actors outside will become dormant. - **spectator_as_ego** (_bool_) Used for large maps only. Defines the influence of the spectator on tile loading in Large Maps. By default, the spectator will provoke loading of neighboring tiles in the absence of an ego actor. This might be inconvenient for applications that immediately spawn an ego actor. ### Methods - **\__init__**(**self**, **synchronous_mode**=False, **no_rendering_mode**=False, **fixed_delta_seconds**=0.0, **max_culling_distance**=0.0, **deterministic_ragdolls**=False, **tile_stream_distance**=3000, **actor_active_distance**=2000, **spectator_as_ego**=True) Creates an object containing desired settings that could later be applied through [carla.World](#carla.World) and its method __apply_settings()__. - **Parameters:** - `synchronous_mode` (_bool_) - Set this to true to enable client-server synchrony. - `no_rendering_mode` (_bool_) - Set this to true to completely disable rendering in the simulation. - `fixed_delta_seconds` (_float - seconds_) - Set a fixed time-step in between frames. 0.0 means variable time-step and it is the default mode. - `max_culling_distance` (_float - meters_) - Configure the max draw distance for each mesh of the level. - `deterministic_ragdolls` (_bool_) - Defines wether to use deterministic physics or ragdoll simulation for pedestrian deaths. - `tile_stream_distance` (_float - meters_) - Used for large maps only. Configures the maximum distance from the hero vehicle to stream tiled maps. - `actor_active_distance` (_float - meters_) - Used for large maps only. Configures the distance from the hero vehicle to convert actors to dormant. - `spectator_as_ego` (_bool_) - Used for large maps only. Defines the influence of the spectator on tile loading in Large Maps. ##### Dunder methods - **\__eq__**(**self**, **other**=[carla.WorldSettings](#carla.WorldSettings)) Returns True if both objects' variables are the same. - **Return:** _bool_ - **\__ne__**(**self**, **other**=[carla.WorldSettings](#carla.WorldSettings)) Returns True if both objects' variables are different. - **Return:** _bool_ - **\__str__**(**self**) Parses the established settings to a string and shows them in command line. - **Return:** _str_ --- ## carla.WorldSnapshot This snapshot comprises all the information for every actor on scene at a certain moment of time. It creates and gives acces to a data structure containing a series of [carla.ActorSnapshot](#carla.ActorSnapshot). The client recieves a new snapshot on every tick that cannot be stored. ### Instance Variables - **id** (_int_) A value unique for every snapshot to differentiate them. - **frame** (_int_) Simulation frame in which the snapshot was taken. - **timestamp** (_[carla.Timestamp](#carla.Timestamp) - seconds_) Precise moment in time when snapshot was taken. This class works in seconds as given by the operative system. ### Methods - **find**(**self**, **actor_id**) Given a certain actor ID, returns its corresponding snapshot or None if it is not found. - **Parameters:** - `actor_id` (_int_) - **Return:** _[carla.ActorSnapshot](#carla.ActorSnapshot)_ - **has_actor**(**self**, **actor_id**) Given a certain actor ID, checks if there is a snapshot corresponding it and so, if the actor was present at that moment. - **Parameters:** - `actor_id` (_int_) - **Return:** _bool_ ##### Dunder methods - **\__eq__**(**self**, **other**=[carla.WorldSnapshot](#carla.WorldSnapshot)) Returns __True__ if both **timestamp** are the same. - **Return:** _bool_ - **\__iter__**(**self**) Iterate over the [carla.ActorSnapshot](#carla.ActorSnapshot) stored in the snapshot. - **\__len__**(**self**) Returns the amount of [carla.ActorSnapshot](#carla.ActorSnapshot) present in this snapshot. - **Return:** _int_ - **\__ne__**(**self**, **other**=[carla.WorldSnapshot](#carla.WorldSnapshot)) Returns True if both **timestamp** are different. - **Return:** _bool_ --- ## command.ApplyAngularImpulse Command adaptation of __add_angular_impulse()__ in [carla.Actor](#carla.Actor). Applies an angular impulse to an actor. ### Instance Variables - **actor_id** (_int_) Actor affected by the command. - **impulse** (_[carla.Vector3D](#carla.Vector3D) - degrees*s_) Angular impulse applied to the actor. ### Methods - **\__init__**(**self**, **actor**, **impulse**) - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor) or int_) - Actor or its ID to whom the command will be applied to. - `impulse` (_[carla.Vector3D](#carla.Vector3D) - degrees*s_) --- ## command.ApplyForce Command adaptation of __add_force()__ in [carla.Actor](#carla.Actor). Applies a force to an actor. ### Instance Variables - **actor_id** (_int_) Actor affected by the command. - **force** (_[carla.Vector3D](#carla.Vector3D) - N_) Force applied to the actor over time. ### Methods - **\__init__**(**self**, **actor**, **force**) - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor) or int_) - Actor or its ID to whom the command will be applied to. - `force` (_[carla.Vector3D](#carla.Vector3D) - N_) --- ## command.ApplyImpulse Command adaptation of __add_impulse()__ in [carla.Actor](#carla.Actor). Applies an impulse to an actor. ### Instance Variables - **actor_id** (_int_) Actor affected by the command. - **impulse** (_[carla.Vector3D](#carla.Vector3D) - N*s_) Impulse applied to the actor. ### Methods - **\__init__**(**self**, **actor**, **impulse**) - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor) or int_) - Actor or its ID to whom the command will be applied to. - `impulse` (_[carla.Vector3D](#carla.Vector3D) - N*s_) --- ## command.ApplyTargetAngularVelocity Command adaptation of __set_target_angular_velocity()__ in [carla.Actor](#carla.Actor). Sets the actor's angular velocity vector. ### Instance Variables - **actor_id** (_int_) Actor affected by the command. - **angular_velocity** (_[carla.Vector3D](#carla.Vector3D) - deg/s_) The 3D angular velocity that will be applied to the actor. ### Methods - **\__init__**(**self**, **actor**, **angular_velocity**) - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor) or int_) - Actor or its ID to whom the command will be applied to. - `angular_velocity` (_[carla.Vector3D](#carla.Vector3D) - deg/s_) - Angular velocity vector applied to the actor. --- ## command.ApplyTargetVelocity Command adaptation of __set_target_velocity()__ in [carla.Actor](#carla.Actor). ### Instance Variables - **actor_id** (_int_) Actor affected by the command. - **velocity** (_[carla.Vector3D](#carla.Vector3D) - m/s_) The 3D velocity applied to the actor. ### Methods - **\__init__**(**self**, **actor**, **velocity**) - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor) or int_) - Actor or its ID to whom the command will be applied to. - `velocity` (_[carla.Vector3D](#carla.Vector3D) - m/s_) - Velocity vector applied to the actor. --- ## command.ApplyTorque Command adaptation of __add_torque()__ in [carla.Actor](#carla.Actor). Applies a torque to an actor. ### Instance Variables - **actor_id** (_int_) Actor affected by the command. - **torque** (_[carla.Vector3D](#carla.Vector3D) - degrees_) Torque applied to the actor over time. ### Methods - **\__init__**(**self**, **actor**, **torque**) - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor) or int_) - Actor or its ID to whom the command will be applied to. - `torque` (_[carla.Vector3D](#carla.Vector3D) - degrees_) --- ## command.ApplyTransform Command adaptation of __set_transform()__ in [carla.Actor](#carla.Actor). Sets a new transform to an actor. ### Instance Variables - **actor_id** (_int_) Actor affected by the command. - **transform** (_[carla.Transform](#carla.Transform)_) Transformation to be applied. ### Methods - **\__init__**(**self**, **actor**, **transform**) - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor) or int_) - Actor or its ID to whom the command will be applied to. - `transform` (_[carla.Transform](#carla.Transform)_) --- ## command.ApplyVehicleAckermannControl Command adaptation of __apply_ackermann_control()__ in [carla.Vehicle](#carla.Vehicle). Applies a certain akermann control to a vehicle. ### Instance Variables - **actor_id** (_int_) Vehicle actor affected by the command. - **control** (_[carla.AckermannVehicleControl](#carla.AckermannVehicleControl)_) Vehicle ackermann control to be applied. ### Methods - **\__init__**(**self**, **actor**, **control**) - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor) or int_) - Actor or its ID to whom the command will be applied to. - `control` (_[carla.AckermannVehicleControl](#carla.AckermannVehicleControl)_) --- ## command.ApplyVehicleControl Command adaptation of __apply_control()__ in [carla.Vehicle](#carla.Vehicle). Applies a certain control to a vehicle. ### Instance Variables - **actor_id** (_int_) Vehicle actor affected by the command. - **control** (_[carla.VehicleControl](#carla.VehicleControl)_) Vehicle control to be applied. ### Methods - **\__init__**(**self**, **actor**, **control**) - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor) or int_) - Actor or its ID to whom the command will be applied to. - `control` (_[carla.VehicleControl](#carla.VehicleControl)_) --- ## command.ApplyVehiclePhysicsControl Command adaptation of __apply_physics_control()__ in [carla.Vehicle](#carla.Vehicle). Applies a new physics control to a vehicle, modifying its physical parameters. ### Instance Variables - **actor_id** (_int_) Vehicle actor affected by the command. - **physics_control** (_[carla.VehiclePhysicsControl](#carla.VehiclePhysicsControl)_) Physics control to be applied. ### Methods - **\__init__**(**self**, **actor**, **physics_control**) - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor) or int_) - Actor or its ID to whom the command will be applied to. - `physics_control` (_[carla.VehiclePhysicsControl](#carla.VehiclePhysicsControl)_) --- ## command.ApplyWalkerControl Command adaptation of __apply_control()__ in [carla.Walker](#carla.Walker). Applies a control to a walker. ### Instance Variables - **actor_id** (_int_) Walker actor affected by the command. - **control** (_[carla.WalkerControl](#carla.WalkerControl)_) Walker control to be applied. ### Methods - **\__init__**(**self**, **actor**, **control**) - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor) or int_) - Actor or its ID to whom the command will be applied to. - `control` (_[carla.WalkerControl](#carla.WalkerControl)_) --- ## command.ApplyWalkerState Apply a state to the walker actor. Specially useful to initialize an actor them with a specific location, orientation and speed. ### Instance Variables - **actor_id** (_int_) Walker actor affected by the command. - **transform** (_[carla.Transform](#carla.Transform)_) Transform to be applied. - **speed** (_float - m/s_) Speed to be applied. ### Methods - **\__init__**(**self**, **actor**, **transform**, **speed**) - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor) or int_) - Actor or its ID to whom the command will be applied to. - `transform` (_[carla.Transform](#carla.Transform)_) - `speed` (_float - m/s_) --- ## command.DestroyActor Command adaptation of __destroy()__ in [carla.Actor](#carla.Actor) that tells the simulator to destroy this actor. It has no effect if the actor was already destroyed. When executed with __apply_batch_sync()__ in [carla.Client](#carla.Client) there will be a command.Response that will return a boolean stating whether the actor was successfully destroyed. ### Instance Variables - **actor_id** (_int_) Actor affected by the command. ### Methods - **\__init__**(**self**, **actor**) - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor) or int_) - Actor or its ID to whom the command will be applied to. --- ## command.Response States the result of executing a command as either the ID of the actor to whom the command was applied to (when succeeded) or an error string (when failed). actor ID, depending on whether or not the command succeeded. The method __apply_batch_sync()__ in [carla.Client](#carla.Client) returns a list of these to summarize the execution of a batch. ### Instance Variables - **actor_id** (_int_) Actor to whom the command was applied to. States that the command was successful. - **error** (_str_) A string stating the command has failed. ### Methods - **has_error**(**self**) Returns True if the command execution fails, and False if it was successful. - **Return:** _bool_ --- ## command.SetAutopilot Command adaptation of __set_autopilot()__ in [carla.Vehicle](#carla.Vehicle). Turns on/off the vehicle's autopilot mode. ### Instance Variables - **actor_id** (_int_) Actor that is affected by the command. - **enabled** (_bool_) If autopilot should be activated or not. - **port** (_uint16_) Port of the Traffic Manager where the vehicle is to be registered or unlisted. ### Methods - **\__init__**(**self**, **actor**, **enabled**, **port**=8000) - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor) or int_) - Actor or its ID to whom the command will be applied to. - `enabled` (_bool_) - `port` (_uint16_) - The Traffic Manager port where the vehicle is to be registered or unlisted. If __None__ is passed, it will consider a TM at default port `8000`. --- ## command.SetEnableGravity Command adaptation of __set_enable_gravity()__ in [carla.Actor](#carla.Actor). Enables or disables gravity on an actor. ### Instance Variables - **actor_id** (_[carla.Actor](#carla.Actor) or int_) Actor that is affected by the command. - **enabled** (_bool_) ### Methods - **\__init__**(**self**, **actor**, **enabled**) - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor) or int_) - Actor or Actor ID to which the command will be applied to. - `enabled` (_bool_) --- ## command.SetSimulatePhysics Command adaptation of __set_simulate_physics()__ in [carla.Actor](#carla.Actor). Determines whether an actor will be affected by physics or not. ### Instance Variables - **actor_id** (_int_) Actor affected by the command. - **enabled** (_bool_) If physics should be activated or not. ### Methods - **\__init__**(**self**, **actor**, **enabled**) - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor) or int_) - Actor or its ID to whom the command will be applied to. - `enabled` (_bool_) --- ## command.SetVehicleLightState Command adaptation of __set_light_state()__ in [carla.Vehicle](#carla.Vehicle). Sets the light state of a vehicle. ### Instance Variables - **actor_id** (_int_) Actor that is affected by the command. - **light_state** (_[carla.VehicleLightState](#carla.VehicleLightState)_) Defines the light state of a vehicle. ### Methods - **\__init__**(**self**, **actor**, **light_state**) - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor) or int_) - Actor or its ID to whom the command will be applied to. - `light_state` (_[carla.VehicleLightState](#carla.VehicleLightState)_) - Recaps the state of the lights of a vehicle, these can be used as a flags. --- ## command.ShowDebugTelemetry Command adaptation of __show_debug_telemetry()__ in [carla.Actor](#carla.Actor). Displays vehicle control telemetry data. ### Instance Variables - **actor_id** (_[carla.Actor](#carla.Actor) or int_) Actor that is affected by the command. - **enabled** (_bool_) ### Methods - **\__init__**(**self**, **actor**, **enabled**) - **Parameters:** - `actor` (_[carla.Actor](#carla.Actor) or int_) - Actor or Actor ID to which the command will be applied to. - `enabled` (_bool_) --- ## command.SpawnActor Command adaptation of __spawn_actor()__ in [carla.World](#carla.World). Spawns an actor into the world based on the blueprint provided and the transform. If a parent is provided, the actor is attached to it. ### Instance Variables - **transform** (_[carla.Transform](#carla.Transform)_) Transform to be applied. - **parent_id** (_int_) Identificator of the parent actor. ### Methods - **\__init__**(**self**) - **\__init__**(**self**, **blueprint**, **transform**) - **Parameters:** - `blueprint` (_[carla.ActorBlueprint](#carla.ActorBlueprint)_) - `transform` (_[carla.Transform](#carla.Transform)_) - **\__init__**(**self**, **blueprint**, **transform**, **parent**) - **Parameters:** - `blueprint` (_[carla.ActorBlueprint](#carla.ActorBlueprint)_) - `transform` (_[carla.Transform](#carla.Transform)_) - `parent` (_[carla.Actor](#carla.Actor) or int_) - **then**(**self**, **command**) Links another command to be executed right after. It allows to ease very common flows such as spawning a set of vehicles by command and then using this method to set them to autopilot automatically. - **Parameters:** - `command` (_any carla Command_) - a Carla command. --- [comment]: <> (=========================) [comment]: <> (PYTHON API SCRIPT SNIPETS) [comment]: <> (=========================)