Skip to content

Commit

Permalink
Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
cgeller committed Feb 2, 2024
1 parent d12d8bb commit 6f08e0f
Show file tree
Hide file tree
Showing 10 changed files with 190 additions and 20 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Docker

on: [push, pull_request]

jobs:

clean-up:
name: Clean up
runs-on: ubuntu-latest
steps:

- name: Clean up
run: rm -rf *

create-image:
name: Create docker image
runs-on: ubuntu-latest
needs: clean-up
env:
IMAGE_TAG_SUFFIX: ""
steps:

- uses: actions/checkout@v4
name: Checkout repository
with:
path: carla-scenario-runner
submodules: true

- uses: docker/login-action@v3
name: Login to Docker Hub
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- uses: robinraju/[email protected]
name: Download PythonAPI
with:
repository: carla-compose/carla-simulator
latest: true
fileName: PythonAPI.tar.gz
extract: true
out-file-path: .

- name: Remove PythonAPI.tar.gz
run: rm PythonAPI.tar.gz

- name: Set image tag
run: |
echo "IMAGE_TAG_SUFFIX=_$(echo '${{ github.ref_name }}' | tr / -)_ci" >> $GITHUB_ENV
if: github.ref_name != github.event.repository.default_branch

- uses: docker/build-push-action@v5
name: Build and push
with:
push: true
file: carla-scenario-runner/docker/Dockerfile
tags: rwthika/carla-scenario-runner:latest${{env.IMAGE_TAG_SUFFIX}}
no-cache: true
context: .
2 changes: 1 addition & 1 deletion CARLA_VER
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
HOST = https://carla-releases.s3.eu-west-3.amazonaws.com/Linux
RELEASE=CARLA_0.9.13
RELEASE=CARLA_0.9.15
13 changes: 13 additions & 0 deletions CARLOS_CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Latest : 1.0.0

## 1.0.0 - Initial Release

### Major changes

