Docs/python_api.md
#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 <i>latest</i> version is the dev branch and may show features not available in any packaged versions of CARLA.<hr>
Manages the settings of the Ackermann PID controller.
speed_kp (float)speed_ki (float)speed_kd (float)accel_kp (float)accel_ki (float)accel_kd (float)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 and they need for a carla.ActorBlueprint to be created. These blueprints belong into a library provided by CARLA, find more about them here.
vehicle.ford.mustang.Pole and TrafficLight. These tags are used by the semantic segmentation sensor. Find more about this and other sensors here.angular_impulse (carla.Vector3D<small> - degrees*s</small>) - Angular impulse vector in global coordinates.force (carla.Vector3D<small> - N</small>) - Force vector in global coordinates.impulse (carla.Vector3D<small> - N*s</small>) - Impulse vector in global coordinates.torque (carla.Vector3D<small> - degrees</small>) - Torque vector in global coordinates.velocity being set, as with <font color="#7fb800">set_target_velocity()</font>.
velocity (carla.Vector3D<small> - m/s</small>) - Velocity vector in local space.enabled (bool)location (carla.Location<small> - meters</small>)enabled (bool)angular_velocity (carla.Vector3D<small> - deg/s</small>)velocity (carla.Vector3D)transform (carla.Transform)CARLA provides a library of blueprints for actors that can be accessed as 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.
other are the same.
other are different.
CARLA provides a library of blueprints for actors in carla.BlueprintLibrary with different attributes each. This class defines the types those at 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.
CARLA provides a blueprint library for actors that can be consulted through 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.
walker.pedestrian.0001.['0001', 'pedestrian', 'walker'].id.
id (str) - e.g. gender would return True for pedestrians' blueprints.tag listed.
tag (str) - e.g. 'walker'.wildcard_pattern. Matching follows fnmatch standard.
wildcard_pattern (str)id as identifier if existing.
id (str)id attribute is modifiable, changes its value to value.
id (str) - The identifier for the attribute that is intended to be changed.value (str) - The new value for said attribute.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.
wildcard_pattern against their variable <font color="#f8805a">type_id</font> (which identifies the blueprint used to spawn them). Matching follows fnmatch standard.
wildcard_pattern (str)actor_id (int)pos position in the list.
A class that comprises all the information for an actor at a certain moment in time. These objects are contained in a carla.WorldSnapshot and sent to the client once every tick.
Class that defines the state of an actor.
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 shows some sensors being attached to a car when spawned. Note that the attachment type is declared as an enum within the class.
A class that contains the blueprints provided for actor spawning. Its main application is to return 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.
Here is a reference containing every available blueprint and its specifics.
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 standard.
wildcard_pattern (str)value against every blueprint contained in this library and returns the result as a new one. Matching follows fnmatch standard.
name (str)value (str)id (str)pos position inside the data structure containing them.
Bounding boxes contain the geometry of an actor or an element in the scene. They can be used by carla.DebugHelper or a carla.Client to draw their shapes for debugging. Check out the snipet in carla.DebugHelper.draw_box where a snapshot of the world is used to draw bounding boxes for traffic lights.
extent.x * 2 would return the size of the box in the X-axis.location (carla.Location) - Center of the box, relative to its parent.extent (carla.Vector3D<small> - meters</small>) - Vector containing half the size of the box for every axis.world_point (carla.Location<small> - meters</small>) - The point in world space to be checked.transform (carla.Transform) - Contains location and rotation needed to convert this object's local space to world space.transform (carla.Transform) - Contains location and rotation needed to convert this object's local space to world space.other.
other.
Enum declaration that contains the different tags available to filter the bounding boxes returned by carla.World.get_level_bbs(). These values correspond to the semantic tag that the elements in the scene have.
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 is some information about how to use this recorder.
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.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.commands (list) - A list of commands to execute in batch. The commands available are listed right above, in the method <font color="#7fb800">apply_batch()</font>.due_tick_cue (bool) - A boolean parameter to specify whether or not to perform a carla.World.tick after applying the batch in synchronous mode. It is False by default.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.
opendrive (str) - Content of an OpenDRIVE file as string, not the path to the .xodr.parameters (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.map_name map. All actors in the current world will be destroyed.
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) - Layers of the map that will be loaded. By default all layers are loaded. This parameter works like a flag mask.map_layers are only available for "Opt" maps
_</font>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_name map. All actors present in the current world will be destroyed, but traffic manager instances will stay alive.
name (str) - Name of the file containing the information of the simulation.start (float<small> - seconds</small>) - 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<small> - seconds</small>) - 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.name (str) - Name of the file you are requesting.min_distance and min_time.
filename (str) - Name of the recorded file to load.min_time (float<small> - seconds</small>) - Minimum time the actor has to move a minimum distance before being considered blocked. Default is 60 seconds.min_distance (float<small> - centimeters</small>) - Minimum distance the actor has to move to not be considered blocked. Default is 100 centimeters.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.
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.show_all parameter. Here is some more information about how to read the recorder file.
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.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).filename, the recording will be there. If not, look inside CarlaUnreal/Saved/.keep_actors (bool) - True if you want autoremove all actors from the replayer, or False to keep them.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.client_connection (int) - Port that will be used by the traffic manager. Default is 8000.path (str) - Specifies the base folder where the local cache for required files will be placed.ignore_hero (bool) - Enables or disables playback of the hero vehicle during a playback of a recorded simulation.ignore_spectator (bool) - Determines whether the recorded spectator movements will be replicated by the replayer.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).seconds (float<small> - seconds</small>) - New timeout value. Default is 5 seconds.<small style="display:block;margin-top:-20px;">Inherited from carla.SensorData</small></br> Class that defines a collision data for <b>sensor.other.collision</b>. 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.
Class that defines a 32-bit RGBA color.
r (int)g (int)b (int)a (int)Class that defines conversion patterns that can be applied to a carla.Image in order to show information provided by carla.Sensor. Depth conversions cause a loss of accuracy, as sensors detect depth as <b>float</b> that is then converted to a grayscale value between 0 and 255. Take a look at the snipet in carla.Sensor.listen to see an example of how to create and save image data for <b>sensor.camera.semantic_segmentation</b>.
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.
Class that defines a stream of events in 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.
Helper class part of 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.
begin to end pointing in that direction.
begin (carla.Location<small> - meters</small>) - Point in the coordinate system where the arrow starts.end (carla.Location<small> - meters</small>) - Point in the coordinate system where the arrow ends and points towards to.thickness (float<small> - meters</small>) - Density of the line.arrow_size (float<small> - meters</small>) - Size of the tip of the arrow.color (carla.Color) - RGB code to color the object. Red by default.life_time (float<small> - seconds</small>) - Shape's lifespan. By default it only lasts one frame. Set this to <code>0</code> for permanent shapes.box (carla.BoundingBox) - Object containing a location and the length of a box for every axis.rotation (carla.Rotation<small> - degrees (pitch,yaw,roll)</small>) - Orientation of the box according to Unreal Engine's axis system.thickness (float<small> - meters</small>) - Density of the lines that define the box.color (carla.Color) - RGB code to color the object. Red by default.life_time (float<small> - seconds</small>) - Shape's lifespan. By default it only lasts one frame. Set this to <code>0</code> for permanent shapes.begin and end.
begin (carla.Location<small> - meters</small>) - Point in the coordinate system where the line starts.end (carla.Location<small> - meters</small>) - Spot in the coordinate system where the line ends.thickness (float<small> - meters</small>) - Density of the line.color (carla.Color) - RGB code to color the object. Red by default.life_time (float<small> - seconds</small>) - Shape's lifespan. By default it only lasts one frame. Set this to <code>0</code> for permanent shapes.location.
location (carla.Location<small> - meters</small>) - Spot in the coordinate system to center the object.size (float<small> - meters</small>) - Density of the point.color (carla.Color) - RGB code to color the object. Red by default.life_time (float<small> - seconds</small>) - Shape's lifespan. By default it only lasts one frame. Set this to <code>0</code> for permanent shapes.location (carla.Location<small> - meters</small>) - 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) - RGB code to color the string. Red by default.life_time (float<small> - seconds</small>) - Shape's lifespan. By default it only lasts one frame. Set this to <code>0</code> for permanent shapes.Class that represents a geometry in the level, this geometry could be part of an actor formed with other EnvironmentObjects (ie: buildings).
Class that defines a float RGBA color.
r (float)g (float)b (float)a (float)Defines the identifiers of each GBuffer texture (See the method [carla.Sensor.listen_to_gbuffer](#carla.Sensor.listen_to_gbuffer)).
<a name="carla.GBufferTextureID.SceneColor"></a><font color="#f8805a">SceneColor</font>
The texture "SceneColor" contains the final color of the image.
<a name="carla.GBufferTextureID.SceneDepth"></a><font color="#f8805a">SceneDepth</font>
The texture "SceneDepth" contains the depth buffer - linear in world units.
<a name="carla.GBufferTextureID.SceneStencil"></a><font color="#f8805a">SceneStencil</font>
The texture "SceneStencil" contains the stencil buffer.
<a name="carla.GBufferTextureID.GBufferA"></a><font color="#f8805a">GBufferA</font>
The texture "GBufferA" contains the world-space normal vectors in the RGB channels. The alpha channel contains "per-object data".
<a name="carla.GBufferTextureID.GBufferB"></a><font color="#f8805a">GBufferB</font>
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.
<a name="carla.GBufferTextureID.GBufferC"></a><font color="#f8805a">GBufferC</font>
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.
<a name="carla.GBufferTextureID.GBufferD"></a><font color="#f8805a">GBufferD</font>
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.
<a name="carla.GBufferTextureID.GBufferE"></a><font color="#f8805a">GBufferE</font>
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.
<a name="carla.GBufferTextureID.GBufferF"></a><font color="#f8805a">GBufferF</font>
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.
<a name="carla.GBufferTextureID.Velocity"></a><font color="#f8805a">Velocity</font>
The texture "Velocity" contains the screen-space velocity of the scene objects.
<a name="carla.GBufferTextureID.SSAO"></a><font color="#f8805a">SSAO</font>
The texture "SSAO" contains the screen-space ambient occlusion texture.
<a name="carla.GBufferTextureID.CustomDepth"></a><font color="#f8805a">CustomDepth</font>
The texture "CustomDepth" contains the Unreal Engine custom depth data.
<a name="carla.GBufferTextureID.CustomStencil"></a><font color="#f8805a">CustomStencil</font>
The texture "CustomStencil" contains the Unreal Engine custom stencil data.
Class that contains geographical coordinates simulated data. The carla.Map can convert simulation locations by using the <b><georeference></b> tag in the OpenDRIVE file.
latitude (float<small> - degrees</small>)longitude (float<small> - degrees</small>)altitude (float<small> - meters</small>)<small style="display:block;margin-top:-20px;">Inherited from carla.SensorData</small></br> Class that defines the Gnss data registered by a <b>sensor.other.gnss</b>. It essentially reports its position with the position of the sensor and an OpenDRIVE geo-reference.
<small style="display:block;margin-top:-20px;">Inherited from carla.SensorData</small></br> Class that defines the data registered by a <b>sensor.other.imu</b>, regarding the sensor's transformation according to the current carla.World. It essentially acts as accelerometer, gyroscope and compass.
<small style="display:block;margin-top:-20px;">Inherited from carla.SensorData</small></br> 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.
color_converter pattern.
color_converter (carla.ColorConverter)color_converter. The default conversion pattern is <b>Raw</b> that will make no changes to the image.
path (str) - Path that will contain the image.color_converter (carla.ColorConverter) - Default <b>Raw</b> will make no changes.Class that embodies the intersections on the road described in the OpenDRIVE file according to OpenDRIVE 1.4 standards.
lane_type (carla.LaneType) - Type of lanes to get the waypoints.Class that represent a position in space with a semantic label.
Class that defines any type of traffic landmark or sign affecting a road. These class mediates between the OpenDRIVE 1.4 standard 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 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.
get_landmarks or get_landmarks_of_type).road_id.road_id.value.road_id at s in OpenDRIVE.s of the landmark. It is the first waypoint for which the landmark will be effective.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.
Helper class containing a set of commonly used landmark types as defined by the default country code in the OpenDRIVE standard (Germany 2017). 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.
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 according to the OpenDRIVE file. The snipet in carla.Map.get_waypoint shows how a waypoint can be used to learn which turns are permitted.
<small style="display:block;margin-top:-20px;">Inherited from carla.SensorData</small></br> Class that defines lanes invasion for <b>sensor.other.lane_invasion</b>. 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.
Class that gathers all the information regarding a lane marking according to OpenDRIVE 1.4 standard standard.
Class that defines the lane marking colors according to OpenDRIVE 1.4.
Class that defines the lane marking types accepted by OpenDRIVE 1.4. The snipet in 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.
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 makes use of a waypoint to get the current and adjacent lane types.
Data contained inside a carla.LidarMeasurement. Each of these represents one of the points in the cloud with its location and its associated intensity.
<small style="display:block;margin-top:-20px;">Inherited from carla.SensorData</small></br> Class that defines the LIDAR data retrieved by a <b>sensor.lidar.ray_cast</b>. This essentially simulates a rotating LIDAR using ray-casting. Learn more about this here.
path (str)channel (int)<small style="display:block;margin-top:-20px;">Inherited from carla.Vector3D</small></br> Represents a spot in the world.
x (float)y (float)z (float)location (carla.Location) - The other point to compute the distance with.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 to translate geometrical information from the .xodr to natural world points. CARLA is currently working with OpenDRIVE 1.4 standard.
name (str) - Name of the current map.xodr_content (str) - .xodr content in string format.path (str) - Path to the intended location of the stored binary map file.distance (float<small> - meters</small>) - Approximate distance between waypoints.path - Path where the file will be saved.location, a point in the simulation, to a carla.GeoLocation, which represents world coordinates. The geographical location of the map is defined inside OpenDRIVE within the tag <b><georeference></b>.
location (carla.Location)opendrive_id (string) - The OpenDRIVE ID of the landmarks.type (string) - The type of the landmarks.landmark (carla.Landmark) - A landmark that belongs to the group.LaneType.Driving & LaneType.Shoulder.
The method will return <b>None</b> 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.
location (carla.Location<small> - meters</small>) - Location used as reference for the 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. <b>None</b> means said location does not belong to a road.lane_type (carla.LaneType) - Limits the search for nearest lane to one or various lane types that can be flagged.road_id (int) - ID of the road to get the waypoint.lane_id (int) - ID of the lane to get the waypoint.s (float<small> - meters</small>) - Specify the length from the road start.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..
Class that represents material parameters. Not all objects in the scene contain all parameters.
<small style="display:block;margin-top:-20px;">Inherited from carla.SensorData</small></br> Class that defines the obstacle data for <b>sensor.other.obstacle</b>. Learn more about this here.
actor and other.This class defines the parameters used when generating a world using an OpenDRIVE file.
2.0.50.0.1.0.0.6.True.True.True.<small style="display:block;margin-top:-20px;">Inherited from carla.SensorData</small></br> 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.
Class that defines a 2 dimensional vector representing an optical flow pixel.
x (float)y (float)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.
osm_file (str) - The content of the input OpenStreetMap file parsed as string.settings (carla.OSM2ODRSettings) - Parameterization for the conversion.Helper class that contains the parameterization that will be used by carla.Osm2Odr to convert an OpenStreetMap map to OpenDRIVE format. Find out more about this feature in the docs.
use_offsets or center_map are enabled as these options override some of the definitions in the string.set_traffic_light_excluded_way_types(way_types) will not generate traffic lights.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.
way_types (list(str)) - The list of road types.generate_traffic_lights is enabled. By default the road types excluded are motorway_link, primary_link, secondary_link, tertiary_link.
way_types (list(str)) - The list of road types.Data contained inside a carla.RadarMeasurement. Each of these represents one of the points in the cloud that a <b>sensor.other.radar</b> registers and contains the distance, angle and velocity in relation to the radar.
<small style="display:block;margin-top:-20px;">Inherited from carla.SensorData</small></br> Class that defines and gathers the measures registered by a <b>sensor.other.radar</b>, 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 array. Learn more about this here.
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).
Unreal Engine's coordinates system.
pitch (float<small> - degrees</small>) - Y-axis rotation angle.yaw (float<small> - degrees</small>) - Z-axis rotation angle.roll (float<small> - degrees</small>) - X-axis rotation angle.Data contained inside a 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.
<small style="display:block;margin-top:-20px;">Inherited from carla.SensorData</small></br> Class that defines the semantic LIDAR data retrieved by a <b>sensor.lidar.ray_cast_semantic</b>. This essentially simulates a rotating LIDAR using ray-casting. Learn more about this here.
path (str)channel (int)<small style="display:block;margin-top:-20px;">Inherited from carla.Actor</small></br> 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 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 (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. All the information on their preferences and settlement can be found here, but the list of those available in CARLA so far goes as follow.
<b>Receive data on every tick.</b>
<b>Only receive data when triggered.</b>
gbuffer_id (carla.GBufferTextureID) - The ID of the target Unreal Engine GBuffer texture.callback (function) - The called function with one argument containing the sensor data.gbuffer_id (carla.GBufferTextureID) - The ID of the target Unreal Engine GBuffer texture.callback (function) - The called function with one argument containing the received GBuffer texture.gbuffer_id (carla.GBufferTextureID) - The ID of the Unreal Engine GBuffer texture.Base class for all the objects containing data generated by a 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.
Collision detector: carla.CollisionEvent.
GNSS sensor: carla.GnssMeasurement.
IMU sensor: carla.IMUMeasurement.
Lane invasion detector: carla.LaneInvasionEvent.
LIDAR sensor: carla.LidarMeasurement.
Obstacle detector: carla.ObstacleDetectionEvent.
Radar sensor: carla.RadarMeasurement.
Semantic LIDAR sensor: carla.SemanticLidarMeasurement.
Class representing a texture object to be uploaded to the server. Pixel format is RGBA, uint8 per channel.
width, height) size.
width (int)height (int)x (int)y (int)value.
x (int)y (int)value (carla.Color)width (int)height (int)Class representing a texture object to be uploaded to the server. Pixel format is RGBA, float per channel.
width, height) size.
width (int)height (int)x (int)y (int)value.
x (int)y (int)value (carla.FloatColor)width (int)height (int)Class that contains time information for simulated data. This information is automatically retrieved as part of the carla.WorldSnapshot the client gets on every frame, but might also be used in many other situations such as a carla.Sensor retrieveing data.
frame (int)elapsed_seconds (float<small> - seconds</small>)delta_seconds (float<small> - seconds</small>)platform_timestamp (float<small> - seconds</small>)<small style="display:block;margin-top:-20px;">Inherited from carla.TrafficSign</small></br> 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.
freeze (bool)green_time (float<small> - seconds</small>) - Sets a given time for the green light to be active.red_time (float<small> - seconds</small>)state (carla.TrafficLightState)yellow_time (float<small> - seconds</small>)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 changes the state of a traffic light on the fly.
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 is applied to every vehicle registered in a traffic manager. In order to learn more, visit the documentation regarding this module.
actor (carla.Actor) - The vehicle whose settings are changed.enable (bool) - True is default and enables lane changes. False will disable them.reference_actor (carla.Actor) - Vehicle that is going to ignore collisions.other_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.actor (carla.Actor) - Vehicle whose minimum distance is being changed.distance (float<small> - meters</small>) - Meters between both vehicles.direction. This method applies the lane change no matter what, disregarding possible collisions.
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.offset (float) - Lane offset displacement from the center line.perc to a negative value.
Default is 30. Exceeding a speed limit can be done using negative percentages.
percentage (float) - Percentage difference between intended speed and the current limit.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.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.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.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.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.actor (carla.Actor) - The actor that you wish to query.percentage (float) - The probability of lane change in percentage units (between 0 and 100).actor (carla.Actor) - The actor that you wish to query.percentage (float) - The probability of lane change in percentage units (between 0 and 100).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.actor (carla.Actor) - Vehicle whose lane offset behaviour is being changed.offset (float) - Lane offset displacement from the center line.perc to a negative value.
Default is 30. Exceeding a speed limit can be done using negative percentages.
actor (carla.Actor) - Vehicle whose speed behaviour is being changed.percentage (float) - Percentage difference between intended speed and the current limit.actor (carla.Actor) - The actor that you wish to query.actor (carla.Actor) - The actor that you wish to query.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.upper_bound cannot be higher than the actor_active_distance. The lower_bound cannot be less than 25.
_</font>actor (carla.Actor) - Vehicle whose speed is being changed.speed (float) - Desired speed at which the vehicle will move.distance (float<small> - meters</small>) - Meters between vehicles.enabled (bool) - If True, enables the hybrid physics.r (float<small> - meters</small>) - New radius where physics are enabled.mode_switch (bool) - If True, the OSM mode is enabled.actor (carla.Actor) - The actor that must follow the given path.path (list) - The list of carla.Locations for the actor to follow.value (int) - Seed value for the random number generation of the Traffic Manager.actor_active_distance of the hero vehicle again.
mode_switch (bool)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.mode_switch (bool) - If True, the TM synchronous mode is enabled.<small style="display:block;margin-top:-20px;">Inherited from carla.Actor</small></br> Traffic signs appearing in the simulation except for traffic lights. These have their own class inherited from this in carla.TrafficLight. Right now, speed signs, stops and yields are mainly the ones implemented, but many others are borne in mind.
Class that defines a transformation, a combination of location and rotation, without scaling.
location (carla.Location)rotation (carla.Rotation<small> - degrees (pitch, yaw, roll)</small>)in_point (carla.Location) - Location in the space to which the transformation will be applied.in_vector (carla.Vector3D) - Vector to which the transformation will be applied.other.
other.
Helper class to perform 2D operations.
x (float)y (float)Helper class to perform 3D operations.
x (float)y (float)z (float)vector (carla.Vector3D)vector (carla.Vector3D)vector (carla.Vector3D)vector (carla.Vector3D)vector (carla.Vector3D)vector (carla.Vector3D)vector (carla.Vector3D)vector (carla.Vector3D)<small style="display:block;margin-top:-20px;">Inherited from carla.Actor</small></br> 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 to facilitate differente requirements. Vehicles can be either manually controlled or set to an autopilot mode that will be conducted client-side by the <b>traffic manager</b>.
control (carla.VehicleAckermannControl)settings (carla.AckermannControllerSettings)control (carla.VehicleControl)physics_control (carla.VehiclePhysicsControl)door_idx if the vehicle has it. Use carla.VehicleDoor.All to close all available doors.
door_idx (carla.VehicleDoor) - door index.simfile_path (str) - Path to the .simfile file with the parameters of the simulation.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).ARGS="--chrono" flag. You will not be able to use Chrono physics without this flag set.
_</font>door_idx if the vehicle has it. Use carla.VehicleDoor.All to open all available doors.
door_idx (carla.VehicleDoor) - door index.enabled (bool).simfile. By default this option is disabled and CarSim uses unreal engine methods to process the geometry of the scene.
enabled (bool)wheel_location (carla.VehicleWheelLocation)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.light_state (carla.VehicleLightState)wheel_location (carla.VehicleWheelLocation)angle_in_deg (float)Manages the basic movement of a vehicle using Ackermann driving controls.
steer (float)steer_speed (float)speed (float)acceleration (float)jerk (float)Manages the basic movement of a vehicle using typical driving controls.
throttle (float) - Scalar value between [0.0,1.0].steer (float) - Scalar value between [-1.0,1.0].brake (float) - Scalar value between [0.0,1.0].hand_brake (bool)reverse (bool)manual_gear_shift (bool)gear (int)Possible index representing the possible doors that can be open. Notice that not all possible doors are able to open in some vehicles.
Enum containing the different failure states of a vehicle, from which the it cannot recover. These are returned by <font color="#7fb800">get_failure_state()</font> and only Rollover is currently implemented.
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.
Summarizes the parameters that will be used to simulate a carla.Vehicle as a physical object. The specific settings for the wheels though are stipulated using carla.WheelPhysicsControl.
torque_curve (list(carla.Vector2D))max_torque (float<small> - Nm</small>)max_rpm (float)idle_rpm (float)brake_effect (float)rev_up_moi (float)rev_down_rate (float)differential_type (int)front_rear_split (float)use_automatic_gears (bool)gear_change_time (float<small> - seconds</small>)final_ratio (float)forward_gear_ratios (list(float))reverse_gear_ratios (list(float))change_up_rpm (float)change_down_rpm (float)transmission_efficiency (float)mass (float<small> - kilograms</small>)drag_coefficient (float)center_of_mass (carla.Vector3D)chassis_width (float)chassis_height (float)downforce_coefficient (float)inertia_tensor_scale (float)sleep_threshold (float)sleep_slope_limit (float)steering_curve (list(carla.Vector2D))wheels (list(carla.WheelPhysicsControl))use_sweep_wheel_collision (bool)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 or carla.Vehicle.get_wheel_steer_angle.
<small style="display:block;margin-top:-20px;">Inherited from carla.Actor</small></br> This class inherits from the 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) or manually via script, using a series of carla.WalkerControl to move these and their skeletons.
control (carla.WalkerControl)blend_value (float<small> - value from 0 to 1 with the blend percentage</small>)bones (carla.WalkerBoneControlIn<small> - list of pairs (bone_name, transform) for the bones that we want to set</small>)<small style="display:block;margin-top:-20px;">Inherited from carla.Actor</small></br> 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 if you are yet to learn on how to spawn actors). They also need for a special blueprint (already defined in 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.
destination (carla.Location<small> - meters</small>)speed (float<small> - m/s</small>) - An easy walking speed is set by default.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 to learn more on how to create a walker and define its movement.
list(name,transform) (tuple)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).
This class defines specific directions that can be commanded to a carla.Walker to control it via script.
AI control can be settled for walkers, but the control used to do so is carla.WalkerAIController.
direction (carla.Vector3D)speed (float<small> - m/s</small>)jump (bool)other and returns <b>True</b> if these are all the same.other and returns <b>True</b> if any of these differ.Waypoints in CARLA are described as 3D directed points. They have a 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 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.
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.
distance (float<small> - meters</small>) - The approximate distance where to get the next waypoints.distance.
distance (float<small> - meters</small>) - The approximate distance between waypoints.distance but in the opposite direction of the lane. Similarly to <font color="#7fb800">next()</font>, 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.
distance (float<small> - meters</small>) - The approximate distance where to get the previous waypoints.distance.
distance (float<small> - meters</small>) - The approximate distance between waypoints.distance (float<small> - meters</small>) - The maximum distance to search for landmarks from the current waypoint.stop_at_junction (bool) - Enables or disables the landmark search through junctions.distance (float<small> - meters</small>) - 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.This class defines objects containing lighting and weather specifications that can later be applied in carla.World. So far, these conditions only intervene with sensor.camera.rgb. 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.
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<small> - degrees</small>) - 0 is an arbitrary North, 180 its corresponding South.sun_altitude_angle (float<small> - degrees</small>) - 90 is midday, -90 is midnight.fog_density (float) - Concentration or thickness of the fog, from 0 to 100.fog_distance (float<small> - meters</small>) - 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.Class that defines specific physical parameters for wheel objects that will be part of a carla.VehiclePhysicsControl to simulate vehicle it as a material object.
affected_by_engine value will be used to decide whether or not it is given power. (default 0.0).axel_type (float)offset (float)max_steer_angle (float<small> - degrees</small>)wheel_radius (float)wheel_width (float)wheel_mass (float)cornering_stiffness (float)friction_force_multiplier (float)side_slip_modifier (float)slip_threshold (float)skid_threshold (float)affected_by_steering (bool)affected_by_brake (bool)affected_by_handbrake (bool)affected_by_engine (bool)abs_enabled (bool)traction_control_enabled (bool)max_wheelspin_rotation (float)max_brake_torque (float<small> - N*m</small>)max_handbrake_torque (float<small> - N*m</small>)suspension_axis (carla.Vector3D)suspension_force_offset (float)suspension_max_raise (float)suspension_max_drop (float)suspension_damping_ratio (float)wheel_load_ratio (float)spring_rate (float)spring_preload (float)suspension_smoothing (float)rollbar_scaling (float)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 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.
texture object in the field corresponfing to material_parameter (normal, diffuse, etc) to the object in the scene corresponding to object_name.
object_name (str)material_parameter (carla.MaterialParameter)texture (TextureColor)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.
objects_name_list (list(str))material_parameter (carla.MaterialParameter)texture (TextureColor)texture object in the field corresponfing to material_parameter (normal, diffuse, etc) to the object in the scene corresponding to object_name.
object_name (str)material_parameter (carla.MaterialParameter)texture (TextureFloatColor)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.
objects_name_list (list(str))material_parameter (carla.MaterialParameter)texture (TextureFloatColor)world_settings (carla.WorldSettings)object_name. Empty textures here will not be applied.
object_name (str)diffuse_texture (TextureColor)emissive_texture (TextureFloatColor)normal_texture (TextureFloatColor)ao_roughness_metallic_emissive_texture (TextureFloatColor)objects_name_list. Empty textures here will not be applied.
objects_name_list (list(str))diffuse_texture (TextureColor)emissive_texture (TextureFloatColor)normal_texture (TextureFloatColor)ao_roughness_metallic_emissive_texture (TextureFloatColor)initial_location (carla.Location) - The initial position of the ray.final_location (carla.Location) - The final position of the ray.env_objects_ids (set(int)) - Set of EnvironmentObject ids to change.enable (bool) - State to be applied to all the EnvironmentObject of the set.frozen (bool)None.
location (carla.Location) - The point to be projected.search_distance (float) - The maximum distance to perform the projection.map_layers (carla.MapLayer) - Mask of level layers to be loaded.callback, and returns the ID of the callback. The function will be called everytime the server ticks. It requires a carla.WorldSnapshot as argument, which can be retrieved from <font color="#7fb800">wait_for_tick()</font>. Use <font color="#7fb800">remove_on_tick()</font> to stop the callbacks.
callback (carla.WorldSnapshot) - Function with a snapshot as compulsory parameter that will be called when the client receives a tick.None.
location (carla.Location) - The point to be projected.direction (carla.Vector3D) - The direction of projection.search_distance (float) - The maximum distance to perform the projection.callback_id started with <font color="#7fb800">on_tick()</font>.
callback_id (callback) - The callback to be removed. The ID is returned when creating the callback.blueprint (carla.ActorBlueprint) - The reference from which the actor will be created.transform (carla.Transform) - Contains the location and orientation the actor will be spawned with.attach_to (carla.Actor) - The parent object that the spawned actor will follow around.attachment (carla.AttachmentType) - Determines how fixed and rigorous should be the changes in position according to its parent object.seconds (float<small> - seconds</small>) - Maximum time the server should wait for a tick. It is set to <code>10.0</code> by default.blueprint (carla.ActorBlueprint) - The reference from which the actor will be created.transform (carla.Transform) - Contains the location and orientation the actor will be spawned with.attach_to (carla.Actor) - The parent object that the spawned actor will follow around.attachment (carla.AttachmentType) - Determines how fixed and rigorous should be the changes in position according to its parent object.map_layers (carla.MapLayer) - Mask of level layers to be unloaded.seconds (float<small> - seconds</small>) - Maximum time the server should wait for a tick. It is set to <code>10.0</code> by default.actor_id (int)actor_ids (list) - The IDs of the actors being searched. By default it is set to <b>None</b> and returns every actor on scene.object_type.
object_type (carla.CityObjectLabel) - Semantic tag of the EnvironmentObjects that are returned.actor_type.
actor_type (carla.CityObjectLabel) - Semantic tag of the elements contained in the bounding boxes that are returned.generate_traffic.py for an example.
landmark (carla.Landmark) - The landmark object describing a traffic light.traffic_light_id (str) - The OpenDRIVE id.waypoint (carla.Waypoint) - The input waypoint.distance (float) - Search distance.junction_id.
junction_id (int) - The id of the junction.landmark (carla.Landmark) - The landmark object describing a traffic sign.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.seed (int) - Sets the seed to use for any random number generated in relation to pedestrians.weather (carla.WeatherParameters) - New conditions to be applied.The simulation has some advanced configuration options that are contained in this class and can be managed using 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 out if you want to learn about it.
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<small> - seconds</small>) - Set a fixed time-step in between frames. <code>0.0</code> means variable time-step and it is the default mode.max_culling_distance (float<small> - meters</small>) - 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<small> - meters</small>) - Used for large maps only. Configures the maximum distance from the hero vehicle to stream tiled maps.actor_active_distance (float<small> - meters</small>) - 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.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. The client recieves a new snapshot on every tick that cannot be stored.
actor_id (int)actor_id (int)Command adaptation of <font color="#7fb800">add_angular_impulse()</font> in carla.Actor. Applies an angular impulse to an actor.
actor (carla.Actor or int) - Actor or its ID to whom the command will be applied to.impulse (carla.Vector3D<small> - degrees*s</small>)Command adaptation of <font color="#7fb800">add_force()</font> in carla.Actor. Applies a force to an actor.
actor (carla.Actor or int) - Actor or its ID to whom the command will be applied to.force (carla.Vector3D<small> - N</small>)Command adaptation of <font color="#7fb800">add_impulse()</font> in carla.Actor. Applies an impulse to an actor.
actor (carla.Actor or int) - Actor or its ID to whom the command will be applied to.impulse (carla.Vector3D<small> - N*s</small>)Command adaptation of <font color="#7fb800">set_target_angular_velocity()</font> in carla.Actor. Sets the actor's angular velocity vector.
actor (carla.Actor or int) - Actor or its ID to whom the command will be applied to.angular_velocity (carla.Vector3D<small> - deg/s</small>) - Angular velocity vector applied to the actor.Command adaptation of <font color="#7fb800">set_target_velocity()</font> in carla.Actor.
actor (carla.Actor or int) - Actor or its ID to whom the command will be applied to.velocity (carla.Vector3D<small> - m/s</small>) - Velocity vector applied to the actor.Command adaptation of <font color="#7fb800">add_torque()</font> in carla.Actor. Applies a torque to an actor.
actor (carla.Actor or int) - Actor or its ID to whom the command will be applied to.torque (carla.Vector3D<small> - degrees</small>)Command adaptation of <font color="#7fb800">set_transform()</font> in carla.Actor. Sets a new transform to an actor.
actor (carla.Actor or int) - Actor or its ID to whom the command will be applied to.transform (carla.Transform)Command adaptation of <font color="#7fb800">apply_ackermann_control()</font> in carla.Vehicle. Applies a certain akermann control to a vehicle.
actor (carla.Actor or int) - Actor or its ID to whom the command will be applied to.control (carla.AckermannVehicleControl)Command adaptation of <font color="#7fb800">apply_control()</font> in carla.Vehicle. Applies a certain control to a vehicle.
actor (carla.Actor or int) - Actor or its ID to whom the command will be applied to.control (carla.VehicleControl)Command adaptation of <font color="#7fb800">apply_physics_control()</font> in carla.Vehicle. Applies a new physics control to a vehicle, modifying its physical parameters.
actor (carla.Actor or int) - Actor or its ID to whom the command will be applied to.physics_control (carla.VehiclePhysicsControl)Command adaptation of <font color="#7fb800">apply_control()</font> in carla.Walker. Applies a control to a walker.
actor (carla.Actor or int) - Actor or its ID to whom the command will be applied to.control (carla.WalkerControl)Apply a state to the walker actor. Specially useful to initialize an actor them with a specific location, orientation and speed.
actor (carla.Actor or int) - Actor or its ID to whom the command will be applied to.transform (carla.Transform)speed (float<small> - m/s</small>)Command adaptation of <font color="#7fb800">destroy()</font> in carla.Actor that tells the simulator to destroy this actor. It has no effect if the actor was already destroyed. When executed with <font color="#7fb800">apply_batch_sync()</font> in carla.Client there will be a <b>command.Response</b> that will return a boolean stating whether the actor was successfully destroyed.
actor (carla.Actor or int) - Actor or its ID to whom the command will be applied to.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 <font color="#7fb800">apply_batch_sync()</font> in carla.Client returns a list of these to summarize the execution of a batch.
Command adaptation of <font color="#7fb800">set_autopilot()</font> in carla.Vehicle. Turns on/off the vehicle's autopilot mode.
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 adaptation of <font color="#7fb800">set_enable_gravity()</font> in carla.Actor. Enables or disables gravity on an actor.
actor (carla.Actor or int) - Actor or Actor ID to which the command will be applied to.enabled (bool)Command adaptation of <font color="#7fb800">set_simulate_physics()</font> in carla.Actor. Determines whether an actor will be affected by physics or not.
actor (carla.Actor or int) - Actor or its ID to whom the command will be applied to.enabled (bool)Command adaptation of <font color="#7fb800">set_light_state()</font> in carla.Vehicle. Sets the light state of a vehicle.
actor (carla.Actor or int) - Actor or its ID to whom the command will be applied to.light_state (carla.VehicleLightState) - Recaps the state of the lights of a vehicle, these can be used as a flags.Command adaptation of <font color="#7fb800">show_debug_telemetry()</font> in carla.Actor. Displays vehicle control telemetry data.
actor (carla.Actor or int) - Actor or Actor ID to which the command will be applied to.enabled (bool)Command adaptation of <font color="#7fb800">spawn_actor()</font> in 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.
blueprint (carla.ActorBlueprint)transform (carla.Transform)blueprint (carla.ActorBlueprint)transform (carla.Transform)parent (carla.Actor or int)command (any carla Command) - a Carla command.
# This recipe is a modification of lane_explorer.py example.
# It draws the path of an actor through the world, printing information at each waypoint.
# ...
current_w = map.get_waypoint(vehicle.get_location())
while True:
next_w = map.get_waypoint(vehicle.get_location(), lane_type=carla.LaneType.Driving | carla.LaneType.Shoulder | carla.LaneType.Sidewalk )
# Check if the vehicle is moving
if next_w.id != current_w.id:
vector = vehicle.get_velocity()
# Check if the vehicle is on a sidewalk
if current_w.lane_type == carla.LaneType.Sidewalk:
draw_waypoint_union(debug, current_w, next_w, cyan if current_w.is_junction else red, 60)
else:
draw_waypoint_union(debug, current_w, next_w, cyan if current_w.is_junction else green, 60)
debug.draw_string(current_w.transform.location, str('%15.0f km/h' % (3.6 * math.sqrt(vector.x**2 + vector.y**2 + vector.z**2))), False, orange, 60)
draw_transform(debug, current_w.transform, white, 60)
# Update the current waypoint and sleep for some time
current_w = next_w
time.sleep(args.tick_time)
# ...
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.DebugHelper.draw_string-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button>
</div> <div id ="carla.Vehicle.set_wheel_steer_direction-snipet" style="display: none;"> <p class="SnipetFont"> Snippet for carla.Vehicle.set_wheel_steer_direction </p> <div id="carla.Vehicle.set_wheel_steer_direction-code" class="SnipetContent">
# Sets the appearance of the vehicles front wheels to 40°. Vehicle physics will not be affected.
vehicle.set_wheel_steer_direction(carla.VehicleWheelLocation.FR_Wheel, 40.0)
vehicle.set_wheel_steer_direction(carla.VehicleWheelLocation.FL_Wheel, 40.0)
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.Vehicle.set_wheel_steer_direction-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button>
</div> <div id ="carla.Sensor.listen-snipet" style="display: none;"> <p class="SnipetFont"> Snippet for carla.Sensor.listen </p> <div id="carla.Sensor.listen-code" class="SnipetContent">
# This recipe applies a color conversion to the image taken by a camera sensor,
# so it is converted to a semantic segmentation image.
# ...
camera_bp = world.get_blueprint_library().filter('sensor.camera.semantic_segmentation')
# ...
cc = carla.ColorConverter.CityScapesPalette
camera.listen(lambda image: image.save_to_disk('output/%06d.png' % image.frame, cc))
# ...
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.Sensor.listen-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button>
</div> <div id ="carla.DebugHelper.draw_box-snipet" style="display: none;"> <p class="SnipetFont"> Snippet for carla.DebugHelper.draw_box </p> <div id="carla.DebugHelper.draw_box-code" class="SnipetContent">
# This recipe shows how to draw traffic light actor bounding boxes from a world snapshot.
# ....
debug = world.debug
world_snapshot = world.get_snapshot()
for actor_snapshot in world_snapshot:
actual_actor = world.get_actor(actor_snapshot.id)
if actual_actor.type_id == 'traffic.traffic_light':
debug.draw_box(carla.BoundingBox(actor_snapshot.get_transform().location,carla.Vector3D(0.5,0.5,2)),actor_snapshot.get_transform().rotation, 0.05, carla.Color(255,0,0,0),0)
# ...
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.DebugHelper.draw_box-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button>
</div> <div id ="carla.Client.__init__-snipet" style="display: none;"> <p class="SnipetFont"> Snippet for carla.Client.__init__ </p> <div id="carla.Client.__init__-code" class="SnipetContent">
# This recipe shows in every script provided in PythonAPI/Examples
# and it is used to parse the client creation arguments when running the script.
argparser = argparse.ArgumentParser(
description=__doc__)
argparser.add_argument(
'--host',
metavar='H',
default='127.0.0.1',
help='IP of the host server (default: 127.0.0.1)')
argparser.add_argument(
'-p', '--port',
metavar='P',
default=2000,
type=int,
help='TCP port to listen to (default: 2000)')
argparser.add_argument(
'-s', '--speed',
metavar='FACTOR',
default=1.0,
type=float,
help='rate at which the weather changes (default: 1.0)')
args = argparser.parse_args()
speed_factor = args.speed
update_freq = 0.1 / speed_factor
client = carla.Client(args.host, args.port)
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.Client.__init__-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button>
</div> <div id ="carla.World.get_spectator-snipet" style="display: none;"> <p class="SnipetFont"> Snippet for carla.World.get_spectator </p> <div id="carla.World.get_spectator-code" class="SnipetContent">
# This recipe spawns an actor and the spectator camera at the actor's location.
# ...
world = client.get_world()
spectator = world.get_spectator()
vehicle_bp = random.choice(world.get_blueprint_library().filter('vehicle.bmw.*'))
transform = random.choice(world.get_map().get_spawn_points())
vehicle = world.try_spawn_actor(vehicle_bp, transform)
# Wait for world to get the vehicle actor
world.tick()
world_snapshot = world.wait_for_tick()
actor_snapshot = world_snapshot.find(vehicle.id)
# Set spectator at given transform (vehicle transform)
spectator.set_transform(actor_snapshot.get_transform())
# ...
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.World.get_spectator-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button>
</div> <div id ="carla.TrafficLight.set_state-snipet" style="display: none;"> <p class="SnipetFont"> Snippet for carla.TrafficLight.set_state </p> <div id="carla.TrafficLight.set_state-code" class="SnipetContent">
# This recipe changes from red to green the traffic light that affects the vehicle.
# This is done by detecting if the vehicle actor is at a traffic light.
# ...
world = client.get_world()
spectator = world.get_spectator()
vehicle_bp = random.choice(world.get_blueprint_library().filter('vehicle.bmw.*'))
transform = random.choice(world.get_map().get_spawn_points())
vehicle = world.try_spawn_actor(vehicle_bp, transform)
# Wait for world to get the vehicle actor
world.tick()
world_snapshot = world.wait_for_tick()
actor_snapshot = world_snapshot.find(vehicle.id)
# Set spectator at given transform (vehicle transform)
spectator.set_transform(actor_snapshot.get_transform())
# ...# ...
if vehicle_actor.is_at_traffic_light():
traffic_light = vehicle_actor.get_traffic_light()
if traffic_light.get_state() == carla.TrafficLightState.Red:
# world.hud.notification("Traffic light changed! Good to go!")
traffic_light.set_state(carla.TrafficLightState.Green)
# ...
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.TrafficLight.set_state-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button>
</div> <div id ="carla.World.enable_environment_objects-snipet" style="display: none;"> <p class="SnipetFont"> Snippet for carla.World.enable_environment_objects </p> <div id="carla.World.enable_environment_objects-code" class="SnipetContent">
# This recipe turn visibility off and on for two specifc buildings on the map
# Get the buildings in the world
world = client.get_world()
env_objs = world.get_environment_objects(carla.CityObjectLabel.Buildings)
# Access individual building IDs and save in a set
building_01 = env_objs[0]
building_02 = env_objs[1]
objects_to_toggle = {building_01.id, building_02.id}
# Toggle buildings off
world.enable_environment_objects(objects_to_toggle, False)
# Toggle buildings on
world.enable_environment_objects(objects_to_toggle, True)
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.World.enable_environment_objects-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button>
</div> <div id ="carla.Map.get_waypoint-snipet" style="display: none;"> <p class="SnipetFont"> Snippet for carla.Map.get_waypoint </p> <div id="carla.Map.get_waypoint-code" class="SnipetContent">
# This recipe shows the current traffic rules affecting the vehicle.
# Shows the current lane type and if a lane change can be done in the actual lane or the surrounding ones.
# ...
waypoint = world.get_map().get_waypoint(vehicle.get_location(),project_to_road=True, lane_type=(carla.LaneType.Driving | carla.LaneType.Shoulder | carla.LaneType.Sidewalk))
print("Current lane type: " + str(waypoint.lane_type))
# Check current lane change allowed
print("Current Lane change: " + str(waypoint.lane_change))
# Left and Right lane markings
print("L lane marking type: " + str(waypoint.left_lane_marking.type))
print("L lane marking change: " + str(waypoint.left_lane_marking.lane_change))
print("R lane marking type: " + str(waypoint.right_lane_marking.type))
print("R lane marking change: " + str(waypoint.right_lane_marking.lane_change))
# ...
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.Map.get_waypoint-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button>
</div> <div id ="carla.Client.apply_batch_sync-snipet" style="display: none;"> <p class="SnipetFont"> Snippet for carla.Client.apply_batch_sync </p> <div id="carla.Client.apply_batch_sync-code" class="SnipetContent">
# 0. Choose a blueprint fo the walkers
world = client.get_world()
blueprintsWalkers = world.get_blueprint_library().filter("walker.pedestrian.*")
walker_bp = random.choice(blueprintsWalkers)
# 1. Take all the random locations to spawn
spawn_points = []
for i in range(50):
spawn_point = carla.Transform()
spawn_point.location = world.get_random_location_from_navigation()
if (spawn_point.location != None):
spawn_points.append(spawn_point)
# 2. Build the batch of commands to spawn the pedestrians
batch = []
for spawn_point in spawn_points:
walker_bp = random.choice(blueprintsWalkers)
batch.append(carla.command.SpawnActor(walker_bp, spawn_point))
# 2.1 apply the batch
results = client.apply_batch_sync(batch, True)
for i in range(len(results)):
if results[i].error:
logging.error(results[i].error)
else:
walkers_list.append({"id": results[i].actor_id})
# 3. Spawn walker AI controllers for each walker
batch = []
walker_controller_bp = world.get_blueprint_library().find('controller.ai.walker')
for i in range(len(walkers_list)):
batch.append(carla.command.SpawnActor(walker_controller_bp, carla.Transform(), walkers_list[i]["id"]))
# 3.1 apply the batch
results = client.apply_batch_sync(batch, True)
for i in range(len(results)):
if results[i].error:
logging.error(results[i].error)
else:
walkers_list[i]["con"] = results[i].actor_id
# 4. Put altogether the walker and controller ids
for i in range(len(walkers_list)):
all_id.append(walkers_list[i]["con"])
all_id.append(walkers_list[i]["id"])
all_actors = world.get_actors(all_id)
# wait for a tick to ensure client receives the last transform of the walkers we have just created
world.wait_for_tick()
# 5. initialize each controller and set target to walk to (list is [controller, actor, controller, actor ...])
for i in range(0, len(all_actors), 2):
# start walker
all_actors[i].start()
# set walk to random point
all_actors[i].go_to_location(world.get_random_location_from_navigation())
# random max speed
all_actors[i].set_max_speed(1 + random.random()) # max speed between 1 and 2 (default is 1.4 m/s)
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.Client.apply_batch_sync-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button>
</div> <div id ="carla.World.unload_map_layer-snipet" style="display: none;"> <p class="SnipetFont"> Snippet for carla.World.unload_map_layer </p> <div id="carla.World.unload_map_layer-code" class="SnipetContent">
# This recipe toggles off several layers in our "_Opt" maps
# Load town one with minimum layout (roads, sidewalks, traffic lights and traffic signs)
# as well as buildings and parked vehicles
world = client.load_world('Town01_Opt', carla.MapLayer.Buildings | carla.MapLayer.ParkedVehicles)
# Toggle all buildings off
world.unload_map_layer(carla.MapLayer.Buildings)
# Toggle all parked vehicles off
world.unload_map_layer(carla.MapLayer.ParkedVehicles)
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.World.unload_map_layer-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button>
</div> <div id ="carla.World.spawn_actor-snipet" style="display: none;"> <p class="SnipetFont"> Snippet for carla.World.spawn_actor </p> <div id="carla.World.spawn_actor-code" class="SnipetContent">
# This recipe attaches different camera / sensors to a vehicle with different attachments.
# ...
camera = world.spawn_actor(rgb_camera_bp, transform, attach_to=vehicle, attachment_type=Attachment.Rigid)
# Default attachment: Attachment.Rigid
gnss_sensor = world.spawn_actor(sensor_gnss_bp, transform, attach_to=vehicle)
collision_sensor = world.spawn_actor(sensor_collision_bp, transform, attach_to=vehicle)
lane_invasion_sensor = world.spawn_actor(sensor_lane_invasion_bp, transform, attach_to=vehicle)
# ...
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.World.spawn_actor-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button>
</div> <div id ="carla.World.load_map_layer-snipet" style="display: none;"> <p class="SnipetFont"> Snippet for carla.World.load_map_layer </p> <div id="carla.World.load_map_layer-code" class="SnipetContent">
# This recipe toggles on several layers in our "_Opt" maps
# Load town one with only minimum layout (roads, sidewalks, traffic lights and traffic signs)
world = client.load_world('Town01_Opt', carla.MapLayer.None)
# Toggle all buildings on
world.load_map_layer(carla.MapLayer.Buildings)
# Toggle all foliage on
world.load_map_layer(carla.MapLayer.Foliage)
# Toggle all parked vehicles on
world.load_map_layer(carla.MapLayer.ParkedVehicles)
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.World.load_map_layer-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button>
</div> <div id ="carla.WalkerAIController.stop-snipet" style="display: none;"> <p class="SnipetFont"> Snippet for carla.WalkerAIController.stop </p> <div id="carla.WalkerAIController.stop-code" class="SnipetContent">
#To destroy the pedestrians, stop them from the navigation, and then destroy the objects (actor and controller).
# stop pedestrians (list is [controller, actor, controller, actor ...])
for i in range(0, len(all_id), 2):
all_actors[i].stop()
# destroy pedestrian (actor and controller)
client.apply_batch([carla.command.DestroyActor(x) for x in all_id])
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.WalkerAIController.stop-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button>
</div> <div id ="carla.ActorBlueprint.set_attribute-snipet" style="display: none;"> <p class="SnipetFont"> Snippet for carla.ActorBlueprint.set_attribute </p> <div id="carla.ActorBlueprint.set_attribute-code" class="SnipetContent">
# This recipe changes attributes of different type of blueprint actors.
# ...
walker_bp = world.get_blueprint_library().filter('walker.pedestrian.0002')
walker_bp.set_attribute('is_invincible', True)
# ...
# Changes attribute randomly by the recommended value
vehicle_bp = wolrd.get_blueprint_library().filter('vehicle.bmw.*')
color = random.choice(vehicle_bp.get_attribute('color').recommended_values)
vehicle_bp.set_attribute('color', color)
# ...
camera_bp = world.get_blueprint_library().filter('sensor.camera.rgb')
camera_bp.set_attribute('image_size_x', 600)
camera_bp.set_attribute('image_size_y', 600)
# ...
<button id="button1" class="CopyScript" onclick="CopyToClipboard('carla.ActorBlueprint.set_attribute-code')">Copy snippet</button> <button id="button1" class="CloseSnipet" onclick="CloseSnipet()">Close snippet</button>
</div> </div> <script> function ButtonAction(container_name){ if(window_big){ snipet_name = container_name.replace('-snipet_button','-snipet'); document.getElementById("snipets-container").innerHTML = document.getElementById(snipet_name).innerHTML; } else{ document.getElementById("snipets-container").innerHTML = null;code_name = container_name.replace('-snipet_button','-code'); var range = document.createRange(); range.selectNode(document.getElementById(code_name)); alert(range); } } function WindowResize(){ if(window.innerWidth > 1200){ window_big = true; } else{ window_big = false; } } var window_big; if(window.innerWidth > 1200){ window_big = true; } else{ window_big = false; } buttons = document.getElementsByClassName('SnipetButton') for (let i = 0; i < buttons.length; i++) { buttons[i].addEventListener("click",function(){ButtonAction(buttons[i].id);},true); } window.onresize = WindowResize; </script>