From 31fff28bc6d24ddae0b3977f8ac343ed16019202 Mon Sep 17 00:00:00 2001 From: "sergi.e" <59253112+sergi-e@users.noreply.github.com> Date: Thu, 15 Oct 2020 16:48:48 +0200 Subject: [PATCH] sergi-e/api-snipets (#3409) * First iteration with snipets, copy button and snippet button for all methods * New iteration with snipets implemented and test snipets * New iteration without yaml intervention, with auxiliary doc deleted and responsive buttons to window width * New iteration with snipets copied from recipes, images added, and invisible button for small window * Fixed some marging issues & code formatting * Removed recipe reference and its instances. Snipets are now scalable to window width. Added button to close snipet. doc_gen_snipets.py is now imported in doc_gen.py. Cleaned css inside .py and added to extra.css * New iteration with two functionalities for snipet buttons. Pop up for small windows. * Fixed bp_library.md Co-authored-by: Marc Garcia Puig --- Docs/core_actors.md | 2 +- Docs/core_concepts.md | 2 +- Docs/core_world.md | 4 +- Docs/extra.css | 118 +++- .../carla.DebugHelper.draw_box.jpg} | Bin .../carla.DebugHelper.draw_line.jpg} | Bin .../carla.Map.get_waypoint.jpg} | Bin .../carla.TrafficLight.set_state.gif} | Bin Docs/index.md | 10 +- Docs/python_api.md | 557 ++++++++++++++++-- Docs/ref_code_recipes.md | 372 ------------ PythonAPI/docs/actor.yml | 4 +- PythonAPI/docs/doc_gen.py | 92 ++- PythonAPI/docs/doc_gen_snipets.py | 146 +++++ PythonAPI/docs/geom.yml | 2 +- PythonAPI/docs/map.yml | 8 +- PythonAPI/docs/sensor_data.yml | 2 +- .../carla.ActorBlueprint.set_attribute.py | 19 + .../docs/snipets/carla.Client.__init__.py | 30 + .../snipets/carla.Client.apply_batch_sync.py | 58 ++ .../snipets/carla.DebugHelper.draw_box.py | 13 + .../snipets/carla.DebugHelper.draw_line.py | 24 + .../docs/snipets/carla.Map.get_waypoint.py | 15 + PythonAPI/docs/snipets/carla.Sensor.listen.py | 10 + .../snipets/carla.TrafficLight.set_state.py | 28 + .../snipets/carla.WalkerAIController.stop.py | 9 + .../docs/snipets/carla.World.get_spectator.py | 20 + .../docs/snipets/carla.World.spawn_actor.py | 10 + PythonAPI/docs/world.yml | 6 +- mkdocs.yml | 3 +- 30 files changed, 1111 insertions(+), 453 deletions(-) rename Docs/img/{recipe_debug_bb.jpg => snipets_images/carla.DebugHelper.draw_box.jpg} (100%) rename Docs/img/{recipe_debug_trail.jpg => snipets_images/carla.DebugHelper.draw_line.jpg} (100%) rename Docs/img/{recipe_lane_marking.jpg => snipets_images/carla.Map.get_waypoint.jpg} (100%) rename Docs/img/{tl_recipe.gif => snipets_images/carla.TrafficLight.set_state.gif} (100%) delete mode 100644 Docs/ref_code_recipes.md create mode 100755 PythonAPI/docs/doc_gen_snipets.py create mode 100755 PythonAPI/docs/snipets/carla.ActorBlueprint.set_attribute.py create mode 100755 PythonAPI/docs/snipets/carla.Client.__init__.py create mode 100755 PythonAPI/docs/snipets/carla.Client.apply_batch_sync.py create mode 100755 PythonAPI/docs/snipets/carla.DebugHelper.draw_box.py create mode 100755 PythonAPI/docs/snipets/carla.DebugHelper.draw_line.py create mode 100755 PythonAPI/docs/snipets/carla.Map.get_waypoint.py create mode 100755 PythonAPI/docs/snipets/carla.Sensor.listen.py create mode 100755 PythonAPI/docs/snipets/carla.TrafficLight.set_state.py create mode 100755 PythonAPI/docs/snipets/carla.WalkerAIController.stop.py create mode 100755 PythonAPI/docs/snipets/carla.World.get_spectator.py create mode 100755 PythonAPI/docs/snipets/carla.World.spawn_actor.py diff --git a/Docs/core_actors.md b/Docs/core_actors.md index 39102d1b6..51eea777a 100644 --- a/Docs/core_actors.md +++ b/Docs/core_actors.md @@ -281,7 +281,7 @@ ai_controller.stop() ``` When a walker reaches the target location, they will automatically walk to another random point. If the target point is not reachable, walkers will go to the closest point from their current location. -[This recipe](ref_code_recipes.md#walker-batch-recipe) uses batches to spawn a lot of walkers and make them wander around. +A snipet in [carla.Client](python_api.md#carla.Client.apply_batch_sync) uses batches to spawn a lot of walkers and make them wander around. !!! Important __To destroy AI pedestrians__, stop the AI controller and destroy both, the actor, and the controller. diff --git a/Docs/core_concepts.md b/Docs/core_concepts.md index 22e0c99e1..ce87df825 100644 --- a/Docs/core_concepts.md +++ b/Docs/core_concepts.md @@ -2,7 +2,7 @@ This page introduces the main features and modules in CARLA. Detailed explanations of the different subjects can be found in their corresponding page. -In order to learn about the different classes and methods in the API, take a look at the [Python API reference](python_api.md). Besides, the [Code recipes](ref_code_recipes.md) reference contains some common code chunks, specially useful during these first steps. +In order to learn about the different classes and methods in the API, take a look at the [Python API reference](python_api.md). * [__First steps__](#first-steps) * [1st- World and client](#1st-world-and-client) diff --git a/Docs/core_world.md b/Docs/core_world.md index c0c809b14..2b6d1593d 100644 --- a/Docs/core_world.md +++ b/Docs/core_world.md @@ -28,7 +28,7 @@ Take a look at [__carla.Client__](python_api.md#carla.Client) in the Python API ### Client creation -Two things are needed. The __IP__ address identifying it, and __two TCP ports__ to communicate with the server. An optional third parameter sets the amount of working threads. By default this is set to all (`0`). [This code recipe](ref_code_recipes.md#parse-client-creation-arguments) shows how to parse these as arguments when running the script. +Two things are needed. The __IP__ address identifying it, and __two TCP ports__ to communicate with the server. An optional third parameter sets the amount of working threads. By default this is set to all (`0`). The [carla.Client](python_api.md#carla.Client.__init__) in the Python API reference contains a snipet that shows how to parse these as arguments when running the script. ```py client = carla.Client('localhost', 2000) @@ -224,7 +224,7 @@ debug = world.debug 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) ``` -This example is extended in a [code recipe](ref_code_recipes.md#debug-bounding-box-recipe) to draw boxes for every actor in a world snapshot. +This example is extended in a snipet in [carla.DebugHelper](python_api.md#carla.DebugHelper.draw_box) that shows how to draw boxes for every actor in a world snapshot. ### World snapshots diff --git a/Docs/extra.css b/Docs/extra.css index 341ee511e..8fdd2827d 100644 --- a/Docs/extra.css +++ b/Docs/extra.css @@ -23,7 +23,7 @@ table.defTable { } table.defTable thead { - background: #ffffff; + background: #ffffff; border-bottom: 1px solid #444444; } @@ -39,6 +39,13 @@ table.defTable tbody td{ padding: 7px 13px; } +/************************* INHERITED PYTHON API LINE **************************/ + +.Inherited { + padding-left:30px; + margin-top:-20px +} + /************************* TOWN SLIDER **************************/ * {box-sizing:border-box} @@ -53,7 +60,7 @@ table.defTable tbody td{ /* Hide the images by default */ .townslide { display: none; - text-align: center; + text-align: center; } @@ -130,3 +137,110 @@ table.defTable tbody td{ background-color: #717171; } +/************************* COPY SCRIPT BUTTON **************************/ + +.CopyScript { + box-shadow:inset 0px 1px 0px 0px #ffffff; + background:linear-gradient(to bottom, #ffffff 5%, #f6f6f6 100%); + background-color:#ffffff; + border-radius:6px; + border:1px solid #dcdcdc; + display:inline-block; + cursor:pointer; + color:#666666; + font-family:Arial; + font-size:15px; + font-weight:bold; + padding:6px 6px; + text-decoration:none; + text-shadow:0px 1px 0px #ffffff; + margin-left: 2px; +} +.CopyScript:hover { + background:linear-gradient(to bottom, #f6f6f6 5%, #ffffff 100%); + background-color:#f6f6f6; +} +.CopyScript:active { + position:relative; + top:1px; +} + +/************************* CLOSE SNIPET BUTTON **************************/ + +.CloseSnipet { + box-shadow:inset 0px 1px 0px 0px #ffffff; + background:linear-gradient(to bottom, #ffffff 5%, #f6f6f6 100%); + background-color:#ffffff; + border-radius:6px; + border:1px solid #dcdcdc; + display:inline-block; + cursor:pointer; + color:#666666; + font-family:Arial; + font-size:15px; + font-weight:bold; + padding:6px 6px; + text-decoration:none; + text-shadow:0px 1px 0px #ffffff; + margin-left: 2px; +} +.CloseSnipet:hover { + background:linear-gradient(to bottom, #ffe6e6 5%, #ffffff 100%); + background-color:#ffffff; +} +.CloseSnipet:active { + position:relative; + top:1px; +} + +/************************* SNIPET TITLE **************************/ + +.SnipetFont { + font-family: Arial, Helvetica, sans-serif; + font-size: 16px; + letter-spacing: 0.4px; + margin-left: 10px; + margin-bottom: 0px; + word-spacing: -2.2px; + color: #4675B1; + font-weight: 700; + text-decoration: rgb(68, 68, 68); + font-style: normal; + font-variant: normal; + text-transform: none; +} + +/************************* SNIPET BUTTON **************************/ + +.SnipetButton { + background-color: #476e9e; + border-radius:42px; + border:0px; + display:inline-block; + cursor:pointer; + color:#ffffff; + font-family:Arial; + font-size:12px; + padding:2px 3px; + text-decoration:none; + text-shadow:0px 1px 0px #2f6627; +} + +/************************* SNIPET CONTENT **************************/ + +.SnipetContent { + width: calc(100vw - 1150px); + margin-left: 10px; +} + +/************************* SNIPET CONTAINER **************************/ + +.Container { + position: fixed; + margin-left: 0px; + overflow-y: auto; + padding-left: 10px; + height: 95%; + top: 70px; + left: 1100px; +} diff --git a/Docs/img/recipe_debug_bb.jpg b/Docs/img/snipets_images/carla.DebugHelper.draw_box.jpg similarity index 100% rename from Docs/img/recipe_debug_bb.jpg rename to Docs/img/snipets_images/carla.DebugHelper.draw_box.jpg diff --git a/Docs/img/recipe_debug_trail.jpg b/Docs/img/snipets_images/carla.DebugHelper.draw_line.jpg similarity index 100% rename from Docs/img/recipe_debug_trail.jpg rename to Docs/img/snipets_images/carla.DebugHelper.draw_line.jpg diff --git a/Docs/img/recipe_lane_marking.jpg b/Docs/img/snipets_images/carla.Map.get_waypoint.jpg similarity index 100% rename from Docs/img/recipe_lane_marking.jpg rename to Docs/img/snipets_images/carla.Map.get_waypoint.jpg diff --git a/Docs/img/tl_recipe.gif b/Docs/img/snipets_images/carla.TrafficLight.set_state.gif similarity index 100% rename from Docs/img/tl_recipe.gif rename to Docs/img/snipets_images/carla.TrafficLight.set_state.gif diff --git a/Docs/index.md b/Docs/index.md index 1b762e08f..1d28f9e0b 100644 --- a/Docs/index.md +++ b/Docs/index.md @@ -81,8 +81,6 @@ CARLA forum

[__Python API reference__](python_api.md) — Classes and methods in the Python API. - [__Code recipes__](ref_code_recipes.md) - — Some code fragments commonly used. [__Blueprint library__](bp_library.md) — Blueprints provided to spawn actors. [__C++ reference__](ref_cpp.md) @@ -91,12 +89,14 @@ CARLA forum — Detailed explanation of the recorder file format. [__Sensors reference__](ref_sensors.md) — Everything about sensors and the data they retrieve. +

## Plugins

[__carlaviz — web visualizer__](plugins_carlaviz.md) — Plugin that listens the simulation and shows the scene and some simulation data in a web browser. - +

+ ## ROS bridge

[__ROS bridge installation__](ros_installation.md) @@ -139,11 +139,11 @@ CARLA forum ## Tutorials — Developers

- [__Contribute with new assets__](tuto_D_contribute_assets.md) + [__Contribute new assets__](tuto_D_contribute_assets.md) — Add new content to CARLA. [__Create a sensor__](tuto_D_create_sensor.md) — Develop a new sensor to be used in CARLA. - [__Create semantic tags_](tuto_D_create_semantic_tags.md) + [__Create semantic tags__](tuto_D_create_semantic_tags.md) — Define new semantic tags for semantic segmentation. [__Customize vehicle suspension__](tuto_D_customize_vehicle_suspension.md) — Modify the suspension system of a vehicle. diff --git a/Docs/python_api.md b/Docs/python_api.md index 2bd8dc9c7..ab4d2f62e 100644 --- a/Docs/python_api.md +++ b/Docs/python_api.md @@ -193,7 +193,7 @@ Returns the actor's attribute with `id` as identifier if existing. - **Setter:** _[carla.ActorBlueprint.set_attribute](#carla.ActorBlueprint.set_attribute)_

Setters
-
- **set_attribute**(**self**, **id**, **value**) +
- **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. @@ -265,13 +265,13 @@ Returns the velocity vector registered for an actor in that tick. --- ## 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. [Here](ref_code_recipes.md#attach-sensors-recipe) is a brief recipe in which we can see how sensors can be attached to a car when spawned. Note that the attachment type is declared as an enum within the class. +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 attatchment 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 this out](ref_code_recipes.md#attach-sensors-recipe) to learn some 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)). +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)). --- @@ -308,7 +308,7 @@ Parses the identifiers for every blueprint to 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 this [recipe](ref_code_recipes.md#debug-bounding-box-recipe) where the user takes a snapshot of the world and then proceeds to draw bounding boxes for traffic lights. +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_) @@ -390,7 +390,7 @@ The Client connects CARLA to the server which runs the simulation. Both server a 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) +- **\__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). @@ -400,7 +400,7 @@ Client constructor. 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/10c5f6a482a21abfd00220c68c7f12b4110b7f63/PythonAPI/examples/spawn_npc.py#L126) 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) +- **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/10c5f6a482a21abfd00220c68c7f12b4110b7f63/PythonAPI/examples/spawn_npc.py#L112-L116) 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()**. @@ -503,7 +503,7 @@ Sets the maxixum time a network call is allowed before blocking it and raising a --- ## carla.CollisionEvent -
Inherited from _[carla.SensorData](#carla.SensorData)_

Class that defines a collision data for sensor.other.collision. The sensor creates one of this for every collision detected which may be many for one simulation step. Learn more about this [here](ref_sensors.md#collision-detector). +

Inherited from _[carla.SensorData](#carla.SensorData)_

Class that defines a collision data for sensor.other.collision. The sensor creates one of this for every collision detected which may be many for one simulation step. Learn more about this [here](ref_sensors.md#collision-detector).

Instance Variables

- **actor** (_[carla.Actor](#carla.Actor)_) @@ -545,7 +545,7 @@ Initializes a color, black by default. --- ## 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 a this [recipe](ref_code_recipes.md#converted-image-recipe) to see an example of how to create and save image data for sensor.camera.semantic_segmentation. +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** @@ -616,7 +616,7 @@ Iterate over the [carla.DVSEvent](#carla.DVSEvent) retrieved as data. --- ## 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. Check out this [recipe](ref_code_recipes.md#debug-bounding-box-recipe) where the user takes a snapshot of the world and then proceeds to draw bounding boxes for traffic lights. +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) @@ -628,7 +628,7 @@ Draws an arrow from `begin` to `end` pointing in that direction. - `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) +- **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. @@ -636,7 +636,7 @@ Draws a box, ussually to act for object colliders. - `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) +- **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. @@ -713,7 +713,7 @@ Height regarding ground level. --- ## 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. +

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_) @@ -731,7 +731,7 @@ West/East value of a point on the map. --- ## 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. +

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_) @@ -749,7 +749,7 @@ Angular velocity. --- ## 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). +

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_) @@ -952,7 +952,7 @@ 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. In this [recipe](ref_code_recipes.md#lanes-recipe) the user creates a waypoint for a current vehicle position and learns which turns are permitted. +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** @@ -967,7 +967,7 @@ 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). +

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)_) @@ -1013,8 +1013,7 @@ White by default. --- ## carla.LaneMarkingType -Class that defines the lane marking types accepted by OpenDRIVE 1.4. Take a look at this [recipe](ref_code_recipes.md#lanes-recipe) where the user creates a [carla.Waypoint](#carla.Waypoint) for a vehicle location and retrieves from it 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 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** @@ -1032,7 +1031,7 @@ __Note on double types:__ Lane markings are defined under the OpenDRIVE standard --- ## carla.LaneType -Class that defines the possible lane types accepted by OpenDRIVE 1.4. This standards define the road information. For instance in this [recipe](ref_code_recipes.md#lanes-recipe) the user creates a [carla.Waypoint](#carla.Waypoint) for the current location of a vehicle and uses it to get the current and adjacent lane types. +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** @@ -1078,7 +1077,7 @@ Computed intensity for this point as a scalar value between [0.0 , 1.0]. --- ## 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). +

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_) @@ -1309,7 +1308,7 @@ Switch of a light. It is __True__ when the light is on. --- ## carla.Location -
Inherited from _[carla.Vector3D](#carla.Vector3D)_

Represents a spot in the world. +

Inherited from _[carla.Vector3D](#carla.Vector3D)_

Represents a spot in the world.

Instance Variables

- **x** (_float – meters_) @@ -1401,7 +1400,7 @@ Returns a list of recommendations made by the creators of the map to be used as - **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)) +- **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:** @@ -1423,7 +1422,7 @@ Returns a waypoint if all the parameters passed are correct. Otherwise, returns --- ## 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). +

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)_) @@ -1512,7 +1511,7 @@ The velocity of the detected object towards the sensor. --- ## 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). +

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_) @@ -1678,7 +1677,7 @@ Enum declaration used in [carla.RssSensor](#carla.RssSensor) to set the log leve --- ## 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. +

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. @@ -1730,7 +1729,7 @@ 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. +

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. @@ -1796,7 +1795,7 @@ ID of the actor hit by the ray. --- ## 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). +

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_) @@ -1829,7 +1828,7 @@ Iterate over the [carla.SemanticLidarDetection](#carla.SemanticLidarDetection) r --- ## 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). +

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. @@ -1852,7 +1851,7 @@ Iterate over the [carla.SemanticLidarDetection](#carla.SemanticLidarDetection) r When True the sensor will be waiting for data.

Methods

-- **listen**(**self**, **callback**) +- **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. @@ -1916,9 +1915,9 @@ Time register of the frame at which this measurement was taken given by the OS i --- ## 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. +

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. Take a look at this [recipe](ref_code_recipes.md#traffic-lights-recipe) to learn how to do so. + 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)_) @@ -1967,7 +1966,7 @@ The client returns the time set for the traffic light to be yellow, according to - **Setter:** _[carla.TrafficLight.set_yellow_time](#carla.TrafficLight.set_yellow_time)_
Setters
-
- **set_state**(**self**, **state**) +
- **set_state**(**self**, **state**) Sets a given state to a traffic light actor. - **Parameters:** - `state` (_[carla.TrafficLightState](#carla.TrafficLightState)_) @@ -1993,7 +1992,7 @@ Sets a given time for the yellow light to be active. --- ## carla.TrafficLightState -All possible states for traffic lights. These can either change at a specific time step or be changed manually. Take a look at this [recipe](ref_code_recipes.md#traffic-lights-recipe) to see an example. +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** @@ -2085,7 +2084,7 @@ Enables or disables the OSM mode. This mode allows the user to run TM in a map c --- ## 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. +

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** @@ -2210,7 +2209,7 @@ Returns the axis values for the vector parsed as string. --- ## carla.Vehicle -
Inherited from _[carla.Actor](#carla.Actor)_

One of the most important group 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. +

Inherited from _[carla.Actor](#carla.Actor)_

One of the most important group 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)_) @@ -2394,7 +2393,7 @@ VehiclePhysicsControl constructor. --- ## 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. +

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.

Instance Variables

- **bounding_box** (_[carla.BoundingBox](#carla.BoundingBox)_) @@ -2421,7 +2420,7 @@ The client returns the control applied to this walker during last tick. The meth --- ## 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. +

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**) @@ -2430,7 +2429,7 @@ Sets the destination that the pedestrian will reach. - `destination` (_[carla.Location](#carla.Location) – meters_) - **start**(**self**) Enables AI control for its parent walker. -- **stop**(**self**) +- **stop**(**self**) Disables AI control for its parent walker.
Setters
@@ -2702,7 +2701,7 @@ This method is used in [__asynchronous__ mode](https://[carla.readthedocs.io](#c - **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)_ -- **spawn_actor**(**self**, **blueprint**, **transform**, **attach_to**=None, **attachment**=Rigid) +- **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. @@ -2774,7 +2773,7 @@ Returns an object containing some data about the simulation such as synchrony be - **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**) +- **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_weather**(**self**) @@ -3148,4 +3147,480 @@ Links another command to be executed right after. It allows to ease very common - **Parameters:** - `command` (_any carla Command_) – a Carla command. ---- \ No newline at end of file +--- +[comment]: <> (=========================) +[comment]: <> (PYTHON API SCRIPT SNIPETS) +[comment]: <> (=========================) +
+ + + +