Skip to content

Commit

Permalink
sergi-e/p098-api (carla-simulator#2638)
Browse files Browse the repository at this point in the history
* Python API iteration p098

* New order enum

* Fixed order getters setters

* New python api md

* New iteration, dunder coded

* PythonAPI/docs/doc_gen.py

* fix method_name
  • Loading branch information
yaknostoyok authored Mar 30, 2020
1 parent 35c346c commit 239c4c5
Show file tree
Hide file tree
Showing 14 changed files with 1,026 additions and 1,034 deletions.
867 changes: 409 additions & 458 deletions Docs/python_api.md

Large diffs are not rendered by default.

76 changes: 36 additions & 40 deletions PythonAPI/docs/actor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@
# - METHODS ----------------------------
methods:
- def_name: __str__
return: str
doc: >
Parses a summary of this actor's information to string.
# --------------------------------------
- def_name: add_impulse
params:
- param_name: impulse
Expand Down Expand Up @@ -116,6 +111,8 @@
doc: >
Sets the actor's velocity vector.
# --------------------------------------
- def_name: __str__
# --------------------------------------
- class_name: VehicleLightState
# - DESCRIPTION ------------------------
doc: >
Expand Down Expand Up @@ -148,6 +145,7 @@
- var_name: All
doc: >
All lights on
- class_name: Vehicle
parent: carla.Actor
# - DESCRIPTION ------------------------
Expand All @@ -161,20 +159,6 @@
The vehicle's collider volume.
# - METHODS ----------------------------
methods:
- def_name: get_light_state
return: carla.VehicleLightState
doc: >
Returns a flag representing the vehicle light state,
this represents which lights are active or not
# --------------------------------------
- def_name: set_light_state
params:
- param_name: light_state
type: carla.VehicleLightState
doc: >
Sets the light state of a vehicle using a VehicleLightState flag,
this represents which lights are active or not
# --------------------------------------
- def_name: apply_control
params:
- param_name: control
Expand All @@ -189,11 +173,22 @@
doc: >
Applies a physics control object in the next tick containing the parameters that define the vehicle as a corporeal body. E.g.: moment of inertia, mass, drag coefficient and many more.
# --------------------------------------
- def_name: is_at_traffic_light
return: bool
doc: >
Vehicles will be affected by a traffic light when the light is red and the vehicle is inside its bounding box. The client returns whether a traffic light is affecting this vehicle according to last tick (it does not call the simulator).
# --------------------------------------
- def_name: get_control
return: carla.VehicleControl
doc: >
The client returns the control applied in the last tick. The method does not call the simulator.
# --------------------------------------
- def_name: get_light_state
return: carla.VehicleLightState
doc: >
Returns a flag representing the vehicle light state,
this represents which lights are active or not
# --------------------------------------
- def_name: get_physics_control
return: carla.VehiclePhysicsControl
doc: >
Expand All @@ -216,11 +211,6 @@
The client returns the state of the traffic light affecting this vehicle according to last tick. The method does not call the simulator.
If no traffic light is currently affecting the vehicle, returns <b>green</b>.
# --------------------------------------
- def_name: is_at_traffic_light
return: bool
doc: >
Vehicles will be affected by a traffic light when the light is red and the vehicle is inside its bounding box. The client returns whether a traffic light is affecting this vehicle according to last tick (it does not call the simulator).
# --------------------------------------
- def_name: set_autopilot
params:
- param_name: enabled
Expand All @@ -229,8 +219,15 @@
doc: >
Turns on/off this vehicle's server-side autopilot. When autopilot mode is on, the vehicle will be conducted by the traffic manager client-side.
# --------------------------------------
- def_name: set_light_state
params:
- param_name: light_state
type: carla.VehicleLightState
doc: >
Sets the light state of a vehicle using a VehicleLightState flag,
this represents which lights are active or not
# --------------------------------------
- def_name: __str__
return: str
# --------------------------------------

- class_name: Walker
Expand Down Expand Up @@ -266,7 +263,6 @@
The client returns the control applied to this walker during last tick. The method does not call the simulator.
# --------------------------------------
- def_name: __str__
return: str
# --------------------------------------

- class_name: WalkerAIController
Expand All @@ -276,6 +272,13 @@
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.
# - METHODS ----------------------------
methods:
- def_name: go_to_location
params:
- param_name: destination
type: carla.Location
doc: >
Sets the destination that the pedestrian will reach.
# --------------------------------------
- def_name: start
doc: >
Enables AI control for its parent walker.
Expand All @@ -284,13 +287,6 @@
doc: >
Disables AI control for its parent walker.
# --------------------------------------
- def_name: go_to_location
params:
- param_name: destination
type: carla.Location
doc: >
Sets the destination that the pedestrian will reach.
# --------------------------------------
- def_name: set_max_speed
params:
- param_name: speed
Expand Down Expand Up @@ -322,9 +318,9 @@
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.
# - PROPERTIES -------------------------
instance_variables:
- var_name: Green
- var_name: Red
- var_name: Yellow
- var_name: Green
- var_name: 'Off'
- var_name: Unknown
# --------------------------------------
Expand Down Expand Up @@ -356,10 +352,10 @@
doc: >
The client returns <b>True</b> if a traffic light is frozen according to last tick. The method does not call the simulator.
# --------------------------------------
- def_name: get_pole_index
return: int
- def_name: get_elapsed_time
return: float
doc: >
Returns the index of the pole that identifies it as part of the traffic light group of a junction.
The client returns the time in seconds since current light state started according to last tick. The method does not call the simulator.
# --------------------------------------
- def_name: get_group_traffic_lights
return: list(carla.TrafficLight)
Expand All @@ -368,10 +364,10 @@
note: >
This function calls the simulator.
# --------------------------------------
- def_name: get_elapsed_time
return: float
- def_name: get_pole_index
return: int
doc: >
The client returns the time in seconds since current light state started according to last tick. The method does not call the simulator.
Returns the index of the pole that identifies it as part of the traffic light group of a junction.
# --------------------------------------
- def_name: get_state
return: carla.TrafficLightState
Expand Down
92 changes: 41 additions & 51 deletions PythonAPI/docs/blueprint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- module_name: carla
doc: >

# - CLASSES ------------------------------
classes:
- class_name: ActorAttributeType
Expand All @@ -12,8 +12,8 @@
- var_name: Bool
- var_name: Int
- var_name: Float
- var_name: RGBColor
- var_name: String
- var_name: RGBColor

- class_name: Color
# - DESCRIPTION ------------------------
Expand Down Expand Up @@ -79,18 +79,18 @@
type: str
doc: >
The attribute's name and identifier in the library.
- var_name: type
type: carla.ActorAttributeType
- var_name: is_modifiable
type: bool
doc: >
The attribute's parameter type.
It is <b>True</b> if the attribute's value can be modified.
- var_name: recommended_values
type: list(str)
doc: >
A list of values suggested by those who designed the blueprint.
- var_name: is_modifiable
type: bool
- var_name: type
type: carla.ActorAttributeType
doc: >
It is <b>True</b> if the attribute's value can be modified.
The attribute's parameter type.
# - METHODS ----------------------------
methods:
- def_name: as_bool
Expand All @@ -101,33 +101,25 @@
doc: >
Reads the attribute as carla.Color.
# --------------------------------------
- def_name: as_int
doc: >
Reads the attribute as int.
# --------------------------------------
- def_name: as_float
doc: >
Reads the attribute as float.
# --------------------------------------
- def_name: as_int
doc: >
Reads the attribute as int.
# --------------------------------------
- def_name: as_str
doc: >
Reads the attribute as string.
# --------------------------------------
- def_name: __bool__
doc: >
Internal method to manage the attribute as bool.
# --------------------------------------
- def_name: __int__
doc: >
Internal method to manage the attribute as int.
# --------------------------------------
- def_name: __float__
doc: >
Internal method to manage the attribute as float.
# --------------------------------------
- def_name: __int__
# --------------------------------------
- def_name: __str__
doc: >
Parses the attribute ID and its value to string.
# --------------------------------------
- def_name: __eq__
return: bool
Expand Down Expand Up @@ -167,18 +159,6 @@
A list of tags each blueprint has that helps describing them. E.g. `['0001', 'pedestrian', 'walker']`.
# - METHODS ----------------------------
methods:
- def_name: __iter__
doc: >
Allows iteration within this class.
# --------------------------------------
- def_name: __len__
doc: >
Returns the amount of attributes for this blueprint.
# --------------------------------------
- def_name: __str__
doc: >
Parses the information of this blueprint to string.
# --------------------------------------
- def_name: has_attribute
return: bool
params:
Expand Down Expand Up @@ -229,6 +209,16 @@
doc: >
If the `id` attribute is modifiable, changes its value to `value`.
# --------------------------------------
- def_name: __iter__
doc: >
Allows iteration within this class' attributes.
# --------------------------------------
- def_name: __len__
doc: >
Returns the amount of attributes for this blueprint.
# --------------------------------------
- def_name: __str__
# --------------------------------------

- class_name: BlueprintLibrary
# - DESCRIPTION ------------------------
Expand All @@ -238,6 +228,22 @@
[Here](bp_library.md) is a reference containing every available blueprint and its specifics.
# - METHODS ----------------------------
methods:
- def_name: filter
params:
- param_name: wildcard_pattern
type: str
doc: >
Filters a list of blueprints matching the `wildcard_pattern` against the id and tags of every blueprint contained in this library and returns the result as a new one. Matching follows [fnmatch](https://docs.python.org/2/library/fnmatch.html) standard.
return: carla.BlueprintLibrary
# --------------------------------------
- def_name: find
params:
- param_name: id
type: str
return: carla.ActorBlueprint
doc: >
Returns the blueprint corresponding to that identifier.
# --------------------------------------
- def_name: __getitem__
params:
- param_name: pos
Expand All @@ -248,7 +254,7 @@
# --------------------------------------
- def_name: __iter__
doc: >
Method that allows iteration of this class.
Method that allows iteration within the blueprints provided.
# --------------------------------------
- def_name: __len__
return: int
Expand All @@ -260,20 +266,4 @@
doc: >
Parses the identifiers for every blueprint to string.
# --------------------------------------
- def_name: filter
params:
- param_name: wildcard_pattern
type: str
doc: >
Filters a list of blueprints matching the `wildcard_pattern` against the id and tags of every blueprint contained in this library and returns the result as a new one. Matching follows [fnmatch](https://docs.python.org/2/library/fnmatch.html) standard.
return: carla.BlueprintLibrary
# --------------------------------------
- def_name: find
params:
- param_name: id
type: str
return: carla.ActorBlueprint
doc: >
Returns the blueprint corresponding to that identifier.
# --------------------------------------
...
Loading

0 comments on commit 239c4c5

Please sign in to comment.