### Run CARLA Example Scripts Source: https://carla-ue5.readthedocs.io/en/latest/start_quickstart Instructions to run example Python scripts for CARLA. This involves navigating to the examples directory, installing requirements, and executing scripts for traffic generation and manual control. ```bash # Terminal A cd PythonAPI\examples pip3 install -r requirements.txt python3 generate_traffic.py # Terminal B cd PythonAPI\examples python3 manual_control.py ``` -------------------------------- ### Install CARLA Python Client Library Source: https://carla-ue5.readthedocs.io/en/latest/start_quickstart Installs the CARLA client library from a pre-compiled wheel file. It's recommended to install this within a virtual environment to prevent version conflicts. ```bash cd CARLA_ROOT/PythonAPI/dist/ pip3 install carla-*.*.*-cp3**-linux_x86_64.whl ``` -------------------------------- ### Install CARLA Python Dependencies Source: https://carla-ue5.readthedocs.io/en/latest/start_quickstart Installs essential Python packages like pygame and numpy, which are required for the CARLA client library and example scripts. The installation command is the same for both Windows and Linux. ```bash pip3 install --user pygame numpy ``` -------------------------------- ### Connect to CARLA Client and Get World Object Source: https://carla-ue5.readthedocs.io/en/latest/tuto_G_getting_started Establishes a connection to the CARLA server on localhost:2000 and retrieves the simulation world object. This is the initial step to interact with the CARLA simulator via its Python API. ```python import carla import random # Connect to the client and retrieve the world object client = carla.Client('localhost', 2000) world = client.get_world() ``` -------------------------------- ### Check and Upgrade Pip Source: https://carla-ue5.readthedocs.io/en/latest/start_quickstart Verifies the current version of pip for Python 3 and provides a command to upgrade it if necessary. This ensures compatibility with CARLA's Python client library installation. ```bash # For Python 3 pip3 -V ``` ```bash # For Python 3 pip3 install --upgrade pip ``` -------------------------------- ### Run CARLA Simulator Source: https://carla-ue5.readthedocs.io/en/latest/start_quickstart Commands to launch the CARLA simulator executable on both Linux and Windows systems. After execution, a spectator view window will appear, and the server will be ready to accept client connections. ```bash cd path/to/carla/root ./CarlaUnreal.sh ``` ```bash cd path/to/carla/root CarlaUnreal.exe ``` -------------------------------- ### Run CARLA UE5 Setup Script (Interactive) Source: https://carla-ue5.readthedocs.io/en/latest/build_linux_ue5 Executes the CARLA setup script in interactive mode within the CARLA UE5 project directory. This script installs prerequisites, prompts for sudo password, and requests GitHub credentials for downloading the Unreal Engine repository. ```shell cd CarlaUE5 ./CarlaSetup.sh --interactive ``` -------------------------------- ### Run CARLA Setup Script Source: https://carla-ue5.readthedocs.io/en/latest/build_windows_ue5 Executes the CarlaSetup.bat script to install required packages, download CARLA content, and build CARLA. This script installs Visual Studio 2022, Cmake, Python 3.8 packages, and Unreal Engine 5.5. It may take a significant amount of time to complete. ```batch cd CarlaUE5 CarlaSetup.bat ``` -------------------------------- ### Run CARLA Docker Container (With Display) Source: https://carla-ue5.readthedocs.io/en/latest/start_quickstart Launches the CARLA Docker image with graphical display support using the X11 protocol. This command maps the host's X11 socket into the container, allowing CARLA to render its output. It also configures environment variables for NVIDIA GPUs and ensures proper user permissions. ```bash docker run \ --runtime=nvidia \ --net=host \ --user=$(id -u):$(id -g) \ --env=DISPLAY=$DISPLAY \ --env=NVIDIA_VISIBLE_DEVICES=all \ --env=NVIDIA_DRIVER_CAPABILITIES=all \ --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ carlasim/carla:0.10.0 bash CarlaUnreal.sh -nosound ``` -------------------------------- ### Specify Python Installation Path for CARLA Setup Source: https://carla-ue5.readthedocs.io/en/latest/build_linux_ue5 Demonstrates how to use the '--python-root' argument with the CarlaSetup.sh script to target a specific Python installation. This is useful if you have multiple Python versions or a custom installation. ```shell # Example: Assuming python3 is located at /usr/bin/python3 cd CarlaUE5 ./CarlaSetup.sh --python-root=/usr ``` -------------------------------- ### CARLA Client Map Management Source: https://carla-ue5.readthedocs.io/en/latest/tuto_G_getting_started Demonstrates how to manage maps within the CARLA simulation using the client object. It includes fetching available maps, loading a new map, and reloading the current map to reset the simulation state. ```python # Print available maps client.get_available_maps() # Load new map client.load_world('Town07') # Reload current map and reset state client.reload_world() ``` -------------------------------- ### Get CARLA Map Spawn Points Source: https://carla-ue5.readthedocs.io/en/latest/tuto_G_getting_started Retrieves a list of predefined spawn points available for the currently loaded map in CARLA. These points are typically distributed evenly and are useful for populating the simulation with NPCs. ```python # Get the map's spawn points spawn_points = world.get_map().get_spawn_points() # Get the blueprint library and filter for the vehicle blueprints vehicle_bps = world.get_blueprint_library().filter('*vehicle*') ``` -------------------------------- ### Iterate and print all available CARLA blueprints Source: https://carla-ue5.readthedocs.io/en/latest/tuto_G_getting_started Accesses the CARLA blueprint library and iterates through all available actor blueprints, printing each one to the console. This is useful for understanding the range of available objects in the simulation. ```python # Print all available blueprints for actor in world.get_blueprint_library(): print(actor) ``` -------------------------------- ### Run CARLA UE5 Setup Script (Unattended) Source: https://carla-ue5.readthedocs.io/en/latest/build_linux_ue5 Runs the CARLA setup script in an unattended mode using pre-configured Git credentials stored in an environment variable. This command installs prerequisites, downloads Unreal Engine, and builds CARLA. ```shell cd CarlaUE5 sudo -E ./CarlaSetup.sh ``` -------------------------------- ### Run CARLA Docker Container (No Display) Source: https://carla-ue5.readthedocs.io/en/latest/start_quickstart Executes the CARLA Docker image without rendering to a display. This is suitable for headless environments like servers or cloud instances. It requires the NVIDIA container runtime and specifies network and environment variables for GPU visibility and capabilities. ```bash docker run \ --runtime=nvidia \ --net=host \ --env=NVIDIA_VISIBLE_DEVICES=all \ --env=NVIDIA_DRIVER_CAPABILITIES=all \ carlasim/carla:0.10.0 bash CarlaUnreal.sh -RenderOffScreen -nosound ``` -------------------------------- ### CARLA Spectator API: Get and Set Transform Source: https://carla-ue5.readthedocs.io/en/latest/tuto_G_getting_started Demonstrates how to retrieve and manipulate the spectator's position and orientation in the CARLA simulation. It includes getting the current transform and setting it to a default or custom one. ```python # Retrieve the spectator object spectator = world.get_spectator() # Get the location and rotation of the spectator through its transform transform = spectator.get_transform() location = transform.location rotation = transform.rotation # Set the spectator with an empty transform spectator.set_transform(carla.Transform()) # This will set the spectator at the origin of the map, with 0 degrees # pitch, yaw and roll - a good way to orient yourself in the map ``` -------------------------------- ### Run CARLA Benchmark Script Examples Source: https://carla-ue5.readthedocs.io/en/latest/adv_benchmarking Examples demonstrating how to execute the CARLA performance benchmark script with different configurations. These commands can be run from the PythonAPI/util directory. ```bash python3 performance_benchmark.py --show_scenarios ``` ```bash python3 performance_benchmark.py --sensors 2 5 --maps Town03 Town05 --weather 0 1 --show_scenarios ``` ```bash python3 performance_benchmark.py --sensors 2 5 --maps Town03 Town05 --weather 0 1 ``` ```bash python3 performance_benchmark.py --async --render_mode ``` -------------------------------- ### CARLA Client Setup and Control Source: https://carla-ue5.readthedocs.io/en/latest/foundations Establishes a connection to the CARLA server and provides methods to load maps and start recording simulation data. It requires the server to be running on the specified IP and port. ```python client = carla.Client('localhost', 2000) client.load_world('Town07') client.start_recorder('recording.log') ``` -------------------------------- ### Run Traffic Generation Example Source: https://carla-ue5.readthedocs.io/en/latest/adv_traffic_manager Executes the `generate_traffic.py` example script to start a TM and populate the CARLA map with vehicles and pedestrians. This script automatically configures the TM and CARLA server for synchronous mode. The `--async` flag can be used to enable asynchronous mode. ```bash cd PythonAPI/examples python3 generate_traffic.py -n 50 ``` -------------------------------- ### Start Camera Recording Source: https://carla-ue5.readthedocs.io/en/latest/tuto_first_steps Configures the attached camera sensor to start recording by providing a callback function. This lambda function saves each captured image to disk with a frame-based naming convention. ```Python # Start camera with PyGame callback camera.listen(lambda image: image.save_to_disk('out/%06d.png' % image.frame)) ``` -------------------------------- ### Install Benchmarking Dependencies Source: https://carla-ue5.readthedocs.io/en/latest/adv_benchmarking Installs the necessary Python packages for running the CARLA performance benchmark. Ensure you have Python installed and pip available. ```bash python -m pip install -U py-cpuinfo==5.0.0 psutil python-tr gpuinfo GPUtil ``` -------------------------------- ### Visualize and select specific spawn points Source: https://carla-ue5.readthedocs.io/en/latest/tuto_G_getting_started Retrieves all spawn points from the current CARLA map and visualizes each one in the spectator window using debug strings for indices and arrows for orientation. This allows for manual selection of spawn points. ```python # Get the map spawn points spawn_points = world.get_map().get_spawn_points() for i, spawn_point in enumerate(spawn_points): # Draw in the spectator window the spawn point index world.debug.draw_string(spawn_point.location, str(i), life_time=100) # We can also draw an arrow to see the orientation of the spawn point # (i.e. which way the vehicle will be facing when spawned) world.debug.draw_arrow(spawn_point.location, spawn_point.location + spawn_point.get_forward_vector(), life_time=100) ``` -------------------------------- ### CARLA World Object Queries Source: https://carla-ue5.readthedocs.io/en/latest/tuto_G_getting_started Shows how to query and access various elements within the CARLA simulation environment using the world object. This includes retrieving all object names, filtering for specific types like buildings, and listing all actors (vehicles, pedestrians, traffic lights). ```python # Get names of all objects world.get_names_of_all_objects() # Filter the list of names for buildings filter(lambda x: 'Building' in x, world.get_names_of_all_objects()) # Get a list of all actors, such as vehicles and pedestrians world.get_actors() # Filter the list to find the vehicles world.get_actors().filter('*vehicle*') ``` -------------------------------- ### Install MkDocs for Documentation Source: https://carla-ue5.readthedocs.io/en/latest/cont_contribution_guidelines Installs the MkDocs static site generator, which is used to build the CARLA documentation. This command uses pip, the Python package installer. ```shell sudo pip install mkdocs ``` -------------------------------- ### Run Carla Example Script Source: https://carla-ue5.readthedocs.io/en/latest/adv_agents Command-line instructions to run the `automatic_control.py` example script. It allows specifying either a 'Basic' or 'Behavior' agent, with options for behavior types. ```bash # To run with a basic agent python3 automatic_control.py --agent=Basic # To run with a behavior agent python3 automatic_control.py --agent=Behavior --behavior=aggressive ``` -------------------------------- ### Running Example Script Source: https://carla-ue5.readthedocs.io/en/latest/adv_agents Command to run the `automatic_control.py` example script with different agent types. ```APIDOC ## Running Example Script ### Description Demonstrates how to execute the `automatic_control.py` example script to test both Basic and Behavior Agents. You can specify the agent type and, for the Behavior Agent, a specific behavior profile. ### Method Command Line Execution ### Endpoint N/A ### Parameters #### Command Line Arguments * `--agent` (string): Specify the agent type, e.g., `Basic` or `Behavior`. * `--behavior` (string): (Optional) For `Behavior` agent, specify the profile, e.g., `aggressive`, `normal`, `cautious`. ### Request Example ```bash # To run with a basic agent python3 automatic_control.py --agent=Basic # To run with a behavior agent (aggressive profile) python3 automatic_control.py --agent=Behavior --behavior=aggressive ``` ### Response #### Success Response (200) N/A (Script execution) #### Response Example N/A ``` -------------------------------- ### Serve CARLA Documentation Locally Source: https://carla-ue5.readthedocs.io/en/latest/cont_contribution_guidelines Starts a local web server to preview the CARLA documentation. The documentation can then be viewed in a web browser at the provided URL. ```shell mkdocs serve ``` -------------------------------- ### Print Spectator Transform in CARLA Source: https://carla-ue5.readthedocs.io/en/latest/tuto_G_getting_started Prints the current transform (location and rotation) of the CARLA spectator to the console. This allows for manual recording or logging of specific viewpoints within the simulation. ```python print(spectator.get_transform()) >>> Transform(Location(x=25.761623, y=13.169240, z=0.539901), Rotation(pitch=0.862031, yaw=-2.056274, roll=0.000069)) ``` -------------------------------- ### Spawn Vehicle Actor in CARLA Source: https://carla-ue5.readthedocs.io/en/latest/tuto_G_getting_started Spawns a vehicle actor into the CARLA simulation world. This is a standard spawn method that may fail if the location is occupied or invalid. It requires a blueprint for the vehicle and a spawn point transform. ```python world.spawn_actor(vehicle_bp, spawn_point) ``` -------------------------------- ### Start CARLA Server Source: https://carla-ue5.readthedocs.io/en/latest/adv_benchmarking Commands to launch the CARLA Unreal Engine 5 simulator. Choose the command based on your operating system or build method. ```bash # Linux: ./CarlaUnreal.sh # Windows: CarlaUnreal.exe # Source: cmake --build Build --target launch ``` -------------------------------- ### Install CARLA UE5 Prerequisites Source: https://carla-ue5.readthedocs.io/en/latest/build_linux_ue5 Installs necessary system packages for building CARLA UE5, including essential build tools, Vulkan, Python, and Git. ```bash sudo apt update sudo apt install build-essential ninja-build libvulkan1 python3 python3-dev python3-pip git git-lfs ``` -------------------------------- ### Spawn CARLA Vehicle Actor Source: https://carla-ue5.readthedocs.io/en/latest/tuto_G_getting_started Details the process of spawning a vehicle actor in the CARLA simulation. It involves obtaining a vehicle blueprint from the library, selecting a random blueprint, and choosing a random spawn point from the map's predefined locations. ```python # Get the blueprint library and filter for the vehicle blueprints vehicle_bps = world.get_blueprint_library().filter('*vehicle*') # Randomly choose a vehicle blueprint to spawn vehicle_bp = random.choice(vehicle_bps) # We need a place to spawn the vehicle that will work so we will # use the predefined spawn points for the map and randomly select one spawn_point = random.choice(world.get_map().get_spawn_points()) ``` -------------------------------- ### Spawn vehicles at specific indexed spawn points Source: https://carla-ue5.readthedocs.io/en/latest/tuto_G_getting_started Spawns vehicles using a predefined list of spawn point indices. This allows for targeted vehicle placement, useful for creating congestion in specific areas. ```python for ind in [89, 95, 99, 102, 103, 104, 110, 111, 115, 126, 135, 138, 139, 140, 141]: world.try_spawn_actor(random.choice(vehicle_bps), spawn_points[ind]) ``` -------------------------------- ### Start Simulation Recording Source: https://carla-ue5.readthedocs.io/en/latest/foundations Starts the simulation recording to a specified log file. By default, it saves only the necessary data for playback. ```python client.start_recorder("/home/carla/recording01.log") ``` -------------------------------- ### Replay Simulation from Log File Source: https://carla-ue5.readthedocs.io/en/latest/foundations Starts a simulation playback from a specified log file. It allows setting a start time, duration, and a camera actor to focus on during playback. ```python client.replay_file("recording01.log", start, duration, camera) ``` -------------------------------- ### Spawn 50 vehicles randomly distributed throughout the map Source: https://carla-ue5.readthedocs.io/en/latest/tuto_G_getting_started Spawns 50 vehicles at random locations across the CARLA map. It utilizes random choices for both vehicle blueprints and spawn points. ```python for i in range(0,50): world.try_spawn_actor(random.choice(vehicle_bps, random.choice(spawn_points))) ``` -------------------------------- ### Filter and print vehicle blueprints from CARLA library Source: https://carla-ue5.readthedocs.io/en/latest/tuto_G_getting_started Filters the CARLA blueprint library to specifically retrieve and print blueprints for vehicles. It then finds a specific vehicle blueprint ('vehicle.audi.tt') for potential use in spawning. ```python # Print all available vehicle blueprints for actor in world.get_blueprint_library().filter('vehicle'): print(actor) vehicle_blueprint = world.get_blueprint_library().find('vehicle.audi.tt') ``` -------------------------------- ### Spawn 100 vehicles randomly throughout the map Source: https://carla-ue5.readthedocs.io/en/latest/tuto_G_getting_started Spawns 100 vehicles by randomly selecting both the vehicle blueprint and a spawn point from the available list. This is a simple method for populating the map with vehicles. ```python for ind in range(0, 100): world.try_spawn_actor(random.choice(vehicle_bps), random.choice(spawn_points)) ``` -------------------------------- ### Retrieve CARLA World Snapshot Source: https://carla-ue5.readthedocs.io/en/latest/core_world Provides an example of how to get a snapshot of the entire CARLA simulation world at the current frame. This includes timestamp information and states of all actors. ```python # Retrieve a snapshot of the world at current frame. world_snapshot = world.get_snapshot()) ``` -------------------------------- ### Fault-Tolerant Vehicle Spawning in CARLA Source: https://carla-ue5.readthedocs.io/en/latest/tuto_G_getting_started Attempts to spawn a vehicle actor, returning None if the spawn fails. This method is safer as it prevents crashes due to invalid spawn locations or conflicts. It returns a reference to the spawned vehicle upon success. ```python vehicle = world.try_spawn_actor(vehicle_bp, spawn_point) ``` -------------------------------- ### Build and Install CARLA Python API Source: https://carla-ue5.readthedocs.io/en/latest/build_windows_ue5 Builds and installs the CARLA Python API. This command ensures that the Python interface for CARLA is built and made available for use. It requires running from the CarlaUE5 folder in an x64 Native Tools Command Prompt for VS 2022. ```bash cmake --build Build --target carla-python-api-install ``` -------------------------------- ### Spawn Vehicle at Spectator's Location in CARLA Source: https://carla-ue5.readthedocs.io/en/latest/tuto_G_getting_started Spawns a vehicle actor at the current location and rotation of the CARLA spectator. This is useful for precisely placing actors in the simulation based on visual placement. ```python vehicle = world.try_spawn_actor(vehicle_bp, spectator.get_transform()) ``` -------------------------------- ### Install Doxygen and Graphviz Source: https://carla-ue5.readthedocs.io/en/latest/ref_cpp Command to install Doxygen and Graphviz on a Linux system, which are required for generating C++ documentation and graph drawing. ```shell sudo apt-get install doxygen graphviz ``` -------------------------------- ### Install CARLA Simulator (Python) Source: https://carla-ue5.readthedocs.io/en/latest/foundations Installs the CARLA simulator module for Python 2 and Python 3 using pip. This is a prerequisite for using the CARLA Python API. ```shell pip install carla-simulator # Python 2 pip3 install carla-simulator # Python 3 ``` -------------------------------- ### CARLA Server Interaction Source: https://carla-ue5.readthedocs.io/en/latest/foundations Demonstrates how to interact with the CARLA server using the client object, including loading maps and starting the simulation recorder. ```APIDOC ## CARLA Server Interaction ### Description Shows examples of interacting with the CARLA server using the client object. This includes loading a new simulation map and starting the built-in recorder. ### Method `load_world`, `start_recorder` ### Endpoint N/A (Client-side methods) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python # Assuming 'client' is an initialized carla.Client object # Load a specific map client.load_world('Town07') # Start recording the simulation to a log file client.start_recorder('recording.log') ``` ### Response #### Success Response (200) N/A (Client-side operations) #### Response Example N/A ``` -------------------------------- ### Run CARLA UE5 Setup Script (Unattended with Terminal Credentials) Source: https://carla-ue5.readthedocs.io/en/latest/build_linux_ue5 Executes the CARLA setup script in unattended mode, providing Git credentials directly in the terminal command. This is an alternative to storing credentials in .bashrc. ```shell cd CarlaUE5 sudo -E env GIT_LOCAL_CREDENTIALS=github_username@github_token ./CarlaSetup.sh ``` -------------------------------- ### Install CARLA UE5 Python API Wheel Source: https://carla-ue5.readthedocs.io/en/latest/build_linux_ue5 Installs the Python API for a built CARLA UE5 package using pip. The `***` indicates a version number. ```bash pip3 install PythonAPI/dist/carla-***.whl ``` -------------------------------- ### Start Recording Source: https://carla-ue5.readthedocs.io/en/latest/adv_recorder Starts the recorder to save simulation data to a binary file. An optional boolean argument enables additional data logging. ```APIDOC ## POST /api/recorder/start ### Description Starts the CARLA simulation recorder. Data is saved to a binary file on the server side. By default, only essential data for playback is stored. Setting `additional_data` to `True` logs more detailed information. ### Method POST ### Endpoint `/api/recorder/start` ### Parameters #### Query Parameters - **filename** (string) - Required - The name of the file to save the recording to. Absolute paths can be specified. - **additional_data** (boolean) - Optional - If `True`, logs detailed information like velocities, traffic light timings, and physics controls. Defaults to `False`. ### Request Example ```json { "filename": "/home/carla/recording01.log", "additional_data": true } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "Recorder started successfully." } ``` ``` -------------------------------- ### Start CARLA Recording (Python) Source: https://carla-ue5.readthedocs.io/en/latest/adv_recorder This script initiates the recording process in CARLA. It allows specifying the output filename, the number of vehicles to spawn at the start, and the duration of the recording. ```python import carla def start_recording(filename, num_vehicles=10, duration=None): client = carla.Client('localhost', 2000) client.set_timeout(2.0) world = client.get_world() # Start recording try: client.start_recorder(filename, True) print(f"Recording started to '{filename}'.") # Optionally spawn vehicles if num_vehicles > 0: blueprint_library = world.get_blueprint_library() vehicle_bp = blueprint_library.find('vehicle.tesla.model3') spawn_point = carla.Transform(carla.Location(x=100, y=100, z=2), carla.Rotation(yaw=0)) for _ in range(num_vehicles): world.spawn_actor(vehicle_bp, spawn_point) print(f"{num_vehicles} vehicles spawned.") # Record for a specific duration if specified if duration: import time time.sleep(duration) client.stop_recorder() print(f"Recording stopped after {duration} seconds.") except Exception as e: print(f"An error occurred: {e}") if __name__ == '__main__': # Example usage: # start_recording('my_recording.log', num_vehicles=5, duration=30) # For default usage (infinite recording until stopped manually): # start_recording('continuous_recording.log') print("To run this script, uncomment and modify the example usage in the __main__ block.") ``` -------------------------------- ### Start Simulation Recording with Additional Data Source: https://carla-ue5.readthedocs.io/en/latest/foundations Starts the simulation recording with the 'additional_data' flag set to True. This saves all previously mentioned information, including velocities, traffic light settings, and actor bounding boxes. ```python client.start_recorder("/home/carla/recording01.log", True) ``` -------------------------------- ### CARLA Waypoint: Get waypoints until lane start Source: https://carla-ue5.readthedocs.io/en/latest/python_api Returns a list of waypoints from the current waypoint to the start of the lane, with a specified distance between each waypoint. This method does not account for lane changes. ```python waypoint.previous_until_lane_start(distance: float) -> list[carla.Waypoint] ``` -------------------------------- ### Get Elapsed Time - CARLA Source: https://carla-ue5.readthedocs.io/en/latest/python_api Gets the time in seconds since the current traffic light state started, based on the last tick. This method does not call the simulator and returns a float. ```python traffic_light.get_elapsed_time() ``` -------------------------------- ### Example PASCAL VOC format XML structure Source: https://carla-ue5.readthedocs.io/en/latest/tuto_G_bounding_boxes This is an example of an XML file generated in the PASCAL VOC format, commonly used for object detection datasets. It includes information about the image source, dimensions, and individual objects with their bounding box coordinates. ```xml output 023235.png /home/matt/Documents/temp/output/023235.png Unknown 800 600 3 0 vehicle Unspecified 0 0 503 310 511 321 vehicle Unspecified 0 0 490 310 498 321 ``` -------------------------------- ### Generate Doxygen Documentation Source: https://carla-ue5.readthedocs.io/en/latest/ref_cpp Command to run Doxygen from the project root folder to generate C++ documentation. Doxygen must be installed, and the _Doxyfile_ must be present. ```shell > doxygen ``` -------------------------------- ### Run Multi-Simulation Setup Source: https://carla-ue5.readthedocs.io/en/latest/adv_traffic_manager Shows how to run multiple CARLA simulations in parallel, each with its own TM-Server. This setup is independent of the TM itself, allowing for distinct simulation environments to be managed concurrently. ```bash terminal 1: ./CarlaUnreal.sh -carla-rpc-port=4000 # simulation A ``` ```bash terminal 2: ./CarlaUnreal.sh -carla-rpc-port=5000 # simulation B ``` ```bash terminal 3: python3 generate_traffic.py --port 4000 --tm-port 4050 # TM-Server A connected to simulation A ``` ```bash terminal 4: python3 generate_traffic.py --port 5000 --tm-port 5050 # TM-Server B connected to simulation B ``` -------------------------------- ### Get Crosswalks Source: https://carla-ue5.readthedocs.io/en/latest/python_api Returns a list of crosswalk zones as closed polygons. The first point is repeated to signify the start and end of the polygon. ```APIDOC ## GET /crosswalks ### Description Returns a list of crosswalk zones as closed polygons. The first point is repeated to signify the start and end of the polygon. ### Method GET ### Endpoint /crosswalks ### Response #### Success Response (200) - **crosswalks** (list(carla.Location)) - A list of carla.Location objects representing crosswalk zones. ``` -------------------------------- ### Get Vehicle Blueprints Source: https://carla-ue5.readthedocs.io/en/latest/tuto_first_steps Retrieves all vehicle blueprints from the CARLA blueprint library, which are used to spawn vehicles in the simulation. ```Python vehicle_blueprints = world.get_blueprint_library().filter('*vehicle*') ``` -------------------------------- ### CARLA Recorder API Source: https://carla-ue5.readthedocs.io/en/latest/foundations Documentation for the CARLA recorder, including starting, stopping, and replaying simulation recordings. ```APIDOC ## CARLA Recorder API ### Description The CARLA recorder allows saving simulation data to a binary file for later reproduction. It captures actor information, traffic light states, weather conditions, and more. Recordings can be started, stopped, and replayed with specific parameters. ### Start Recording #### Method `client.start_recorder(filename, additional_data=False)` #### Endpoint N/A (Client-side function) #### Parameters - **filename** (str) - Required - The name or absolute path of the file to save the recording. - **additional_data** (bool) - Optional - If True, saves additional data like velocities, traffic light timings, etc. Defaults to False. #### Request Example ```python # Start recording with default settings client.start_recorder("/home/carla/recording01.log") # Start recording with additional data client.start_recorder("/home/carla/recording01.log", True) ``` ### Stop Recording #### Method `client.stop_recorder()` #### Endpoint N/A (Client-side function) #### Parameters None #### Request Example ```python client.stop_recorder() ``` ### Replay File #### Method `client.replay_file(filename, start, duration, camera)` #### Endpoint N/A (Client-side function) #### Parameters - **filename** (str) - Required - The path to the recording log file. - **start** (int) - Required - The recording time in seconds to start playback. Positive for start, negative for end. - **duration** (int) - Required - The duration in seconds to playback. 0 means playback the entire recording. - **camera** (int) - Optional - The ID of the actor for the spectator camera to focus on. `0` allows free movement. #### Request Example ```python # Replay the entire recording starting from the beginning, free camera movement client.replay_file("recording01.log", 0, 0, 0) # Replay 30 seconds of recording starting from 10 seconds in client.replay_file("recording01.log", 10, 30, 0) ``` ### Recorder File Format #### Description The recorder saves data in a custom binary file format. Refer to the official CARLA documentation for detailed specifications. ``` -------------------------------- ### Get Waypoints for a CARLA Junction Source: https://carla-ue5.readthedocs.io/en/latest/core_map Retrieves a pair of waypoints for each lane within a CARLA junction. These waypoints mark the start and end points of the junction boundaries. ```python waypoints_junc = my_junction.get_waypoints() ``` -------------------------------- ### CARLA Simulator Setup with Synchronous Mode Source: https://carla-ue5.readthedocs.io/en/latest/tuto_G_bounding_boxes Initializes the CARLA client, world, and blueprint library. Spawns a vehicle and an RGB camera, attaches the camera to the vehicle, and sets the simulator to synchronous mode with a fixed time step. It also sets up a listener for the camera's data. ```python import carla import math import random import time import queue import numpy as np import cv2 client = carla.Client('localhost', 2000) world = client.get_world() bp_lib = world.get_blueprint_library() # spawn vehicle vehicle_bp =bp_lib.find('vehicle.lincoln.mkz_2020') vehicle = world.try_spawn_actor(vehicle_bp, random.choice(spawn_points)) # spawn camera camera_bp = bp_lib.find('sensor.camera.rgb') camera_init_trans = carla.Transform(carla.Location(z=2)) camera = world.spawn_actor(camera_bp, camera_init_trans, attach_to=vehicle) vehicle.set_autopilot(True) # Set up the simulator in synchronous mode settings = world.get_settings() settings.synchronous_mode = True # Enables synchronous mode settings.fixed_delta_seconds = 0.05 world.apply_settings(settings) # Get the map spawn points spawn_points = world.get_map().get_spawn_points() # Create a queue to store and retrieve the sensor data image_queue = queue.Queue() camera.listen(image_queue.put) ``` -------------------------------- ### Client Creation and Configuration Source: https://carla-ue5.readthedocs.io/en/latest/core_world Demonstrates how to create a CARLA client, set its timeout, and includes notes on version compatibility. ```APIDOC ## Client Creation and Configuration ### Description This section details the process of establishing a connection with the CARLA server using the `carla.Client` class. It covers client instantiation with host and port, setting a network timeout to prevent indefinite blocking, and important considerations regarding client-server version synchronization. ### Method Instantiation and method calls on `carla.Client` ### Endpoint N/A (Client-side operation) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import carla # Create a client connection to the CARLA server client = carla.Client('localhost', 2000) # Set a timeout for all network operations (in seconds) client.set_timeout(10.0) # Example of checking client and server versions print(f"Client version: {client.get_client_version()}") print(f"Server version: {client.get_server_version()}") ``` ### Response #### Success Response (200) Successful connection and client object initialization. #### Response Example ```python # Client object is ready for use ``` ### Notes - The default connection is to 'localhost' on port 2000. These can be changed. - The second port used for communication is typically `port + 1`. - Mismatched `libcarla` versions between client and server can lead to issues. ``` -------------------------------- ### CARLA Map: Get Road Topology Source: https://carla-ue5.readthedocs.io/en/latest/core_map Generates a minimal graph of the road topology, returning a list of waypoint pairs that define the start and end points of each lane. ```python waypoint_tuple_list = map.get_topology() ``` -------------------------------- ### CARLA Recorder Methods Source: https://carla-ue5.readthedocs.io/en/latest/python_api Documentation for CARLA recorder functionalities including starting, stopping, and querying recording data. ```APIDOC ## POST /recorder/request_file ### Description Requests one of the required files returned by carla.Client.get_required_files. ### Method POST ### Endpoint /recorder/request_file ### Parameters #### Request Body - **name** (str) - Required - Name of the file you are requesting. ### Request Example ```json { "name": "some_file.txt" } ``` ### Response #### Success Response (200) - **file_content** (str) - Content of the requested file. #### Response Example ```json { "file_content": "This is the content of the requested file." } ``` ``` ```APIDOC ## GET /recorder/show_recorder_actors_blocked ### Description The terminal will show the information registered for actors considered blocked. An actor is considered blocked when it does not move a minimum distance in a period of time. ### Method GET ### Endpoint /recorder/show_recorder_actors_blocked ### Parameters #### Query Parameters - **filename** (str) - Required - Name of the recorded file to load. - **min_time** (float) - Optional - Minimum time (in seconds) the actor has to move before being considered blocked. Default is 60 seconds. - **min_distance** (float) - Optional - Minimum distance (in centimeters) the actor has to move to not be considered blocked. Default is 100 centimeters. ### Response #### Success Response (200) - **blocked_actors_info** (string) - Information registered for actors considered blocked. #### Response Example ```json { "blocked_actors_info": "Actor ID 123: Blocked for 75s, distance moved 50cm." } ``` ``` ```APIDOC ## GET /recorder/show_recorder_collisions ### Description The terminal will show the collisions registered by the recorder. These can be filtered by specifying the type of actor involved. ### Method GET ### Endpoint /recorder/show_recorder_collisions ### Parameters #### Query Parameters - **filename** (str) - Required - Name or absolute path of the file recorded. - **category1** (char) - Required - Character variable specifying a first type of actor involved in the collision ('h'=Hero, 'v'=Vehicle, 'w'=Walker, 't'=Traffic light, 'o'=Other, 'a'=Any). - **category2** (char) - Required - Character variable specifying a second type of actor involved in the collision. ### Response #### Success Response (200) - **collisions_info** (string) - Information about registered collisions. #### Response Example ```json { "collisions_info": "Collision detected between Vehicle (ID 45) and Walker (ID 78)." } ``` ``` ```APIDOC ## GET /recorder/show_recorder_file_info ### Description Parses and shows the information saved by the recorder in the terminal as text (frames, times, events, state, positions...). The information shown can be specified by using the `show_all` parameter. ### Method GET ### Endpoint /recorder/show_recorder_file_info ### Parameters #### Query Parameters - **filename** (str) - Required - Name or absolute path of the file recorded. - **show_all** (bool) - Required - If True, returns all information stored for every frame. If False, returns a summary of key events and frames. ### Response #### Success Response (200) - **file_info** (string) - Information from the recorder file. #### Response Example ```json { "file_info": "Frame: 100, Time: 5.2s, Event: Collision, State: Active." } ``` ``` ```APIDOC ## POST /recorder/start_recorder ### Description Enables the recording feature, which will start saving every information possible needed by the server to replay the simulation. ### Method POST ### Endpoint /recorder/start_recorder ### Parameters #### Request Body - **filename** (str) - Required - Name of the file to write the recorded data. If no folder is specified, it saves in 'CarlaUnreal/Saved/'. - **additional_data** (bool) - Optional - Enables or disables recording non-essential data (bounding box location, physics control parameters, etc). Defaults to False. ### Request Example ```json { "filename": "my_recording.log", "additional_data": true } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message that recording has started. #### Response Example ```json { "message": "Recording started successfully." } ``` ``` ```APIDOC ## POST /recorder/stop_recorder ### Description Stops the recording in progress. If a path was specified in `filename` during `start_recorder`, the recording will be saved there. Otherwise, it will be saved in 'CarlaUnreal/Saved/'. ### Method POST ### Endpoint /recorder/stop_recorder ### Parameters (No parameters required) ### Response #### Success Response (200) - **message** (string) - Confirmation message that recording has stopped. #### Response Example ```json { "message": "Recording stopped successfully." } ``` ``` ```APIDOC ## POST /recorder/stop_replayer ### Description Stops the current replayer. ### Method POST ### Endpoint /recorder/stop_replayer ### Parameters #### Request Body - **keep_actors** (bool) - Required - If True, all actors from the replayer will be kept. If False, they will be autoremoved. ### Request Example ```json { "keep_actors": false } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message that the replayer has stopped. #### Response Example ```json { "message": "Replayer stopped successfully." } ``` ``` -------------------------------- ### Get Crosswalk Zones in CARLA Map Source: https://carla-ue5.readthedocs.io/en/latest/python_api Returns a list of closed polygons representing all crosswalk zones within the map. The first point is repeated to signify the start and end of each polygon. ```python map.get_crosswalks() ``` -------------------------------- ### Manage Lights and Light States in Carla Source: https://carla-ue5.readthedocs.io/en/latest/core_world Provides Python code examples for accessing the light manager, retrieving all lights, customizing individual lights by turning them on, setting intensity, and defining their state using `carla.LightState`. ```Python # Get the light manager and lights lmanager = world.get_lightmanager() mylights = lmanager.get_all_lights() # Custom a specific light light01 = mylights[0] light01.turn_on() light01.set_intensity(100.0) state01 = carla.LightState(200.0,red,carla.LightGroup.Building,True) light01.set_light_state(state01) ``` -------------------------------- ### Launch CARLA Server (Linux) Source: https://carla-ue5.readthedocs.io/en/latest/tuto_first_steps This command navigates to the CARLA root directory and executes the CARLA Unreal Engine server script on Linux systems. ```shell cd /carla/root ./CarlaUnreal.sh ``` -------------------------------- ### Applying Command Batches Source: https://carla-ue5.readthedocs.io/en/latest/core_world Illustrates how to use `apply_batch` and `apply_batch_sync` for efficient execution of multiple commands, such as destroying actors. ```APIDOC ## Applying Command Batches ### Description This section explains the utility of CARLA's command batching feature, which allows multiple simulation commands to be executed in a single step. This is particularly useful for operations involving numerous actors, improving efficiency. Examples include using `carla.command.DestroyActor` within a batch. ### Method `client.apply_batch()`, `client.apply_batch_sync()` ### Endpoint N/A (Client-side operation) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import carla # Assuming 'client' is an established carla.Client object # and 'vehicles_list' is a list of carla.Actor objects to be destroyed # Example list of actors to destroy # vehicles_list = [...] # Create a list of commands to destroy each actor in the list destroy_commands = [carla.command.DestroyActor(actor) for actor in vehicles_list] # Apply the commands in a batch (asynchronous) # client.apply_batch(destroy_commands) # Apply the commands in a batch (synchronous) # results = client.apply_batch_sync(destroy_commands) # print(f"Batch execution results: {results}") ``` ### Response #### Success Response (200) Commands are executed by the server. `apply_batch_sync` returns a list of results. #### Response Example ```python # If using apply_batch_sync, results might look like: # Batch execution results: [True, True, False, ...] ``` ### Notes - `apply_batch` sends commands asynchronously. - `apply_batch_sync` sends commands and waits for their execution, returning a list indicating the success or failure of each command. ``` -------------------------------- ### Clone CARLA Repository Source: https://carla-ue5.readthedocs.io/en/latest/build_windows_ue5 Clones the ue5-dev branch of the CARLA simulator from GitHub to your local machine. This is the first step in setting up the CARLA development environment. ```bash git clone -b ue5-dev https://github.com/carla-simulator/carla.git CarlaUE5 ``` -------------------------------- ### Set up a CMake preset for Linux Development Source: https://carla-ue5.readthedocs.io/en/latest/build_windows_ue5 This command initializes a build configuration using the 'Linux-Development' CMake preset. It creates a dedicated folder within the build directory for all artifacts related to this specific configuration, aiding in the management of multiple build setups. ```bash cmake --preset Linux-Development ``` -------------------------------- ### Get Road Topology Graph in CARLA Source: https://carla-ue5.readthedocs.io/en/latest/python_api Returns a simplified graph representation of the OpenDRIVE file's topology. The output is a list of tuples, where each tuple contains two waypoints representing the start and end of a road segment. This graph is suitable for loading into NetworkX. ```python map.get_topology() ``` -------------------------------- ### Build Unreal Engine 5.5 for CARLA Source: https://carla-ue5.readthedocs.io/en/latest/build_linux_ue5 Builds Unreal Engine 5.5 using the provided setup scripts. This is a prerequisite for building CARLA UE5 and can take a significant amount of time. ```bash ./Setup.sh && ./GenerateProjectFiles.sh && make ``` -------------------------------- ### CARLA Client Creation (Python) Source: https://carla-ue5.readthedocs.io/en/latest/core_world Demonstrates how to create a CARLA client instance by specifying the IP address and TCP port for server connection. It also shows how to set a network operation timeout. ```Python client = carla.Client('localhost', 2000) client.set_timeout(10.0) # seconds ``` -------------------------------- ### Setup AI Controller for Pedestrian Movement Source: https://carla-ue5.readthedocs.io/en/latest/tuto_G_pedestrian_bones Initializes and starts an AI controller for a pedestrian, allowing it to navigate autonomously within the Carla simulation environment. It uses the world's blueprint library to find the walker controller and spawns an actor with a random navigation target. ```python controller_bp = world.get_blueprint_library().find('controller.ai.walker') controller = world.spawn_actor(controller_bp, pedestrian.get_transform(), pedestrian) controller.start() controller.go_to_location(world.get_random_location_from_navigation()) ``` -------------------------------- ### Configure Unattended CARLA UE5 Build with Git Credentials Source: https://carla-ue5.readthedocs.io/en/latest/build_linux_ue5 Sets up environment variables for unattended CARLA UE5 builds by adding GitHub credentials to the .bashrc file. This allows the setup script to run without manual credential input. ```shell export GIT_LOCAL_CREDENTIALS=username@github_token ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.