### Install CARLA Qt Example Plugin and Tool Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Examples/QtClient/CMakeLists.txt Installs the Qt example plugin and standalone tool to their respective locations within the CARLA installation directory, making them discoverable by CARLA Studio or runnable directly. ```cmake include (GNUInstallDirs) install ( TARGETS carla_studio_example_plugin LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/carla-studio/plugins" RUNTIME DESTINATION "${CMAKE_INSTALL_LIBDIR}/carla-studio/plugins" OPTIONAL ) install ( TARGETS carla_studio_example_tool RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" OPTIONAL ) ``` -------------------------------- ### Install Dependencies and Run Example Scripts Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/start_quickstart.md Install necessary Python packages and run example scripts for traffic generation and manual control in separate terminals. ```shell # Terminal A cd PythonAPI\examples pip3 install -r requirements.txt python3 generate_traffic.py # Terminal B cd PythonAPI\examples python3 manual_control.py ``` -------------------------------- ### Run Interactive CARLA Setup Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/build_linux_ue5.md Execute the CARLA setup script interactively to install prerequisites, download Unreal Engine, and build CARLA. This script prompts for sudo password and GitHub credentials. ```sh cd CarlaUE5 ./CarlaSetup.sh --interactive ``` -------------------------------- ### Define C++ Example Client Project Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Examples/CMakeLists.txt Initializes the C++ example client project with its name, C++ language support, and version. This is a standard CMake project setup. ```cmake project ( carla-example-cpp-client LANGUAGES CXX VERSION ${CARLA_VERSION} ) ``` -------------------------------- ### Add Qt Client Subdirectory Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Examples/CMakeLists.txt Includes the Qt-based community tool example, which builds a dockable plugin and a standalone executable. This step is conditional on Qt being installed. ```cmake add_subdirectory (${CARLA_WORKSPACE_PATH}/Examples/QtClient QtClient) ``` -------------------------------- ### Run CARLA Setup Script Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/build_windows_ue5.md Execute the CarlaSetup.bat script to install all necessary dependencies, including Visual Studio 2022, CMake, Python 3.8, and Unreal Engine 5.5. This script also downloads CARLA content and builds the project, which can take a significant amount of time. ```sh cd CarlaUE5 CarlaSetup.bat ``` -------------------------------- ### Build CARLA Example Client Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/tuto_cpp.md Builds the example C++ client for CARLA. This is the first step to running client-side logic. ```sh cmake --build Build --target carla-example-client ``` -------------------------------- ### Run CARLA Example Client Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/tuto_cpp.md Runs the example C++ client. It can connect to the default CARLA endpoint or a custom one. ```sh ./Build/Examples/carla-example-client ``` ```sh ./Build/Examples/carla-example-client 192.168.1.100 3000 ``` -------------------------------- ### Run CARLA Setup Script (Linux Unattended) Source: https://github.com/carla-simulator/carla/blob/ue5-dev/README.md Run the CARLA setup script unattended on Linux by storing Git credentials in the .bashrc file. This automates the download and installation of Unreal Engine and CARLA. ```sh export GIT_LOCAL_CREDENTIALS=username@github_token cd CarlaUE5 sudo -E ./CarlaSetup.sh ``` -------------------------------- ### CARLA Fundamentals Tutorial Code Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/tutorials.md Code examples for the CARLA Fundamentals video tutorial. This notebook covers basic concepts and starting your first script. ```Python # This is a placeholder for the actual code from the Fundamentals.ipynb file. # The content of the notebook is not directly available in the provided text. # Please refer to the linked "Fundamentals.ipynb" for the complete code. # Example structure of what might be in the notebook: # import carla # # # Connect to the CARLA simulator # client = carla.Client('localhost', 2000) # world = client.get_world() # # # Get vehicle information # blueprint_library = world.get_blueprint_library() # vehicle_bp = blueprint_library.filter('vehicle.tesla.model3')[0] # # # Spawn a vehicle # spawn_point = carla.Transform(carla.Location(x=0.0, y=0.0, z=0.5), carla.Rotation(yaw=0.0)) # vehicle = world.spawn_actor(vehicle_bp, spawn_point) # # print(f"Spawned vehicle: {vehicle.id}") ``` -------------------------------- ### Launch RViz for Sensor Data Visualization Source: https://github.com/carla-simulator/carla/blob/ue5-dev/PythonAPI/examples/ros2/README.md Start RViz using this script to visualize the sensor data being published by CARLA. Docker must be installed and running. ```bash ./run_rviz.sh ``` -------------------------------- ### Run Basic Agent Example Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/adv_agents.md Execute the automatic_control.py script using a Basic Agent. This requires navigating to the examples directory. ```shell python3 automatic_control.py --agent=Basic ``` -------------------------------- ### Installation Configuration Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Util/DockerUtils/fbx/CMakeLists.txt Specifies the installation destination for the built executable relative to the current source directory. ```cmake # install location install(TARGETS FBX2OBJ DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/../dist") ``` -------------------------------- ### Link CARLA Client Library to Example Client Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Examples/CMakeLists.txt Links the 'carla-client' library to the 'carla-example-client' executable. This makes the CARLA client API available to the example. ```cmake target_link_libraries ( carla-example-client PUBLIC carla-client ) ``` -------------------------------- ### Run Unattended CARLA Setup Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/build_linux_ue5.md Execute the CARLA setup script in unattended mode after caching sudo password and setting Git credentials. This downloads and installs all necessary components. ```sh cd CarlaUE5 ./CarlaSetup.sh ``` -------------------------------- ### Build Standalone Qt Example Tool Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Examples/QtClient/CMakeLists.txt Configures a standalone executable for the CARLA Studio community example tool. It sets include directories, links against the Qt Widgets library, and enables AUTOMOC. ```cmake carla_add_executable ( carla_studio_example_tool "Build the CARLA Studio community example tool (standalone)." WIN32 ${CARLA_QT_EXAMPLE_SOURCE} ) set_target_properties ( carla_studio_example_tool PROPERTIES AUTOMOC ON ) target_include_directories ( carla_studio_example_tool PRIVATE ${CARLA_QT_EXAMPLE_INCLUDE} ) target_link_libraries ( carla_studio_example_tool PRIVATE ${CARLA_QT_WIDGETS} ) ``` -------------------------------- ### Install CARLA Python Client Library Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/start_quickstart.md Install the CARLA client library using pip from the wheel file provided in the CARLA package distribution. It is recommended to do this within a virtual environment. ```shell cd CARLA_ROOT/PythonAPI/dist/ pip3 install carla-*.*.*-cp3**-linux_x86_64.whl ``` -------------------------------- ### Build Qt Example Plugin Library Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Examples/QtClient/CMakeLists.txt Configures a shared library plugin for the CARLA Studio example. It customizes the output name to match CARLA's plugin convention, sets visibility to hidden, and links against Qt Widgets. ```cmake add_library ( carla_studio_example_plugin MODULE ${CARLA_QT_EXAMPLE_SOURCE} ) set_target_properties ( carla_studio_example_plugin PROPERTIES AUTOMOC ON PREFIX "" OUTPUT_NAME "qt-carla-studio-example" CXX_VISIBILITY_PRESET hidden ) target_compile_definitions ( carla_studio_example_plugin PRIVATE CARLA_STUDIO_BUILD_AS_PLUGIN ) target_include_directories ( carla_studio_example_plugin PRIVATE ${CARLA_QT_EXAMPLE_INCLUDE} ) target_link_libraries ( carla_studio_example_plugin PRIVATE ${CARLA_QT_WIDGETS} ) ``` -------------------------------- ### Install Benchmarking Dependencies Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/adv_benchmarking.md Install the required Python packages for the benchmarking script. Ensure you are using the specified version for py-cpuinfo. ```python python -m pip install -U py-cpuinfo==5.0.0 psutil python-tr gpuinfo GPUtil ``` -------------------------------- ### Install MkDocs for Documentation Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/cont_contribution_guidelines.md Installs MkDocs, a static site generator used for building CARLA's documentation. Ensure pip is available and updated. ```sh sudo pip install mkdocs ``` -------------------------------- ### Install CARLA Client Library and Headers Source: https://github.com/carla-simulator/carla/blob/ue5-dev/LibCarla/CMakeLists.txt Installs the CARLA client library archive and public headers to the appropriate system directories. This makes the client available for external use. ```cmake install ( TARGETS carla-client ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ) install ( DIRECTORY ${LIBCARLA_SOURCE_PATH}/carla DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" PATTERN "*.inl" ) ``` -------------------------------- ### Install CARLA with C++ Client Enabled Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Examples/CppClient/Standalone/README.md Build CARLA from source, enabling the C++ client and installing it to a specified prefix. This makes the client library and CMake configuration files available for external projects. ```bash cd /path/to/carla cmake -B Build -DBUILD_CARLA_CLIENT=ON -DBUILD_PYTHON_API=OFF cmake --build Build --target carla-client -j cmake --install Build --prefix /opt/carla ``` -------------------------------- ### Load World and Start Recorder Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/foundations.md Use the client object to load a specific map into the simulation and start recording simulation data to a log file. ```python client.load_world('Town07') client.start_recorder('recording.log') ``` -------------------------------- ### Start CARLA Simulator Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/adv_benchmarking.md Use these commands to launch the CARLA simulator on Linux, Windows, or from source. ```shell # Linux: ./CarlaUnreal.sh ``` ```shell # Windows: CarlaUnreal.exe ``` ```shell # Source: cmake --build Build --target launch ``` -------------------------------- ### Build and Install Python API Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/build_windows_ue5.md Build and install the Python API for CARLA. This command ensures that the Python bindings are compiled and installed, making the CARLA Python client available. Ensure you are in the CarlaUE5 directory and have the x64 Native Tools Command Prompt for VS 2022 open. ```sh cmake --build Build --target carla-python-api-install ``` -------------------------------- ### Install Doxygen and Graphviz Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/ref_cpp.md Installs the necessary tools for generating C++ documentation on Linux systems. ```sh # linux > sudo apt-get install doxygen graphviz ``` -------------------------------- ### Run Behavior Agent Example Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/adv_agents.md Execute the automatic_control.py script using a Behavior Agent with an 'aggressive' profile. This requires navigating to the examples directory. ```shell python3 automatic_control.py --agent=Behavior --behavior=aggressive ``` -------------------------------- ### Install CARLA Python API from Package Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/build_linux_ue5.md Installs the Python API for the built CARLA package. Replace '***' with the specific version number of the package. ```sh pip3 install PythonAPI/dist/carla-***.whl ``` -------------------------------- ### Start Recording with Additional Data Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/adv_recorder.md Starts recording simulation data and includes additional information such as velocities, traffic light timings, and physics controls. Set the second argument to True to enable this. ```python client.start_recorder("/home/carla/recording01.log", True) ``` -------------------------------- ### Start Recording Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/adv_recorder.md Starts the recorder. The file name can be an absolute path. If not specified, the file is saved in CarlaUnreal/Saved. An optional boolean argument 'additional_data' can be set to True to store more detailed information. ```APIDOC ## Start Recording ### Description Starts the recorder to save simulation data to a specified file. ### Method `client.start_recorder(filename, additional_data=False)` ### Parameters * **filename** (string) - Required - The path and name of the file to save the recording. * **additional_data** (boolean) - Optional - If True, stores additional data such as velocities, trigger boxes, and physics controls. Defaults to False. ### Request Example ```python client.start_recorder("/home/carla/recording01.log") client.start_recorder("/home/carla/recording01.log", True) ``` ``` -------------------------------- ### Define CARLA Example C++ Client Source Path Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Examples/CMakeLists.txt Sets the variable CARLA_EXAMPLE_CPP_CLIENT_SOURCE_PATH to the location of the C++ client example sources. This is a prerequisite for subsequent build steps. ```cmake set ( CARLA_EXAMPLE_CPP_CLIENT_SOURCE_PATH ${CARLA_WORKSPACE_PATH}/Examples/CppClient ) ``` -------------------------------- ### Install CARLA Prerequisites on Linux Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/build_linux_ue5.md Installs essential build tools and libraries required for compiling CARLA on a Debian-based Linux distribution. Run this command before proceeding with the CARLA build. ```sh sudo apt update sudo apt install build-essential ninja-build libvulkan1 python3 python3-dev python3-pip git git-lfs ``` -------------------------------- ### CMake Project Setup Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Util/DockerUtils/fbx/CMakeLists.txt Sets the minimum CMake version and project name. Specifies the generator platform for building. ```cmake cmake_minimum_required(VERSION 2.8.9) project(FBX2OBJ) set(CMAKE_GENERATOR_PLATFORM x64) ``` -------------------------------- ### Install and Link CARLA C++ Client Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/tuto_cpp.md Shows how to build, install, and link the CARLA C++ client library into an external CMake project. This enables using CARLA's C++ API in your own applications. ```bash # in CARLA's source tree cmake -B Build -DBUILD_CARLA_CLIENT=ON -DBUILD_PYTHON_API=OFF cmake --build Build --target carla-client -j cmake --install Build --prefix /opt/carla ``` ```cmake find_package(Carla CONFIG REQUIRED) add_executable(myapp main.cpp) target_link_libraries(myapp PRIVATE Carla::carla-client) ``` ```bash cmake -B build -DCMAKE_PREFIX_PATH=/opt/carla cmake --build build -j ``` -------------------------------- ### Run CARLA Setup Script (Linux Unattended with Terminal Credentials) Source: https://github.com/carla-simulator/carla/blob/ue5-dev/README.md Execute the CARLA setup script unattended on Linux by providing Git credentials directly in the terminal command. This method avoids modifying the .bashrc file. ```sh cd CarlaUE5 sudo -E env GIT_LOCAL_CREDENTIALS=github_username@github_token ./CarlaSetup.sh ``` -------------------------------- ### Include and Library Directories Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Util/DockerUtils/fbx/CMakeLists.txt Configures include paths for source files and library paths for dependencies. Ensure LibXml2 is installed if uncommented. ```cmake # find_package (LibXml2 REQUIRED) # include folders include_directories(src) include_directories(dependencies/include) # library folders link_directories(dependencies/lib/gcc/x64/release) ``` -------------------------------- ### client.replay_file Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/foundations.md Starts a simulation playback from a specified point in a log file. Allows control over playback duration and camera focus. ```APIDOC ## client.replay_file ### Description Starts a simulation playback from a specified point in a log file. Allows control over playback duration and camera focus. ### Method ```python client.replay_file(start, duration, camera) ``` ### Parameters #### Path Parameters - **start** (int) - Required - Recording time in seconds to start the simulation at. If positive, time will be considered from the beginning of the recording. If negative, it will be considered from the end. - **duration** (int) - Required - Seconds to playback. 0 is all the recording. By the end of the playback, vehicles will be set to autopilot and pedestrians will stop. - **camera** (int) - Required - ID of the actor that the camera will focus on. Set it to `0` to let the spectator move freely. ### Request Example ```python client.replay_file("recording01.log", 10, 60, 0) ``` ### Response This method does not return a value, but initiates a simulation playback. ``` -------------------------------- ### Serve Documentation Locally with MkDocs Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/cont_contribution_guidelines.md Starts a local development server to preview documentation changes. Access the live preview via the provided URL. ```sh mkdocs serve ``` -------------------------------- ### Build CARLA Components Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/build_devcontainer.md Use CMake build targets to install the Python API, launch the Unreal Editor, or package the project. ```bash cmake --build Build --target carla-python-api-install ``` ```bash cmake --build Build --target launch ``` ```bash cmake --build Build --target package ``` -------------------------------- ### Get Waypoints within a Junction Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/core_map.md Fetch pairs of waypoints marking the start and end boundaries of lanes within a CARLA junction. ```python waypoints_junc = my_junction.get_waypoints() ``` -------------------------------- ### Setup CARLA Simulator and Utilities Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/tuto_G_pedestrian_bones.md Connect to the CARLA client, retrieve the world object, and enable synchronous mode for controlled simulation time progression. Imports necessary libraries for math, random operations, queues, and image processing. ```python import carla import random import numpy as np import math import queue import cv2 #OpenCV to manipulate and save the images # Connect to the client and retrieve the world object client = carla.Client('localhost', 2000) world = client.get_world() # 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) # We will aslo set up the spectator so we can see what we do spectator = world.get_spectator() ``` -------------------------------- ### Build and Launch Editor with Preset Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/build_windows_ue5.md After setting up a preset, use this command to build the project and launch the editor, directing build artifacts to the preset-specific folder. ```bash cmake --build Build/Linux-Development/ --target launch ``` -------------------------------- ### Install CARLA Simulator Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/foundations.md Install the CARLA simulator Python module using pip. Use 'pip install' for Python 2 and 'pip3 install' for Python 3. ```sh pip install carla-simulator # Python 2 pip3 install carla-simulator # Python 3 ``` -------------------------------- ### Install Pygame and Numpy on Windows Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/start_quickstart.md Install the required Python packages, pygame and numpy, for CARLA on Windows. This command installs them for the current user. ```shell pip3 install --user pygame numpy ``` -------------------------------- ### Setting Options Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Unreal/CMakeLists.txt Initializes the options list for the build. ```cmake set (CARLA_UNREAL_OPTIONS) ``` -------------------------------- ### Traffic Manager Initialization and Autopilot Setup in Batch Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/adv_traffic_manager.md Demonstrates creating a Traffic Manager instance with a specified port and setting autopilot for spawned actors in a batch process. It also shows how to set a global speed difference for all vehicles managed by the TM. ```python traffic_manager = client.get_trafficmanager(args.tm-port) tm_port = traffic_manager.get_port() ... batch.append(SpawnActor(blueprint, transform).then(SetAutopilot(FutureActor, True,tm_port))) ... traffic_manager.global_percentage_speed_difference(30.0) ``` -------------------------------- ### Set Up and Spawn Instance Segmentation Camera Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/tuto_G_instance_segmentation_sensor.md Configures the camera's position and rotation in the world and spawns the instance segmentation sensor. ```python # Get the map spawn points and the spectator spawn_points = world.get_map().get_spawn_points() spectator = world.get_spectator() # Set the camera to some location in the map cam_location = carla.Location(x=-46., y=152, z=18) cam_rotation = carla.Rotation(pitch=-21, yaw=-93.4, roll=0) camera_transform = carla.Transform(location=cam_location, rotation=cam_rotation) spectator.set_transform(camera_transform) # Retrieve the semantic camera blueprint and spawn the camera instance_camera_bp = world.get_blueprint_library().find('sensor.camera.instance_segmentation') instance_camera = world.try_spawn_actor(instance_camera_bp, camera_transform) ``` -------------------------------- ### Multi-Client Simulation Setup Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/adv_traffic_manager.md Sets up a multi-client simulation where multiple TMs connect to the same port. The first TM acts as a TM-Server, controlling the behavior of subsequent TM-Clients. ```bash terminal 1: ./CarlaUnreal.sh -carla-rpc-port=4000 terminal 2: python3 generate_traffic.py --port 4000 --tm-port 4050 # TM-Server terminal 3: python3 generate_traffic.py --port 4000 --tm-port 4050 # TM-Client ``` -------------------------------- ### Set Git Credentials for Unattended Setup Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/build_linux_ue5.md Set the GIT_LOCAL_CREDENTIALS environment variable with your GitHub username and token for unattended CARLA setup. ```sh export GIT_LOCAL_CREDENTIALS=github_username@github_token ``` -------------------------------- ### CARLA Simulator Setup Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/tuto_G_bounding_boxes.md Boilerplate code to initialize the CARLA client, world, spawn a vehicle and camera, and set up synchronous mode. The camera is attached to the vehicle and its sensor data is streamed to a queue. ```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) ``` -------------------------------- ### Multi-TM Simulation Setup Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/adv_traffic_manager.md Sets up a multi-TM simulation where multiple TM instances are created on distinct ports. Each TM instance manages its own behavior independently. ```bash terminal 1: ./CarlaUnreal.sh -carla-rpc-port=4000 terminal 2: python3 generate_traffic.py --port 4000 --tm-port 4050 # TM-Server A terminal 3: python3 generate_traffic.py --port 4000 --tm-port 4550 # TM-Server B ``` -------------------------------- ### Cache Sudo Password for Unattended Setup Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/build_linux_ue5.md Cache the sudo password for 15 minutes to enable unattended execution of the CARLA setup script. ```sh sudo -v ``` -------------------------------- ### carla.WorldSettings.__init__ Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/python_api.md Creates an object containing desired settings that could later be applied through carla.World and its method apply_settings(). ```APIDOC ## carla.WorldSettings.__init__ ### Description Creates an object containing desired settings that could later be applied through `carla.World` and its method `apply_settings()`. ### Method __init__ ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **synchronous_mode** (bool) - Optional - Set this to true to enable client-server synchrony. - **no_rendering_mode** (bool) - Optional - Set this to true to completely disable rendering in the simulation. - **fixed_delta_seconds** (float) - Optional - Set a fixed time-step in between frames. `0.0` means variable time-step and it is the default mode. - **max_culling_distance** (float) - Optional - Configure the max draw distance for each mesh of the level. - **deterministic_ragdolls** (bool) - Optional - Defines wether to use deterministic physics or ragdoll simulation for pedestrian deaths. - **tile_stream_distance** (float) - Optional - Used for large maps only. Configures the maximum distance from the hero vehicle to stream tiled maps. - **actor_active_distance** (float) - Optional - Used for large maps only. Configures the distance from the hero vehicle to convert actors to dormant. - **spectator_as_ego** (bool) - Optional - Used for large maps only. Defines the influence of the spectator on tile loading in Large Maps. ### Request Example ```json { "synchronous_mode": false, "no_rendering_mode": false, "fixed_delta_seconds": 0.0, "max_culling_distance": 0.0, "deterministic_ragdolls": false, "tile_stream_distance": 3000, "actor_active_distance": 2000, "spectator_as_ego": true } ``` ### Response #### Success Response (200) This method does not return a value, it initializes the object. #### Response Example None ``` -------------------------------- ### Initialize CARLA Client, World, and Traffic Manager Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/tuto_G_traffic_manager.md Connects to the CARLA client, retrieves the world object, and sets up both the simulator and the Traffic Manager in synchronous mode. Also sets a random seed for reproducibility. ```python import carla import random # Connect to the client and retrieve the world object client = carla.Client('localhost', 2000) world = client.get_world() # 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) # Set up the TM in synchronous mode traffic_manager = client.get_trafficmanager() traffic_manager.set_synchronous_mode(True) # Set a seed so behaviour can be repeated if necessary traffic_manager.set_random_device_seed(0) random.seed(0) # We will aslo set up the spectator so we can see what we do spectator = world.get_spectator() ``` -------------------------------- ### List Available Scenarios Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/adv_benchmarking.md Use the --show_scenarios flag to list all available scenario parameters without running the benchmark. This helps in understanding the testable configurations. ```bash python3 performance_benchmark.py --show_scenarios ``` -------------------------------- ### Replay File with Specific Start Time Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/adv_recorder.md Replay a recorded file starting from a specific time and frame. This is useful for re-enacting specific events like collisions. ```python client.replay_file("col2.log", 13, 0, 122) ``` -------------------------------- ### Add Dependencies for Python API Install Target Source: https://github.com/carla-simulator/carla/blob/ue5-dev/PythonAPI/CMakeLists.txt Establishes a dependency chain where 'carla-python-api-install' requires 'carla-python-api' to be built first. This ensures the API is built before attempting to install it. ```cmake add_dependencies ( carla-python-api-install carla-python-api ) ``` -------------------------------- ### Create Custom Target for CARLA Python API Installation Source: https://github.com/carla-simulator/carla/blob/ue5-dev/PythonAPI/CMakeLists.txt Defines a CMake custom target 'carla-python-api-install' for installing the Python API in editable mode. This is useful for development and testing. ```cmake carla_add_custom_target ( carla-python-api-install "Build & install the CARLA Python API" COMMAND ${Python3_EXECUTABLE} -m pip install -e ${CARLA_PYTHON_API_CARLA_PATH} WORKING_DIRECTORY ${CARLA_PYTHON_API_CARLA_PATH} VERBATIM USES_TERMINAL ) ``` -------------------------------- ### Spawn and Start AI Walker Controller Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/tuto_G_pedestrian_bones.md Spawns an AI controller for a pedestrian, starts it, and assigns a random navigation point. This code is used to make pedestrians move autonomously. ```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()) ``` -------------------------------- ### Initialize CARLA Simulator and Traffic Manager Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/tuto_G_pygame.md Connects to the CARLA client, retrieves the world object, and sets up the simulator and traffic manager in synchronous mode. Also sets a random seed for reproducibility. ```python import carla import random import pygame import numpy as np # Connect to the client and retrieve the world object client = carla.Client('localhost', 2000) world = client.get_world() # 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) # Set up the TM in synchronous mode traffic_manager = client.get_trafficmanager() traffic_manager.set_synchronous_mode(True) # Set a seed so behaviour can be repeated if necessary traffic_manager.set_random_device_seed(0) random.seed(0) # We will aslo set up the spectator so we can see what we do spectator = world.get_spectator() ``` -------------------------------- ### Run CARLA Benchmark with Custom Settings Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/adv_benchmarking.md Customize the benchmark by specifying the host, port, output file, number of ticks, and rendering mode. This example also includes Traffic Manager. ```bash python3 performance_benchmark.py --host= --port= --file=benchmark.md --tm --ticks=200 --render_mode ``` -------------------------------- ### Test Deterministic Mode with generate_traffic.py Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/adv_traffic_manager.md An example command to test deterministic mode by populating a map with autopilot actors and setting a specific seed. This requires navigating to the example script directory. ```bash cd PythonAPI/examples python3 generate_traffic.py -n 50 --seed 9 ``` -------------------------------- ### Example PASCAL VOC XML Annotation File Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/tuto_G_bounding_boxes.md This is an example of an XML file generated in the PASCAL VOC format. It includes image details and bounding box information for detected objects. ```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 ``` -------------------------------- ### Run CARLA Docker Container Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/build_devcontainer.md Starts the CARLA development container, mounting the Unreal Engine and CARLA repository from the host. Use --rebuild to force image rebuild before running. ```sh export CARLA_UNREAL_ENGINE_PATH=/path/to/UnrealEngine5_carla Util/Docker/run.sh --dev ``` ```sh Util/Docker/run.sh --dev --rebuild ``` -------------------------------- ### Get Closest Waypoint Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/core_map.md Finds the closest waypoint to a given location, optionally projecting to the road and specifying lane types. Also shows how to get a waypoint using OpenDRIVE parameters. ```python # Nearest waypoint in the center of a Driving or Sidewalk lane. waypoint01 = map.get_waypoint(vehicle.get_location(),project_to_road=True, lane_type=(carla.LaneType.Driving | carla.LaneType.Sidewalk)) #Nearest waypoint but specifying OpenDRIVE parameters. waypoint02 = map.get_waypoint_xodr(road_id,lane_id,s) ``` -------------------------------- ### carla.Client.__init__ Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/python_api.md Initializes a connection to the CARLA simulator. It allows specifying the host, port, and number of worker threads for background updates. ```APIDOC ## carla.Client.__init__ ### Description Client constructor. Establishes a connection to the CARLA simulator server. ### Method __init__ ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **host** (_str_) - IP address where a CARLA Simulator instance is running. Default is localhost (127.0.0.1). - **port** (_int_) - TCP port where the CARLA Simulator instance is running. Default are 2000 and the subsequent 2001. - **worker_threads** (_int_) - Number of working threads used for background updates. If 0, use all available concurrency. ``` -------------------------------- ### Run ROS 2 Native Example Script Source: https://github.com/carla-simulator/carla/blob/ue5-dev/PythonAPI/examples/ros2/README.md This command executes the Python script that interfaces with CARLA using ROS 2. The `--file` argument specifies the sensor configuration. ```python python3 ros2_native.py --file stack.json ``` -------------------------------- ### Qt Package Discovery and Configuration Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Examples/QtClient/CMakeLists.txt Finds either Qt6 or Qt5 and sets up the necessary variables for linking against the Widgets component. If neither is found, it issues a warning and skips the Qt example target. ```cmake find_package (Qt6 COMPONENTS Widgets QUIET) if (NOT Qt6_FOUND) find_package (Qt5 COMPONENTS Widgets QUIET) if (NOT Qt5_FOUND) carla_warning ("Qt6 or Qt5 not found. Skipping Qt example target.") return () endif () set (Qt_VERSION 5) set (CARLA_QT_WIDGETS Qt5::Widgets) else () set (Qt_VERSION 6) set (CARLA_QT_WIDGETS Qt6::Widgets) endif () ``` -------------------------------- ### Connect to CARLA Client Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/tuto_G_texture_streaming.md Establishes a connection to the CARLA simulator. Ensure the simulator is running before executing. ```python import carla from PIL import Image # Connect to client client = carla.Client('127.0.0.1', 2000) client.set_timeout(2.0) ``` -------------------------------- ### carla.World.remove_on_tick Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/python_api.md Stops the callback for a given callback ID that was previously started with on_tick(). ```APIDOC ## carla.World.remove_on_tick ### Description Stops the callback for `callback_id` started with __on_tick()__. ### Parameters #### Path Parameters - **callback_id** (callback) - Required - The callback to be removed. The ID is returned when creating the callback. ``` -------------------------------- ### Setting Definitions Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Unreal/CMakeLists.txt Defines build-time preprocessor macros, starting with RecastBuilder path. ```cmake set ( CARLA_UNREAL_DEFINITIONS RECASTBUILDER_PATH="$" ) ``` -------------------------------- ### Set up CMake Development Preset Source: https://github.com/carla-simulator/carla/blob/ue5-dev/Docs/build_windows_ue5.md Use this command to set up a development preset for your build. This creates a specific folder for the build artifacts. ```bash cmake --preset Linux-Development ```