* Created GitHub workflow and Dockerfile to automatically build Docker images
* Update to [CARLA 0.9.15](https://carla.org/2023/11/10/release-0.9.15/)
* Update to Ubuntu 22.04 and Python 3.10 including corresponding pip versions

### Minor changes

* Small fix related to CARLA autopilot
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,35 @@
# Control Actor: *carla-scenario-runner*

<p align="left">
<img src="https://img.shields.io/github/v/release/ika-rwth-aachen/carla-scenario-runner"/>
<img src="https://img.shields.io/github/license/ika-rwth-aachen/carla-scenario-runner"/>
<a href="https://github.com/ika-rwth-aachen/carla-scenario-runner/actions/workflows/docker.yml">
<img src="https://github.com/ika-rwth-aachen/carla-scenario-runner/actions/workflows/docker.yml/badge.svg"/></a>
<img src="https://img.shields.io/badge/Ubuntu-22.04-E95420"/>
<img src="https://img.shields.io/badge/CARLA-0.9.15-blueviolet"/>
<img src="https://img.shields.io/badge/Python-3.10-blueviolet"/>
<img src="https://img.shields.io/github/stars/ika-rwth-aachen/carla-scenario-runner?style=social"/>
</p>

> [!IMPORTANT]
> This repository is a minimal fork of the official [scenario_runner](https://github.com/carla-simulator/scenario_runner)! All initial and following modifications to the original repository are documented in [CARLOS_CHANGELOG.md](./CARLOS_CHANGELOG.md).
> [!TIP]
> We recommend to use the *carla-scenario-runner* as **control actor** in our open, modular and scalable simulation framework <a href="https://github.com/ika-rwth-aachen/carlos">**CARLOS**. <img src="https://img.shields.io/github/stars/ika-rwth-aachen/carlos?style=social"/></a>
>
> The *carla-scenario-runner* is used to enable scenario-based testing and evaluation. It is a powerful engine that follows the OpenSCENARIO standard for scenario definitions.
> [!NOTE]
> We set up a Continous Integration (CI) pipeline as [GitHub workflow](./github/workflows/docker.yml) to continously build Docker images for the `carla-scenario-runner`, publicly available on [Docker Hub](https://hub.docker.com/r/rwthika/carla-scenario-runner).
---
---
## Original README

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
![GitHub tag (latest SemVer)](https://img.shields.io/github/tag/carla-simulator/scenario_runner.svg)
[![Build Status](https://travis-ci.com/carla-simulator/scenario_runner.svg?branch=master)](https://travis-ci.com/carla/scenario_runner)

ScenarioRunner for CARLA
========================
This repository contains traffic scenario definition and an execution engine
for CARLA. It also allows the execution of a simulation of the CARLA Challenge.
You can use this system to prepare your agent for the CARLA Challenge.
Expand Down
62 changes: 62 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
ARG UBUNTU_VERSION="22.04"


############ dependencies ############
FROM "ubuntu:${UBUNTU_VERSION}"

USER root
SHELL ["/bin/bash", "-c"]

ARG CARLA_API_PATH=/opt/carla/PythonAPI
ARG SCENARIO_RUNNER_PATH=/opt/carla/carla-scenario-runner

# Install essentials
RUN apt-get update && \
apt-get install -y \
libpng16-16 \
libtiff5 \
libjpeg8 \
build-essential \
wget \
git \
libxerces-c-dev \
python3-pip \
&& rm -rf /var/lib/apt/lists/*

RUN pip3 install --upgrade pip
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 10

# Install carla-scenario-runner
COPY ./carla-scenario-runner $SCENARIO_RUNNER_PATH
RUN pip3 install -r $SCENARIO_RUNNER_PATH/requirements.txt

# Move over PythonAPI
COPY ./artifacts/PythonAPI ${CARLA_API_PATH}

# Recursively install PythonAPI requirements, keep version of first occurrence
RUN cat $(find ${CARLA_API_PATH} -type f -name "requirements.txt") > /tmp/requirements_raw.txt \
&& awk -F '==' '{print $1}' /tmp/requirements_raw.txt | awk '!visited[$1]++' > /tmp/requirements.txt \
&& pip3 install -r /tmp/requirements.txt

# Create script that adds API to pythonpath and make .bashrc source it
RUN echo "export PYTHONPATH=\$PYTHONPATH:$CARLA_API_PATH/carla/dist/$(ls $CARLA_API_PATH/carla/dist | grep py$(python --version | awk -F'[ .]' '{print $2"."$3}').)" >> /setup_carla_env.sh; \
echo "export PYTHONPATH=\$PYTHONPATH:$CARLA_API_PATH/carla/agents" >> /setup_carla_env.sh; \
echo "export PYTHONPATH=\$PYTHONPATH:$CARLA_API_PATH/carla" >> /setup_carla_env.sh; \
echo "export CARLA_API_PATH=$CARLA_API_PATH" >> /setup_carla_env.sh; \
echo "source /setup_carla_env.sh" >> ~/.bashrc

# Needed for (pygame based) scripts that have a GUI
ENV SDL_VIDEODRIVER=x11

USER root
SHELL ["/bin/bash", "-c"]

ARG WORKSPACE=${SCENARIO_RUNNER_PATH}
ENV WORKSPACE=${WORKSPACE}
WORKDIR ${WORKSPACE}

# Set entrypoint
COPY ./carla-scenario-runner/docker/entrypoint.sh /
ENTRYPOINT [ "/entrypoint.sh" ]

CMD [ "python3", "scenario_runner.py", "--help" ]
8 changes: 8 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -e

# source CARLA environment setup script
source /setup_carla_env.sh

# run the actual command
exec "$@"
29 changes: 15 additions & 14 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
py-trees==0.8.3
numpy==1.18.4; python_version >= '3.0'
networkx==2.2
Shapely==1.7.1
psutil
xmlschema==1.0.18
ephem
tabulate
opencv-python==4.2.0.32
matplotlib
six
simple-watchdog-timer
antlr4-python3-runtime==4.10
graphviz
# Update all versions to be compatible with Ubuntu 22.04, Python 3.10.6, ROS Humble (at 2023-07-24)
py-trees==0.8.3 # newest version (2.2.3) is not compatible
numpy==1.21.5
networkx==3.1
shapely==2.0.1
psutil==5.9.0
xmlschema==2.3.1
ephem==4.1.4
tabulate==0.9.0
opencv-python==4.8.0.74
matplotlib==3.7.2
six==1.16.0
simple-watchdog-timer==0.1.1
antlr4-python3-runtime==4.13.1
graphviz==0.20.1
2 changes: 1 addition & 1 deletion scenario_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
from srunner.scenarioconfigs.osc2_scenario_configuration import OSC2ScenarioConfiguration

# Version of scenario_runner
VERSION = '0.9.13'
VERSION = '0.9.15'


class ScenarioRunner(object):
Expand Down
1 change: 1 addition & 0 deletions srunner/scenariomanager/actorcontrols/actor_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def __init__(self, actor, control_py_module, args, scenario_file_path):
if ".py" in control_py_module:
module_name = os.path.basename(control_py_module).split('.')[0]
sys.path.append(os.path.dirname(control_py_module))
sys.path.append(os.path.dirname(__file__))
module_control = importlib.import_module(module_name)
control_class_name = module_control.__name__.title().replace('_', '')
else:
Expand Down
4 changes: 2 additions & 2 deletions srunner/scenariomanager/actorcontrols/carla_autopilot.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from srunner.scenariomanager.actorcontrols.basic_control import BasicControl


class CarlaAutoPilotControl(BasicControl):
class CarlaAutopilot(BasicControl):

"""
Controller class for vehicles derived from BasicControl.
Expand All @@ -33,7 +33,7 @@ class CarlaAutoPilotControl(BasicControl):
"""

def __init__(self, actor, args=None):
super(CarlaAutoPilotControl, self).__init__(actor)
super(CarlaAutopilot, self).__init__(actor)
self._actor.set_autopilot(enabled=True)

def reset(self):
Expand Down

0 comments on commit 6f08e0f

Please sign in to comment.