├── src ├── __init__.py ├── code_generator.py ├── generate_stubs.py └── stub_generator.py ├── requirements.txt ├── LICENSE.md ├── README.md ├── .gitignore └── stubs ├── 0.9.13 └── command.pyi ├── 0.9.14 └── command.pyi └── 0.9.15 └── command.pyi /src/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | pyyaml==6.0 2 | requests==2.28.1 3 | -------------------------------------------------------------------------------- /src/code_generator.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | class CodeGenerator: 4 | level: int 5 | code: str 6 | 7 | def __init__(self): 8 | self.level = 0 9 | self.code = "" 10 | 11 | def indent(self): 12 | self.level += 1 13 | 14 | def dedent(self): 15 | self.level = max(0, self.level - 1) 16 | 17 | def add_line(self, value: str | None = None): 18 | if not value: 19 | self.code += "\n" 20 | else: 21 | self.code += "\t" * self.level + str(value) + "\n" 22 | 23 | def save_to_file(self, path: str): 24 | with open(path, "a") as f: 25 | f.write(self.code) 26 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Mathias Wold 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/generate_stubs.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import argparse 4 | import os 5 | from pathlib import Path 6 | 7 | import requests 8 | 9 | from .stub_generator import CarlaStubGenerator 10 | 11 | PROJECT_ROOT = Path(__file__).parent.parent 12 | 13 | 14 | if __name__ == "__main__": 15 | parser = argparse.ArgumentParser() 16 | parser.add_argument( 17 | "--version", 18 | help="The version of the CARLA Python API to generate the stubs for.", 19 | type=str, 20 | ) 21 | parser.add_argument( 22 | "--output", 23 | help="The output directory.", 24 | type=str, 25 | default=PROJECT_ROOT / "stubs", 26 | ) 27 | args = parser.parse_args() 28 | 29 | version = args.version 30 | if not version: 31 | # get the latest version from repository tags 32 | tags = requests.get( 33 | "https://api.github.com/repos/carla-simulator/carla/tags" 34 | ).json() 35 | version = tags[0]["name"] 36 | 37 | # list all files in the CARLA Python API docs repository 38 | carla_repo_url = f"https://api.github.com/repos/carla-simulator/carla/contents/PythonAPI/docs?ref={version}" 39 | response = requests.get(carla_repo_url) 40 | 41 | if response.status_code == 404: 42 | raise Exception(f"CARLA PythonAPI version {version} not found") 43 | 44 | data = response.json() 45 | 46 | # get download urls for all yaml files in the CARLA Python API docs 47 | file_urls = [ 48 | file["download_url"] 49 | for file in data 50 | if file["name"].endswith((".yml", ".yaml")) 51 | ] 52 | 53 | output_path = Path(args.output) / Path(version) 54 | os.makedirs(output_path, exist_ok=True) 55 | 56 | # remove old stubs 57 | for file in os.listdir(output_path): 58 | os.remove(os.path.join(output_path, file)) 59 | 60 | # generate stubs for all yaml files 61 | print(f"Generating stubs for CARLA PythonAPI version {version}... \n") 62 | 63 | for file_url in file_urls: 64 | print(f"Generating stubs for {file_url.split('/')[-1]}") 65 | file = requests.get(file_url).text 66 | stub_generator = CarlaStubGenerator(file) 67 | stub_generator.save_to_file(output_path) 68 | 69 | print(f"\nSaved stubs to {output_path.relative_to(PROJECT_ROOT)}") 70 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CARLA Python Stubs 2 | 3 | [![GitHub all releases](https://img.shields.io/github/downloads/mathiaswold/carla-python-stubs/total)](https://github.com/mathiaswold/carla-python-stubs/releases) 4 | 5 | This repository contains [Python stub files](https://peps.python.org/pep-0484/#stub-files) for the [CARLA Python API](https://carla.readthedocs.io/en/latest/python_api/). Installing these along the CARLA Python API will allow you to use type hints and auto-completion in your code. 6 | 7 | ![type-hints](https://user-images.githubusercontent.com/45951843/189996748-ef9e27f7-c3df-4249-bb22-659edffd54ea.png) 8 | 9 | ## Installation 10 | Download the stub files (ending with `.pyi`) for your version of CARLA from [the releases page](https://github.com/mathiaswold/carla-python-stubs/releases). Then follow the installation instructions for your editor below. 11 | 12 | ### VS Code 13 | VS code expects by default that custom stubs are placed in the `./typings` directory in your project. Create a subdirectory named `carla` (`./typings/carla`) and place the stub files there. You should now see type hints for the `carla`-module in your code. See [VS Code docs of `stubPath`](https://code.visualstudio.com/docs/python/settings-reference#_python-language-server-settings) for more information. 14 | 15 | 16 | ### PyCharm 17 | Create a directory in the root of your project with any name, for example `./stubs`. Right-click the directory and select **Mark directory as** --> **Sources Root**. Create a subdirectory named `carla` (`./stubs/carla`) and place the stub files there. You should now see type hints for the `carla`-module in your code. See [PyCharm docs of stubs for external implementation](https://www.jetbrains.com/help/pycharm/stubs.html#create-stub-external) for more information. 18 | 19 | ### Other editors 20 | See if your editor supports adding custom Python stubs. If not, you can add the stub files directly to the CARLA module: 21 | 1. Run `pip show carla` in the terminal. Find the `Location` path. This should end in a directory named `site-packages`. 22 | 2. Open the `Location` directory above. Place the stub files in the `carla` subdiretory (`.../site-packages/carla`). 23 | 3. You should now see type hints for the `carla`-module in your code. 24 | 25 | 26 | ## Generating stubs 27 | Stubs are available in [releases](https://github.com/mathiaswold/carla-python-stubs/releases). You can generate them yourself: 28 | 1. Clone this repository. 29 | 2. Install the requirements: `pip install -r requirements.txt` 30 | 3. Run `python -m src.generate_stubs` in the terminal. This will generate stubs for the latest CARLA version. You can specify a different version by running `python -m src.generate_stubs --version `. See `python -m src.generate_stubs --help` for more information. 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # poetry 98 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 99 | # This is especially recommended for binary packages to ensure reproducibility, and is more 100 | # commonly ignored for libraries. 101 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 102 | #poetry.lock 103 | 104 | # pdm 105 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 106 | #pdm.lock 107 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 108 | # in version control. 109 | # https://pdm.fming.dev/#use-with-ide 110 | .pdm.toml 111 | 112 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 113 | __pypackages__/ 114 | 115 | # Celery stuff 116 | celerybeat-schedule 117 | celerybeat.pid 118 | 119 | # SageMath parsed files 120 | *.sage.py 121 | 122 | # Environments 123 | .env 124 | .venv 125 | env/ 126 | venv/ 127 | ENV/ 128 | env.bak/ 129 | venv.bak/ 130 | 131 | # Spyder project settings 132 | .spyderproject 133 | .spyproject 134 | 135 | # Rope project settings 136 | .ropeproject 137 | 138 | # mkdocs documentation 139 | /site 140 | 141 | # mypy 142 | .mypy_cache/ 143 | .dmypy.json 144 | dmypy.json 145 | 146 | # Pyre type checker 147 | .pyre/ 148 | 149 | # pytype static type analyzer 150 | .pytype/ 151 | 152 | # Cython debug symbols 153 | cython_debug/ 154 | 155 | # PyCharm 156 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 157 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 158 | # and can be added to the global gitignore or merged into this file. For a more nuclear 159 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 160 | .idea/ 161 | -------------------------------------------------------------------------------- /src/stub_generator.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import re 4 | from pathlib import Path 5 | 6 | import yaml 7 | 8 | from .code_generator import CodeGenerator 9 | 10 | MODULE_NAMES = ["carla", "command"] 11 | 12 | 13 | class CarlaStubGenerator: 14 | module_name: str 15 | classes: list[dict] 16 | _generator: CodeGenerator 17 | 18 | def __init__(self, file): 19 | try: 20 | data = yaml.safe_load(file)[0] 21 | except IndexError: 22 | raise IndexError(f"{file} is empty") 23 | 24 | self.module_name = data.get("module_name") 25 | self.classes = data.get("classes") 26 | self._generator = CodeGenerator() 27 | self._generator.add_line("from __future__ import annotations") 28 | self._generator.add_line() 29 | self._generator.add_line("from typing import Any") 30 | self._generator.add_line("import numpy as np") 31 | self._generator.add_line() 32 | for module_name in MODULE_NAMES: 33 | if self.module_name != module_name: 34 | self._generator.add_line(f"import {module_name}") 35 | self._generator.add_line() 36 | 37 | def save_to_file(self, directory: Path): 38 | self._generate() 39 | file_name = "__init__" if self.module_name == "carla" else self.module_name 40 | self._generator.save_to_file(directory / f"{file_name}.pyi") 41 | 42 | def _generate(self): 43 | for _class in self.classes: 44 | self._generate_class(_class) 45 | self._generator.add_line() 46 | self._generator.add_line() 47 | 48 | def _generate_class(self, _class): 49 | class_name = _class.get("class_name", None) 50 | if class_name: 51 | parent = _class.get("parent", None) 52 | if parent: 53 | parent = self._remove_module(parent) 54 | self._generator.add_line(f"class {class_name}({parent}):") 55 | else: 56 | self._generator.add_line(f"class {class_name}:") 57 | self._generator.indent() 58 | self._generator.add_line('"""') 59 | self._generator.add_line(self._parse_docs(_class.get("doc", ""))) 60 | self._generator.add_line('"""') 61 | self._generator.add_line() 62 | self._generate_instance_variables(_class) 63 | self._generate_methods(_class) 64 | self._generator.dedent() 65 | 66 | def _generate_instance_variables(self, _class): 67 | instance_variables = _class.get("instance_variables", []) 68 | if instance_variables: 69 | for instance_variable in instance_variables: 70 | name = instance_variable.get("var_name", None) 71 | if name: 72 | type = self._parse_type(instance_variable.get("type", "Any")) 73 | doc = self._parse_docs(instance_variable.get("doc", "")) 74 | self._generator.add_line(f"{name}: {type}") 75 | self._generator.add_line(f'"""{doc}"""') 76 | self._generator.add_line() 77 | 78 | def _generate_methods(self, _class): 79 | methods = _class.get("methods", []) 80 | for method in methods: 81 | name = method.get("def_name", None) 82 | if name: 83 | param_list = method.get("params", []) 84 | param_list = param_list or [] 85 | 86 | # parse params in method defintion 87 | def_params = "self, " 88 | for param in param_list: 89 | param_name = param.get("param_name", "").split("(")[0] 90 | param_type = self._parse_type(param.get("type", "Any")) 91 | param_default = param.get("default", None) 92 | if param_default is not None: 93 | if param_type == "str": 94 | param_default = f'"{param_default}"' 95 | try: 96 | param_default = self._remove_module(param_default) 97 | if param_default.startswith(f"{param_type}."): 98 | param_default = param_default.split(".")[0] 99 | except: 100 | pass 101 | def_params += f"{param_name}: {param_type} = {param_default}, " 102 | else: 103 | def_params += f"{param_name}: {param_type}, " 104 | def_params = def_params.rstrip(", ") 105 | 106 | # parse return type and generate method definition 107 | return_type = method.get("return", None) 108 | if return_type: 109 | parsed_return_type = self._parse_type(return_type) 110 | self._generator.add_line( 111 | f"def {name}({def_params}) -> {parsed_return_type}:" 112 | ) 113 | else: 114 | self._generator.add_line(f"def {name}({def_params}):") 115 | 116 | # generate method docstring 117 | self._generator.indent() 118 | self._generator.add_line('"""') 119 | self._generator.add_line(self._parse_docs(method.get("doc", ""))) 120 | 121 | note = method.get("note", None) 122 | if note: 123 | self._generator.add_line() 124 | self._generator.add_line(f"*note*: {self._parse_docs(note)}") 125 | 126 | warning = method.get("warning", None) 127 | if warning: 128 | self._generator.add_line() 129 | self._generator.add_line( 130 | f"**warning**: {self._parse_docs(warning)}" 131 | ) 132 | 133 | for param in param_list: 134 | param_name = param.get("param_name", "") 135 | param_type = self._parse_type(param.get("type", "")) 136 | param_doc = self._parse_docs(param.get("doc", "")) 137 | self._generator.add_line() 138 | self._generator.add_line( 139 | f":param {param_name}: ({param_type}) {param_doc}" 140 | ) 141 | 142 | if return_type: 143 | self._generator.add_line() 144 | self._generator.add_line(f":return: {return_type}") 145 | 146 | self._generator.add_line('"""') 147 | self._generator.add_line("...") 148 | self._generator.dedent() 149 | self._generator.add_line() 150 | 151 | def _parse_type(self, _type: str): 152 | if "uint" in _type: 153 | return f"np.{_type}" 154 | if _type == "boolean": 155 | return "bool" 156 | if "<" in _type: # skip html tags 157 | return "Any" 158 | if " " in _type: 159 | return "str" 160 | if _type == "string": 161 | return "str" 162 | _type = self._remove_module(_type) # remove module name 163 | _type = _type.replace("(", "[").replace(")", "]") 164 | 165 | return _type 166 | 167 | def _remove_module(self, value: str): 168 | return value.replace(f"{self.module_name}.", "") 169 | 170 | def _parse_docs(self, value: str): 171 | # remove html tags of type __add_force()__ 172 | value = re.sub(r"__<.*?>", "", value) 173 | value = re.sub(r"<.*?>__", "", value) 174 | 175 | # remove other tags 176 | for tag in ["a", "b", "i", "br", "code", "font", "small"]: 177 | value = re.sub(rf"<{tag}.*?>", "", value) 178 | value = value.replace(f"", "") 179 | 180 | return value.strip() 181 | -------------------------------------------------------------------------------- /stubs/0.9.13/command.pyi: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import Any 4 | import numpy as np 5 | 6 | import carla 7 | 8 | class Response: 9 | """ 10 | States the result of executing a command as either the ID of the actor to whom the command was applied to (when succeeded) or an error string (when failed). actor ID, depending on whether or not the command succeeded. The method apply_batch_sync() in carla.Client returns a list of these to summarize the execution of a batch. 11 | """ 12 | 13 | actor_id: int 14 | """Actor to whom the command was applied to. States that the command was successful.""" 15 | 16 | error: str 17 | """A string stating the command has failed.""" 18 | 19 | def has_error(self) -> bool: 20 | """ 21 | Returns True if the command execution fails, and False if it was successful. 22 | 23 | :return: bool 24 | """ 25 | ... 26 | 27 | 28 | 29 | class SpawnActor: 30 | """ 31 | Command adaptation of spawn_actor() 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. 32 | """ 33 | 34 | transform: carla.Transform 35 | """Transform to be applied.""" 36 | 37 | parent_id: int 38 | """Identificator of the parent actor.""" 39 | 40 | def __init__(self): 41 | """ 42 | 43 | """ 44 | ... 45 | 46 | def __init__(self, blueprint: carla.ActorBlueprint, transform: carla.Transform): 47 | """ 48 | 49 | 50 | :param blueprint: (carla.ActorBlueprint) 51 | 52 | :param transform: (carla.Transform) 53 | """ 54 | ... 55 | 56 | def __init__(self, blueprint: carla.ActorBlueprint, transform: carla.Transform, parent: str): 57 | """ 58 | 59 | 60 | :param blueprint: (carla.ActorBlueprint) 61 | 62 | :param transform: (carla.Transform) 63 | 64 | :param parent: (str) 65 | """ 66 | ... 67 | 68 | def then(self, command: str): 69 | """ 70 | Links another command to be executed right after. It allows to ease very common flows such as spawning a set of vehicles by command and then using this method to set them to autopilot automatically. 71 | 72 | :param command: (str) a Carla command. 73 | """ 74 | ... 75 | 76 | 77 | 78 | class DestroyActor: 79 | """ 80 | Command adaptation of destroy() in carla.Actor that tells the simulator to destroy this actor. It has no effect if the actor was already destroyed. When executed with apply_batch_sync() in carla.Client there will be a command.Response that will return a boolean stating whether the actor was successfully destroyed. 81 | """ 82 | 83 | actor_id: int 84 | """Actor affected by the command""" 85 | 86 | def __init__(self, actor: str): 87 | """ 88 | 89 | 90 | :param actor: (str) Actor or its ID to whom the command will be applied to. 91 | """ 92 | ... 93 | 94 | 95 | 96 | class ApplyVehiclePhysicsControl: 97 | """ 98 | Command adaptation of apply_physics_control() in carla.Vehicle. Applies a new physics control to a vehicle, modifying its physical parameters. 99 | """ 100 | 101 | actor_id: int 102 | """Vehicle actor affected by the command.""" 103 | 104 | control: carla.VehiclePhysicsControl 105 | """Physics control to be applied.""" 106 | 107 | def __init__(self, actor: str, control: carla.VehiclePhysicsControl): 108 | """ 109 | 110 | 111 | :param actor: (str) Actor or its ID to whom the command will be applied to. 112 | 113 | :param control: (carla.VehiclePhysicsControl) 114 | """ 115 | ... 116 | 117 | 118 | 119 | class ApplyVehicleControl: 120 | """ 121 | Command adaptation of apply_control() in carla.Vehicle. Applies a certain control to a vehicle. 122 | """ 123 | 124 | actor_id: int 125 | """Vehicle actor affected by the command.""" 126 | 127 | control: carla.VehicleControl 128 | """Vehicle control to be applied.""" 129 | 130 | def __init__(self, actor: str, control: carla.VehicleControl): 131 | """ 132 | 133 | 134 | :param actor: (str) Actor or its ID to whom the command will be applied to. 135 | 136 | :param control: (carla.VehicleControl) 137 | """ 138 | ... 139 | 140 | 141 | 142 | class ApplyWalkerControl: 143 | """ 144 | Command adaptation of apply_control() in carla.Walker. Applies a control to a walker. 145 | """ 146 | 147 | actor_id: int 148 | """Walker actor affected by the command.""" 149 | 150 | control: carla.WalkerControl 151 | """Walker control to be applied.""" 152 | 153 | def __init__(self, actor: str, control: carla.WalkerControl): 154 | """ 155 | 156 | 157 | :param actor: (str) Actor or its ID to whom the command will be applied to. 158 | 159 | :param control: (carla.WalkerControl) 160 | """ 161 | ... 162 | 163 | 164 | 165 | class ApplyTransform: 166 | """ 167 | Command adaptation of set_transform() in carla.Actor. Sets a new transform to an actor. 168 | """ 169 | 170 | actor_id: int 171 | """Actor affected by the command.""" 172 | 173 | transform: carla.Transform 174 | """Transformation to be applied.""" 175 | 176 | def __init__(self, actor: str, transform: carla.Transform): 177 | """ 178 | 179 | 180 | :param actor: (str) Actor or its ID to whom the command will be applied to. 181 | 182 | :param transform: (carla.Transform) 183 | """ 184 | ... 185 | 186 | 187 | 188 | class ApplyWalkerState: 189 | """ 190 | Apply a state to the walker actor. Specially useful to initialize an actor them with a specific location, orientation and speed. 191 | """ 192 | 193 | actor_id: int 194 | """Walker actor affected by the command.""" 195 | 196 | transform: carla.Transform 197 | """Transform to be applied.""" 198 | 199 | speed: float 200 | """Speed to be applied.""" 201 | 202 | def __init__(self, actor: str, transform: carla.Transform, speed: float): 203 | """ 204 | 205 | 206 | :param actor: (str) Actor or its ID to whom the command will be applied to. 207 | 208 | :param transform: (carla.Transform) 209 | 210 | :param speed: (float) 211 | """ 212 | ... 213 | 214 | 215 | 216 | class ApplyTargetVelocity: 217 | """ 218 | Command adaptation of set_target_velocity() in carla.Actor. 219 | """ 220 | 221 | actor_id: int 222 | """Actor affected by the command.""" 223 | 224 | velocity: carla.Vector3D 225 | """The 3D velocity applied to the actor.""" 226 | 227 | def __init__(self, actor: str, velocity: carla.Vector3D): 228 | """ 229 | 230 | 231 | :param actor: (str) Actor or its ID to whom the command will be applied to. 232 | 233 | :param velocity: (carla.Vector3D) Velocity vector applied to the actor. 234 | """ 235 | ... 236 | 237 | 238 | 239 | class ApplyTargetAngularVelocity: 240 | """ 241 | Command adaptation of set_target_angular_velocity() in carla.Actor. Sets the actor's angular velocity vector. 242 | """ 243 | 244 | actor_id: int 245 | """Actor affected by the command.""" 246 | 247 | angular_velocity: carla.Vector3D 248 | """The 3D angular velocity that will be applied to the actor.""" 249 | 250 | def __init__(self, actor: str, angular_velocity: carla.Vector3D): 251 | """ 252 | 253 | 254 | :param actor: (str) Actor or its ID to whom the command will be applied to. 255 | 256 | :param angular_velocity: (carla.Vector3D) Angular velocity vector applied to the actor. 257 | """ 258 | ... 259 | 260 | 261 | 262 | class ApplyImpulse: 263 | """ 264 | Command adaptation of add_impulse() in carla.Actor. Applies an impulse to an actor. 265 | """ 266 | 267 | actor_id: int 268 | """Actor affected by the command.""" 269 | 270 | impulse: carla.Vector3D 271 | """Impulse applied to the actor.""" 272 | 273 | def __init__(self, actor: str, impulse: carla.Vector3D): 274 | """ 275 | 276 | 277 | :param actor: (str) Actor or its ID to whom the command will be applied to. 278 | 279 | :param impulse: (carla.Vector3D) 280 | """ 281 | ... 282 | 283 | 284 | 285 | class ApplyForce: 286 | """ 287 | Command adaptation of add_force() in carla.Actor. Applies a force to an actor. 288 | """ 289 | 290 | actor_id: int 291 | """Actor affected by the command.""" 292 | 293 | force: carla.Vector3D 294 | """Force applied to the actor over time.""" 295 | 296 | def __init__(self, actor: str, force: carla.Vector3D): 297 | """ 298 | 299 | 300 | :param actor: (str) Actor or its ID to whom the command will be applied to. 301 | 302 | :param force: (carla.Vector3D) 303 | """ 304 | ... 305 | 306 | 307 | 308 | class ApplyAngularImpulse: 309 | """ 310 | Command adaptation of add_angular_impulse() in carla.Actor. Applies an angular impulse to an actor. 311 | """ 312 | 313 | actor_id: int 314 | """Actor affected by the command.""" 315 | 316 | impulse: carla.Vector3D 317 | """Angular impulse applied to the actor.""" 318 | 319 | def __init__(self, actor: str, impulse: carla.Vector3D): 320 | """ 321 | 322 | 323 | :param actor: (str) Actor or its ID to whom the command will be applied to. 324 | 325 | :param impulse: (carla.Vector3D) 326 | """ 327 | ... 328 | 329 | 330 | 331 | class ApplyTorque: 332 | """ 333 | Command adaptation of add_torque() in carla.Actor. Applies a torque to an actor. 334 | """ 335 | 336 | actor_id: int 337 | """Actor affected by the command.""" 338 | 339 | torque: carla.Vector3D 340 | """Torque applied to the actor over time.""" 341 | 342 | def __init__(self, actor: str, torque: carla.Vector3D): 343 | """ 344 | 345 | 346 | :param actor: (str) Actor or its ID to whom the command will be applied to. 347 | 348 | :param torque: (carla.Vector3D) 349 | """ 350 | ... 351 | 352 | 353 | 354 | class SetSimulatePhysics: 355 | """ 356 | Command adaptation of set_simulate_physics() in carla.Actor. Determines whether an actor will be affected by physics or not. 357 | """ 358 | 359 | actor_id: int 360 | """Actor affected by the command.""" 361 | 362 | enabled: bool 363 | """If physics should be activated or not.""" 364 | 365 | def __init__(self, actor: str, enabled: bool): 366 | """ 367 | 368 | 369 | :param actor: (str) Actor or its ID to whom the command will be applied to. 370 | 371 | :param enabled: (bool) 372 | """ 373 | ... 374 | 375 | 376 | 377 | class SetAutopilot: 378 | """ 379 | Command adaptation of set_autopilot() in carla.Vehicle. Turns on/off the vehicle's autopilot mode. 380 | """ 381 | 382 | actor_id: int 383 | """Actor that is affected by the command.""" 384 | 385 | enabled: bool 386 | """If autopilot should be activated or not.""" 387 | 388 | port: np.uint16 389 | """Port of the Traffic Manager where the vehicle is to be registered or unlisted.""" 390 | 391 | def __init__(self, actor: str, enabled: bool, port: np.uint16 = 8000): 392 | """ 393 | 394 | 395 | :param actor: (str) Actor or its ID to whom the command will be applied to. 396 | 397 | :param enabled: (bool) 398 | 399 | :param port: (np.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`. 400 | """ 401 | ... 402 | 403 | 404 | 405 | class SetVehicleLightState: 406 | """ 407 | Command adaptation of set_light_state() in carla.Vehicle. Sets the light state of a vehicle. 408 | """ 409 | 410 | actor_id: int 411 | """Actor that is affected by the command.""" 412 | 413 | light_state: carla.VehicleLightState 414 | """Defines the light state of a vehicle.""" 415 | 416 | def __init__(self, actor: str, light_state: carla.VehicleLightState): 417 | """ 418 | 419 | 420 | :param actor: (str) Actor or its ID to whom the command will be applied to. 421 | 422 | :param light_state: (carla.VehicleLightState) Recaps the state of the lights of a vehicle, these can be used as a flags. 423 | """ 424 | ... 425 | 426 | 427 | 428 | class SetEnableGravity: 429 | """ 430 | Command adaptation of set_enable_gravity() in carla.Actor. Enables or disables gravity on an actor. 431 | """ 432 | 433 | actor_id: str 434 | """Actor that is affected by the command.""" 435 | 436 | enabled: bool 437 | """""" 438 | 439 | def __init__(self, actor: str, enabled: bool): 440 | """ 441 | 442 | 443 | :param actor: (str) Actor or Actor ID to which the command will be applied to. 444 | 445 | :param enabled: (bool) 446 | """ 447 | ... 448 | 449 | 450 | 451 | class ShowDebugTelemetry: 452 | """ 453 | Command adaptation of show_debug_telemetry() in carla.Actor. Displays vehicle control telemetry data. 454 | """ 455 | 456 | actor_id: str 457 | """Actor that is affected by the command.""" 458 | 459 | enabled: bool 460 | """""" 461 | 462 | def __init__(self, actor: str, enabled: bool): 463 | """ 464 | 465 | 466 | :param actor: (str) Actor or Actor ID to which the command will be applied to. 467 | 468 | :param enabled: (bool) 469 | """ 470 | ... 471 | 472 | 473 | 474 | -------------------------------------------------------------------------------- /stubs/0.9.14/command.pyi: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import Any 4 | import numpy as np 5 | 6 | import carla 7 | 8 | class Response: 9 | """ 10 | States the result of executing a command as either the ID of the actor to whom the command was applied to (when succeeded) or an error string (when failed). actor ID, depending on whether or not the command succeeded. The method apply_batch_sync() in carla.Client returns a list of these to summarize the execution of a batch. 11 | """ 12 | 13 | actor_id: int 14 | """Actor to whom the command was applied to. States that the command was successful.""" 15 | 16 | error: str 17 | """A string stating the command has failed.""" 18 | 19 | def has_error(self) -> bool: 20 | """ 21 | Returns True if the command execution fails, and False if it was successful. 22 | 23 | :return: bool 24 | """ 25 | ... 26 | 27 | 28 | 29 | class SpawnActor: 30 | """ 31 | Command adaptation of spawn_actor() 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. 32 | """ 33 | 34 | transform: carla.Transform 35 | """Transform to be applied.""" 36 | 37 | parent_id: int 38 | """Identificator of the parent actor.""" 39 | 40 | def __init__(self): 41 | """ 42 | 43 | """ 44 | ... 45 | 46 | def __init__(self, blueprint: carla.ActorBlueprint, transform: carla.Transform): 47 | """ 48 | 49 | 50 | :param blueprint: (carla.ActorBlueprint) 51 | 52 | :param transform: (carla.Transform) 53 | """ 54 | ... 55 | 56 | def __init__(self, blueprint: carla.ActorBlueprint, transform: carla.Transform, parent: str): 57 | """ 58 | 59 | 60 | :param blueprint: (carla.ActorBlueprint) 61 | 62 | :param transform: (carla.Transform) 63 | 64 | :param parent: (str) 65 | """ 66 | ... 67 | 68 | def then(self, command: str): 69 | """ 70 | Links another command to be executed right after. It allows to ease very common flows such as spawning a set of vehicles by command and then using this method to set them to autopilot automatically. 71 | 72 | :param command: (str) a Carla command. 73 | """ 74 | ... 75 | 76 | 77 | 78 | class DestroyActor: 79 | """ 80 | Command adaptation of destroy() in carla.Actor that tells the simulator to destroy this actor. It has no effect if the actor was already destroyed. When executed with apply_batch_sync() in carla.Client there will be a command.Response that will return a boolean stating whether the actor was successfully destroyed. 81 | """ 82 | 83 | actor_id: int 84 | """Actor affected by the command""" 85 | 86 | def __init__(self, actor: str): 87 | """ 88 | 89 | 90 | :param actor: (str) Actor or its ID to whom the command will be applied to. 91 | """ 92 | ... 93 | 94 | 95 | 96 | class ApplyVehiclePhysicsControl: 97 | """ 98 | Command adaptation of apply_physics_control() in carla.Vehicle. Applies a new physics control to a vehicle, modifying its physical parameters. 99 | """ 100 | 101 | actor_id: int 102 | """Vehicle actor affected by the command.""" 103 | 104 | control: carla.VehiclePhysicsControl 105 | """Physics control to be applied.""" 106 | 107 | def __init__(self, actor: str, control: carla.VehiclePhysicsControl): 108 | """ 109 | 110 | 111 | :param actor: (str) Actor or its ID to whom the command will be applied to. 112 | 113 | :param control: (carla.VehiclePhysicsControl) 114 | """ 115 | ... 116 | 117 | 118 | 119 | class ApplyVehicleControl: 120 | """ 121 | Command adaptation of apply_control() in carla.Vehicle. Applies a certain control to a vehicle. 122 | """ 123 | 124 | actor_id: int 125 | """Vehicle actor affected by the command.""" 126 | 127 | control: carla.VehicleControl 128 | """Vehicle control to be applied.""" 129 | 130 | def __init__(self, actor: str, control: carla.VehicleControl): 131 | """ 132 | 133 | 134 | :param actor: (str) Actor or its ID to whom the command will be applied to. 135 | 136 | :param control: (carla.VehicleControl) 137 | """ 138 | ... 139 | 140 | 141 | 142 | class ApplyWalkerControl: 143 | """ 144 | Command adaptation of apply_control() in carla.Walker. Applies a control to a walker. 145 | """ 146 | 147 | actor_id: int 148 | """Walker actor affected by the command.""" 149 | 150 | control: carla.WalkerControl 151 | """Walker control to be applied.""" 152 | 153 | def __init__(self, actor: str, control: carla.WalkerControl): 154 | """ 155 | 156 | 157 | :param actor: (str) Actor or its ID to whom the command will be applied to. 158 | 159 | :param control: (carla.WalkerControl) 160 | """ 161 | ... 162 | 163 | 164 | 165 | class ApplyTransform: 166 | """ 167 | Command adaptation of set_transform() in carla.Actor. Sets a new transform to an actor. 168 | """ 169 | 170 | actor_id: int 171 | """Actor affected by the command.""" 172 | 173 | transform: carla.Transform 174 | """Transformation to be applied.""" 175 | 176 | def __init__(self, actor: str, transform: carla.Transform): 177 | """ 178 | 179 | 180 | :param actor: (str) Actor or its ID to whom the command will be applied to. 181 | 182 | :param transform: (carla.Transform) 183 | """ 184 | ... 185 | 186 | 187 | 188 | class ApplyWalkerState: 189 | """ 190 | Apply a state to the walker actor. Specially useful to initialize an actor them with a specific location, orientation and speed. 191 | """ 192 | 193 | actor_id: int 194 | """Walker actor affected by the command.""" 195 | 196 | transform: carla.Transform 197 | """Transform to be applied.""" 198 | 199 | speed: float 200 | """Speed to be applied.""" 201 | 202 | def __init__(self, actor: str, transform: carla.Transform, speed: float): 203 | """ 204 | 205 | 206 | :param actor: (str) Actor or its ID to whom the command will be applied to. 207 | 208 | :param transform: (carla.Transform) 209 | 210 | :param speed: (float) 211 | """ 212 | ... 213 | 214 | 215 | 216 | class ApplyTargetVelocity: 217 | """ 218 | Command adaptation of set_target_velocity() in carla.Actor. 219 | """ 220 | 221 | actor_id: int 222 | """Actor affected by the command.""" 223 | 224 | velocity: carla.Vector3D 225 | """The 3D velocity applied to the actor.""" 226 | 227 | def __init__(self, actor: str, velocity: carla.Vector3D): 228 | """ 229 | 230 | 231 | :param actor: (str) Actor or its ID to whom the command will be applied to. 232 | 233 | :param velocity: (carla.Vector3D) Velocity vector applied to the actor. 234 | """ 235 | ... 236 | 237 | 238 | 239 | class ApplyTargetAngularVelocity: 240 | """ 241 | Command adaptation of set_target_angular_velocity() in carla.Actor. Sets the actor's angular velocity vector. 242 | """ 243 | 244 | actor_id: int 245 | """Actor affected by the command.""" 246 | 247 | angular_velocity: carla.Vector3D 248 | """The 3D angular velocity that will be applied to the actor.""" 249 | 250 | def __init__(self, actor: str, angular_velocity: carla.Vector3D): 251 | """ 252 | 253 | 254 | :param actor: (str) Actor or its ID to whom the command will be applied to. 255 | 256 | :param angular_velocity: (carla.Vector3D) Angular velocity vector applied to the actor. 257 | """ 258 | ... 259 | 260 | 261 | 262 | class ApplyImpulse: 263 | """ 264 | Command adaptation of add_impulse() in carla.Actor. Applies an impulse to an actor. 265 | """ 266 | 267 | actor_id: int 268 | """Actor affected by the command.""" 269 | 270 | impulse: carla.Vector3D 271 | """Impulse applied to the actor.""" 272 | 273 | def __init__(self, actor: str, impulse: carla.Vector3D): 274 | """ 275 | 276 | 277 | :param actor: (str) Actor or its ID to whom the command will be applied to. 278 | 279 | :param impulse: (carla.Vector3D) 280 | """ 281 | ... 282 | 283 | 284 | 285 | class ApplyForce: 286 | """ 287 | Command adaptation of add_force() in carla.Actor. Applies a force to an actor. 288 | """ 289 | 290 | actor_id: int 291 | """Actor affected by the command.""" 292 | 293 | force: carla.Vector3D 294 | """Force applied to the actor over time.""" 295 | 296 | def __init__(self, actor: str, force: carla.Vector3D): 297 | """ 298 | 299 | 300 | :param actor: (str) Actor or its ID to whom the command will be applied to. 301 | 302 | :param force: (carla.Vector3D) 303 | """ 304 | ... 305 | 306 | 307 | 308 | class ApplyAngularImpulse: 309 | """ 310 | Command adaptation of add_angular_impulse() in carla.Actor. Applies an angular impulse to an actor. 311 | """ 312 | 313 | actor_id: int 314 | """Actor affected by the command.""" 315 | 316 | impulse: carla.Vector3D 317 | """Angular impulse applied to the actor.""" 318 | 319 | def __init__(self, actor: str, impulse: carla.Vector3D): 320 | """ 321 | 322 | 323 | :param actor: (str) Actor or its ID to whom the command will be applied to. 324 | 325 | :param impulse: (carla.Vector3D) 326 | """ 327 | ... 328 | 329 | 330 | 331 | class ApplyTorque: 332 | """ 333 | Command adaptation of add_torque() in carla.Actor. Applies a torque to an actor. 334 | """ 335 | 336 | actor_id: int 337 | """Actor affected by the command.""" 338 | 339 | torque: carla.Vector3D 340 | """Torque applied to the actor over time.""" 341 | 342 | def __init__(self, actor: str, torque: carla.Vector3D): 343 | """ 344 | 345 | 346 | :param actor: (str) Actor or its ID to whom the command will be applied to. 347 | 348 | :param torque: (carla.Vector3D) 349 | """ 350 | ... 351 | 352 | 353 | 354 | class SetSimulatePhysics: 355 | """ 356 | Command adaptation of set_simulate_physics() in carla.Actor. Determines whether an actor will be affected by physics or not. 357 | """ 358 | 359 | actor_id: int 360 | """Actor affected by the command.""" 361 | 362 | enabled: bool 363 | """If physics should be activated or not.""" 364 | 365 | def __init__(self, actor: str, enabled: bool): 366 | """ 367 | 368 | 369 | :param actor: (str) Actor or its ID to whom the command will be applied to. 370 | 371 | :param enabled: (bool) 372 | """ 373 | ... 374 | 375 | 376 | 377 | class SetAutopilot: 378 | """ 379 | Command adaptation of set_autopilot() in carla.Vehicle. Turns on/off the vehicle's autopilot mode. 380 | """ 381 | 382 | actor_id: int 383 | """Actor that is affected by the command.""" 384 | 385 | enabled: bool 386 | """If autopilot should be activated or not.""" 387 | 388 | port: np.uint16 389 | """Port of the Traffic Manager where the vehicle is to be registered or unlisted.""" 390 | 391 | def __init__(self, actor: str, enabled: bool, port: np.uint16 = 8000): 392 | """ 393 | 394 | 395 | :param actor: (str) Actor or its ID to whom the command will be applied to. 396 | 397 | :param enabled: (bool) 398 | 399 | :param port: (np.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`. 400 | """ 401 | ... 402 | 403 | 404 | 405 | class SetVehicleLightState: 406 | """ 407 | Command adaptation of set_light_state() in carla.Vehicle. Sets the light state of a vehicle. 408 | """ 409 | 410 | actor_id: int 411 | """Actor that is affected by the command.""" 412 | 413 | light_state: carla.VehicleLightState 414 | """Defines the light state of a vehicle.""" 415 | 416 | def __init__(self, actor: str, light_state: carla.VehicleLightState): 417 | """ 418 | 419 | 420 | :param actor: (str) Actor or its ID to whom the command will be applied to. 421 | 422 | :param light_state: (carla.VehicleLightState) Recaps the state of the lights of a vehicle, these can be used as a flags. 423 | """ 424 | ... 425 | 426 | 427 | 428 | class SetEnableGravity: 429 | """ 430 | Command adaptation of set_enable_gravity() in carla.Actor. Enables or disables gravity on an actor. 431 | """ 432 | 433 | actor_id: str 434 | """Actor that is affected by the command.""" 435 | 436 | enabled: bool 437 | """""" 438 | 439 | def __init__(self, actor: str, enabled: bool): 440 | """ 441 | 442 | 443 | :param actor: (str) Actor or Actor ID to which the command will be applied to. 444 | 445 | :param enabled: (bool) 446 | """ 447 | ... 448 | 449 | 450 | 451 | class ShowDebugTelemetry: 452 | """ 453 | Command adaptation of show_debug_telemetry() in carla.Actor. Displays vehicle control telemetry data. 454 | """ 455 | 456 | actor_id: str 457 | """Actor that is affected by the command.""" 458 | 459 | enabled: bool 460 | """""" 461 | 462 | def __init__(self, actor: str, enabled: bool): 463 | """ 464 | 465 | 466 | :param actor: (str) Actor or Actor ID to which the command will be applied to. 467 | 468 | :param enabled: (bool) 469 | """ 470 | ... 471 | 472 | 473 | 474 | -------------------------------------------------------------------------------- /stubs/0.9.15/command.pyi: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import Any 4 | import numpy as np 5 | 6 | import carla 7 | 8 | class Response: 9 | """ 10 | States the result of executing a command as either the ID of the actor to whom the command was applied to (when succeeded) or an error string (when failed). actor ID, depending on whether or not the command succeeded. The method apply_batch_sync() in carla.Client returns a list of these to summarize the execution of a batch. 11 | """ 12 | 13 | actor_id: int 14 | """Actor to whom the command was applied to. States that the command was successful.""" 15 | 16 | error: str 17 | """A string stating the command has failed.""" 18 | 19 | def has_error(self) -> bool: 20 | """ 21 | Returns True if the command execution fails, and False if it was successful. 22 | 23 | :return: bool 24 | """ 25 | ... 26 | 27 | 28 | 29 | class SpawnActor: 30 | """ 31 | Command adaptation of spawn_actor() 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. 32 | """ 33 | 34 | transform: carla.Transform 35 | """Transform to be applied.""" 36 | 37 | parent_id: int 38 | """Identificator of the parent actor.""" 39 | 40 | def __init__(self): 41 | """ 42 | 43 | """ 44 | ... 45 | 46 | def __init__(self, blueprint: carla.ActorBlueprint, transform: carla.Transform): 47 | """ 48 | 49 | 50 | :param blueprint: (carla.ActorBlueprint) 51 | 52 | :param transform: (carla.Transform) 53 | """ 54 | ... 55 | 56 | def __init__(self, blueprint: carla.ActorBlueprint, transform: carla.Transform, parent: str): 57 | """ 58 | 59 | 60 | :param blueprint: (carla.ActorBlueprint) 61 | 62 | :param transform: (carla.Transform) 63 | 64 | :param parent: (str) 65 | """ 66 | ... 67 | 68 | def then(self, command: str): 69 | """ 70 | Links another command to be executed right after. It allows to ease very common flows such as spawning a set of vehicles by command and then using this method to set them to autopilot automatically. 71 | 72 | :param command: (str) a Carla command. 73 | """ 74 | ... 75 | 76 | 77 | 78 | class DestroyActor: 79 | """ 80 | Command adaptation of destroy() in carla.Actor that tells the simulator to destroy this actor. It has no effect if the actor was already destroyed. When executed with apply_batch_sync() in carla.Client there will be a command.Response that will return a boolean stating whether the actor was successfully destroyed. 81 | """ 82 | 83 | actor_id: int 84 | """Actor affected by the command""" 85 | 86 | def __init__(self, actor: str): 87 | """ 88 | 89 | 90 | :param actor: (str) Actor or its ID to whom the command will be applied to. 91 | """ 92 | ... 93 | 94 | 95 | 96 | class ApplyVehiclePhysicsControl: 97 | """ 98 | Command adaptation of apply_physics_control() in carla.Vehicle. Applies a new physics control to a vehicle, modifying its physical parameters. 99 | """ 100 | 101 | actor_id: int 102 | """Vehicle actor affected by the command.""" 103 | 104 | physics_control: carla.VehiclePhysicsControl 105 | """Physics control to be applied.""" 106 | 107 | def __init__(self, actor: str, physics_control: carla.VehiclePhysicsControl): 108 | """ 109 | 110 | 111 | :param actor: (str) Actor or its ID to whom the command will be applied to. 112 | 113 | :param physics_control: (carla.VehiclePhysicsControl) 114 | """ 115 | ... 116 | 117 | 118 | 119 | class ApplyVehicleControl: 120 | """ 121 | Command adaptation of apply_control() in carla.Vehicle. Applies a certain control to a vehicle. 122 | """ 123 | 124 | actor_id: int 125 | """Vehicle actor affected by the command.""" 126 | 127 | control: carla.VehicleControl 128 | """Vehicle control to be applied.""" 129 | 130 | def __init__(self, actor: str, control: carla.VehicleControl): 131 | """ 132 | 133 | 134 | :param actor: (str) Actor or its ID to whom the command will be applied to. 135 | 136 | :param control: (carla.VehicleControl) 137 | """ 138 | ... 139 | 140 | 141 | 142 | class ApplyVehicleAckermannControl: 143 | """ 144 | Command adaptation of apply_ackermann_control() in carla.Vehicle. Applies a certain akermann control to a vehicle. 145 | """ 146 | 147 | actor_id: int 148 | """Vehicle actor affected by the command.""" 149 | 150 | control: carla.AckermannVehicleControl 151 | """Vehicle ackermann control to be applied.""" 152 | 153 | def __init__(self, actor: str, control: carla.AckermannVehicleControl): 154 | """ 155 | 156 | 157 | :param actor: (str) Actor or its ID to whom the command will be applied to. 158 | 159 | :param control: (carla.AckermannVehicleControl) 160 | """ 161 | ... 162 | 163 | 164 | 165 | class ApplyWalkerControl: 166 | """ 167 | Command adaptation of apply_control() in carla.Walker. Applies a control to a walker. 168 | """ 169 | 170 | actor_id: int 171 | """Walker actor affected by the command.""" 172 | 173 | control: carla.WalkerControl 174 | """Walker control to be applied.""" 175 | 176 | def __init__(self, actor: str, control: carla.WalkerControl): 177 | """ 178 | 179 | 180 | :param actor: (str) Actor or its ID to whom the command will be applied to. 181 | 182 | :param control: (carla.WalkerControl) 183 | """ 184 | ... 185 | 186 | 187 | 188 | class ApplyTransform: 189 | """ 190 | Command adaptation of set_transform() in carla.Actor. Sets a new transform to an actor. 191 | """ 192 | 193 | actor_id: int 194 | """Actor affected by the command.""" 195 | 196 | transform: carla.Transform 197 | """Transformation to be applied.""" 198 | 199 | def __init__(self, actor: str, transform: carla.Transform): 200 | """ 201 | 202 | 203 | :param actor: (str) Actor or its ID to whom the command will be applied to. 204 | 205 | :param transform: (carla.Transform) 206 | """ 207 | ... 208 | 209 | 210 | 211 | class ApplyWalkerState: 212 | """ 213 | Apply a state to the walker actor. Specially useful to initialize an actor them with a specific location, orientation and speed. 214 | """ 215 | 216 | actor_id: int 217 | """Walker actor affected by the command.""" 218 | 219 | transform: carla.Transform 220 | """Transform to be applied.""" 221 | 222 | speed: float 223 | """Speed to be applied.""" 224 | 225 | def __init__(self, actor: str, transform: carla.Transform, speed: float): 226 | """ 227 | 228 | 229 | :param actor: (str) Actor or its ID to whom the command will be applied to. 230 | 231 | :param transform: (carla.Transform) 232 | 233 | :param speed: (float) 234 | """ 235 | ... 236 | 237 | 238 | 239 | class ApplyTargetVelocity: 240 | """ 241 | Command adaptation of set_target_velocity() in carla.Actor. 242 | """ 243 | 244 | actor_id: int 245 | """Actor affected by the command.""" 246 | 247 | velocity: carla.Vector3D 248 | """The 3D velocity applied to the actor.""" 249 | 250 | def __init__(self, actor: str, velocity: carla.Vector3D): 251 | """ 252 | 253 | 254 | :param actor: (str) Actor or its ID to whom the command will be applied to. 255 | 256 | :param velocity: (carla.Vector3D) Velocity vector applied to the actor. 257 | """ 258 | ... 259 | 260 | 261 | 262 | class ApplyTargetAngularVelocity: 263 | """ 264 | Command adaptation of set_target_angular_velocity() in carla.Actor. Sets the actor's angular velocity vector. 265 | """ 266 | 267 | actor_id: int 268 | """Actor affected by the command.""" 269 | 270 | angular_velocity: carla.Vector3D 271 | """The 3D angular velocity that will be applied to the actor.""" 272 | 273 | def __init__(self, actor: str, angular_velocity: carla.Vector3D): 274 | """ 275 | 276 | 277 | :param actor: (str) Actor or its ID to whom the command will be applied to. 278 | 279 | :param angular_velocity: (carla.Vector3D) Angular velocity vector applied to the actor. 280 | """ 281 | ... 282 | 283 | 284 | 285 | class ApplyImpulse: 286 | """ 287 | Command adaptation of add_impulse() in carla.Actor. Applies an impulse to an actor. 288 | """ 289 | 290 | actor_id: int 291 | """Actor affected by the command.""" 292 | 293 | impulse: carla.Vector3D 294 | """Impulse applied to the actor.""" 295 | 296 | def __init__(self, actor: str, impulse: carla.Vector3D): 297 | """ 298 | 299 | 300 | :param actor: (str) Actor or its ID to whom the command will be applied to. 301 | 302 | :param impulse: (carla.Vector3D) 303 | """ 304 | ... 305 | 306 | 307 | 308 | class ApplyForce: 309 | """ 310 | Command adaptation of add_force() in carla.Actor. Applies a force to an actor. 311 | """ 312 | 313 | actor_id: int 314 | """Actor affected by the command.""" 315 | 316 | force: carla.Vector3D 317 | """Force applied to the actor over time.""" 318 | 319 | def __init__(self, actor: str, force: carla.Vector3D): 320 | """ 321 | 322 | 323 | :param actor: (str) Actor or its ID to whom the command will be applied to. 324 | 325 | :param force: (carla.Vector3D) 326 | """ 327 | ... 328 | 329 | 330 | 331 | class ApplyAngularImpulse: 332 | """ 333 | Command adaptation of add_angular_impulse() in carla.Actor. Applies an angular impulse to an actor. 334 | """ 335 | 336 | actor_id: int 337 | """Actor affected by the command.""" 338 | 339 | impulse: carla.Vector3D 340 | """Angular impulse applied to the actor.""" 341 | 342 | def __init__(self, actor: str, impulse: carla.Vector3D): 343 | """ 344 | 345 | 346 | :param actor: (str) Actor or its ID to whom the command will be applied to. 347 | 348 | :param impulse: (carla.Vector3D) 349 | """ 350 | ... 351 | 352 | 353 | 354 | class ApplyTorque: 355 | """ 356 | Command adaptation of add_torque() in carla.Actor. Applies a torque to an actor. 357 | """ 358 | 359 | actor_id: int 360 | """Actor affected by the command.""" 361 | 362 | torque: carla.Vector3D 363 | """Torque applied to the actor over time.""" 364 | 365 | def __init__(self, actor: str, torque: carla.Vector3D): 366 | """ 367 | 368 | 369 | :param actor: (str) Actor or its ID to whom the command will be applied to. 370 | 371 | :param torque: (carla.Vector3D) 372 | """ 373 | ... 374 | 375 | 376 | 377 | class SetSimulatePhysics: 378 | """ 379 | Command adaptation of set_simulate_physics() in carla.Actor. Determines whether an actor will be affected by physics or not. 380 | """ 381 | 382 | actor_id: int 383 | """Actor affected by the command.""" 384 | 385 | enabled: bool 386 | """If physics should be activated or not.""" 387 | 388 | def __init__(self, actor: str, enabled: bool): 389 | """ 390 | 391 | 392 | :param actor: (str) Actor or its ID to whom the command will be applied to. 393 | 394 | :param enabled: (bool) 395 | """ 396 | ... 397 | 398 | 399 | 400 | class SetAutopilot: 401 | """ 402 | Command adaptation of set_autopilot() in carla.Vehicle. Turns on/off the vehicle's autopilot mode. 403 | """ 404 | 405 | actor_id: int 406 | """Actor that is affected by the command.""" 407 | 408 | enabled: bool 409 | """If autopilot should be activated or not.""" 410 | 411 | port: np.uint16 412 | """Port of the Traffic Manager where the vehicle is to be registered or unlisted.""" 413 | 414 | def __init__(self, actor: str, enabled: bool, port: np.uint16 = 8000): 415 | """ 416 | 417 | 418 | :param actor: (str) Actor or its ID to whom the command will be applied to. 419 | 420 | :param enabled: (bool) 421 | 422 | :param port: (np.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`. 423 | """ 424 | ... 425 | 426 | 427 | 428 | class SetVehicleLightState: 429 | """ 430 | Command adaptation of set_light_state() in carla.Vehicle. Sets the light state of a vehicle. 431 | """ 432 | 433 | actor_id: int 434 | """Actor that is affected by the command.""" 435 | 436 | light_state: carla.VehicleLightState 437 | """Defines the light state of a vehicle.""" 438 | 439 | def __init__(self, actor: str, light_state: carla.VehicleLightState): 440 | """ 441 | 442 | 443 | :param actor: (str) Actor or its ID to whom the command will be applied to. 444 | 445 | :param light_state: (carla.VehicleLightState) Recaps the state of the lights of a vehicle, these can be used as a flags. 446 | """ 447 | ... 448 | 449 | 450 | 451 | class SetEnableGravity: 452 | """ 453 | Command adaptation of set_enable_gravity() in carla.Actor. Enables or disables gravity on an actor. 454 | """ 455 | 456 | actor_id: str 457 | """Actor that is affected by the command.""" 458 | 459 | enabled: bool 460 | """""" 461 | 462 | def __init__(self, actor: str, enabled: bool): 463 | """ 464 | 465 | 466 | :param actor: (str) Actor or Actor ID to which the command will be applied to. 467 | 468 | :param enabled: (bool) 469 | """ 470 | ... 471 | 472 | 473 | 474 | class ShowDebugTelemetry: 475 | """ 476 | Command adaptation of show_debug_telemetry() in carla.Actor. Displays vehicle control telemetry data. 477 | """ 478 | 479 | actor_id: str 480 | """Actor that is affected by the command.""" 481 | 482 | enabled: bool 483 | """""" 484 | 485 | def __init__(self, actor: str, enabled: bool): 486 | """ 487 | 488 | 489 | :param actor: (str) Actor or Actor ID to which the command will be applied to. 490 | 491 | :param enabled: (bool) 492 | """ 493 | ... 494 | 495 | 496 | 497 | --------------------------------------------------------------------------------