To setup CARLA refer to the official CARLA documentation. Ensure all environment variables and dependencies are correctly configured.
The necessary setup to use the LunaticAgent
class and the AgentGameLoop.py module is as follows:
# Clone the repository
git clone --recurse-submodules https://github.com/Daraan/LunaticAI-Driver-for-CARLA-Simulator.git LunaticAI
cd LunaticAI
# Install the dependencies
pip install -r docs/requirements/requirements.txt
# Use these two commands if you forgot the --recurse-submodules in the first step
git submodule init
git submodule update
If you want to use the LunaticChallenger
additional requirements are need to be installed to setup the Leaderboard 2.0. The scenario_runner is already included as a submodule.
Follow the instructions in the Leaderboard 2.0, however apply the following changes:
-
Use the newer
master
branch instead of theleaderboard-2.0
branch:git clone -b master --single-branch https://github.com/carla-simulator/leaderboard.git
-
If you are using Python 3.10+ skip the requirements installation; the leaderboard requirements are already included our in the .
-
If you are using Python 3.9+ check if the pull request Python 3.9+ support{.github .fa .fa-github} is included yet; if not, apply the changes manually:
# Alternatively to below code you can use the patch file from docs/requirements/leaderboard_8e5eda.patch cd leaderboard git remote add other https://github.com/Daraan/leaderboard-fork.git git fetch patch upgrade-dependencies git cherry-pick 8e5eda14e96c05387d9714086b5f7b90b13fd4df --no-commit
If you locally want to build the documentation you need to additionally install Sphinx.
pip install -r docs/requirements/_readthedocs.txt
sh build_docs.sh
# Navigate to a parent folder in which you want to store the repository
git clone --recurse-submodules https://github.com/Daraan/LunaticAI-Driver-for-CARLA-Simulator.git LunaticAI
cd LunaticAI
git submodule init
git submodule update
Note
The following setup is only needed when you do not use a distributed version of the carla package or installed it via conda/pip, i.e. when import carla
can be used without problems.
Otherwise you need to either add the path to the carla .egg files to your PYTHONPATH
environment variable or use the sys.path.append
method in your script before importing carla.
Setting the CARLA_ROOT
variable allows you to import the carla
module by one of the two workarounds below. It is recommended to still follow the below section for a more stable setup afterwards.
Temporarily set the path variables with the following commands or register them permanently in your system, e.g. via conda env var create
.
For Linux you can also modify your .bashrc
or .bash_profile
and for Windows you can use the setx
command to set them permanently.
from launch_tools import carla
# or in this order
import launch_tools
import carla
set CARLA_ROOT=<path to carla folder>
export CARLA_ROOT=<path to carla folder>
If you do not use a packaged version of CARLA, e.g. installed via pip, but the distributed .egg
files that come with carla locate the appropriate files and add them to your PYTHONPATH
variable.
You find them in ${CARLA_ROOT}/PythonAPI/carla/dist
.
Adjust the file name depending on your system and Python version, for example it could look like this:
# Linux; temporary
export PYTHONPATH=$CARLA_ROOT/PythonAPI/carla/dist/carla-0.9.15-py3.10-linux-x86_64.egg:$PYTHONPATH
# or conda
conda activate <your_env>
conda env var create PYTHONPATH=$CARLA_ROOT/PythonAPI/carla/dist/carla-0.9.15-py3.10-linux-x86_64.egg:$PYTHONPATH
conda activate <your_env>
Important
Depending on your operating system, python and CARLA version the file will be named differently.
There are multiple reasons for that. First consult the CARLA documentation and check if you have installed all necessary dependencies. The CARLA F.A.Q section provides further assistance..
This is caused by the fact that the xml.etree.ElementTree.Element.getchildren()
method was removed in Python 3.9.
Recent versions of the scenario_runner already include this patch. For the Leaderboard Setup see how to acquire this patch.
For all other cases, you can apply the patch manually at the error location; exchange:
- for elem in scenario.getchildren():
+ for elem in list(scenario):
This indicates that another agents
module is in your PYTHONPATH
and is imported instead of the
one from this repository. Make sure that the path to the cloned repository is in your PYTHONPATH
before any other path. Modules that interfere are likely PythonAPI/carla/agents
but also
the leaderboard
or scenario_runner
might try to import the agents
module before the one from
this repository.
# A quick hack is to add the path to the repository at the beginning of your script
import sys
sys.path.insert(0, 'path to this project')
An actor is spawned at a blocked position. Restart your simulation and try again.
In case you run into this error, be sure to first import carla
and pygame
afterwards.
ImportError: ./lib/libstdc++.so.6: version 'GLIBCXX_3.4.30' not found (required by /home/.cache/Python-Eggs/carla-0.9.15-py3.10-linux-x86_64.egg-tmp/carla/libcarla.cpython-310-x86_64-linux-gnu.so)
This issue is tracked here.
For rules there is a separate project:./Rules.md#troubleshooting section.