Skip to content

feat(docker): fix scenario-simulator and add readme for tool containers #6159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 3 additions & 46 deletions docker/tools/README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,6 @@
# Open AD Kit Tools

This directory offers tools for [Open AD Kit](https://autoware.org/open-ad-kit/) containers to make deployment and simulation easier.
This directory offers tools for [Open AD Kit](https://autoware.org/open-ad-kit/) containers to make development and deployment easier.

- `visualizer`: a container which visualizes the Autoware with RViz.
- `scenario-simulator`: a container which runs scenario-simulator.

## Visualizer

### Run

```bash
docker run --rm --name visualizer -p 6080:6080 ghcr.io/autowarefoundation/autoware-tools:visualizer
```

### Settings

The following environment variables can be configured with `-e` while launching the visualizer container:

| Variable | Default Value | Possible Values | Description |
| ----------------- | ------------------------------ | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `RVIZ_CONFIG` | `/autoware/rviz/autoware.rviz` | Any valid path | The full path to the RViz configuration file inside the container |
| `REMOTE_DISPLAY` | `true` | `true`, `false` | By default, the rviz2 is redirected to a URL to enable browser-based visualization. Set this to `false` to launch a local rviz2 display. |
| `REMOTE_PASSWORD` | `openadkit` | Any string | Password for remote display (only used when `REMOTE_DISPLAY=true`) |

## Scenario Simulator

### Run

```bash
docker run --rm --name scenario-simulator ghcr.io/autowarefoundation/autoware-tools:scenario-simulator
```

### Settings

The following environment variables can be configured with `-e` while launching the scenario simulator container:

| Variable | Default Value | Possible Values | Description |
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------- | -------------------------------------------------------- |
| `SCENARIO` | [`scenario_test_runner/scenario/sample.yaml`](https://github.com/tier4/scenario_simulator_v2/blob/master/test_runner/scenario_test_runner/scenario/sample.yaml) | Any valid path | The full path to the scenario file inside the container |
| `ARCHITECTURE_TYPE` | `awf/universe/20240605` | Any valid architecture type | The architecture type to use for the scenario simulation |
| `SENSOR_MODEL` | `sample_sensor_kit` | Any valid sensor model | The sensor model to use for the scenario simulation |
| `VEHICLE_MODEL` | `sample_vehicle` | Any valid vehicle model | The vehicle model to use for the scenario simulation |
| `INITIALIZE_DURATION` | `90` | Any positive integer | The duration to initialize the scenario simulation |
| `GLOBAL_FRAME_RATE` | `30` | Any positive integer | The frame rate of the scenario simulation |
| `GLOBAL_TIMEOUT` | `120` | Any positive integer | The timeout of the scenario simulation |
| `OUTPUT_DIRECTORY` | `/autoware/scenario-sim/output` | Any valid path | The directory to save the simulation results |
| `USE_SIM_TIME` | `false` | `true`, `false` | Whether to use simulation time instead of system time |
| `RECORD` | `false` | `true`, `false` | Whether to record the scenario simulation rosbag |
- [scenario-simulator](./scenario-simulator/README.md): Simulation container for Autoware scenario testing.
- [visualizer](./visualizer/README.md): RViz-based visualization container for Autoware.
25 changes: 14 additions & 11 deletions docker/tools/scenario-simulator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO
ENV CCACHE_DIR="/root/.ccache"

COPY docker/scripts/resolve_rosdep_keys.sh /autoware/resolve_rosdep_keys.sh
RUN chmod +x /autoware/resolve_rosdep_keys.sh
COPY src/simulator /autoware/src/simulator
COPY docker/scripts/ /autoware/
RUN chmod +x /autoware/*.sh
WORKDIR /autoware

# Extract rosdep dependencies for simulator
# hadolint ignore=SC1091
RUN source /opt/autoware/setup.bash \
&& /autoware/resolve_rosdep_keys.sh /autoware/src ${ROS_DISTRO} --dependency-types=exec \
> /rosdep-simulator-exec-depend-packages.txt \
&& cat /rosdep-simulator-exec-depend-packages.txt

# Install dependencies and build the scenario simulator
# hadolint ignore=SC1091
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
Expand All @@ -17,22 +24,16 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
&& rosdep update && rosdep install -y --from-paths src --ignore-src --rosdistro $ROS_DISTRO \
&& /autoware/cleanup_apt.sh

# Build the scenario simulator
# hadolint ignore=SC1091
RUN --mount=type=cache,target=${CCACHE_DIR} \
source /opt/autoware/setup.bash \
&& /autoware/build_and_clean.sh ${CCACHE_DIR} /opt/autoware \
&& find /opt/autoware/lib -type f -name "*.py" -exec chmod +x {} \; \
&& find /opt/autoware/share -type f -name "*.py" -exec chmod +x {} \;

# Extract rosdep dependencies for simulator
# hadolint ignore=SC1091
RUN source /opt/autoware/setup.bash \
&& /autoware/resolve_rosdep_keys.sh /autoware/src ${ROS_DISTRO} --dependency-types=exec \
> /rosdep-simulator-exec-depend-packages.txt \
&& cat /rosdep-simulator-exec-depend-packages.txt

### Scenario Simulator
FROM ghcr.io/autowarefoundation/autoware:core AS scenario-simulator
FROM ghcr.io/autowarefoundation/autoware:universe AS scenario-simulator
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO
ARG LIB_DIR
Expand All @@ -46,10 +47,12 @@ RUN --mount=type=ssh \
apt-get update \
# Remove xmlschema and yamale from rosdep packages since we install via pip
&& sed -i '/\(xmlschema\|yamale\)/d' /tmp/rosdep-simulator-exec-depend-packages.txt \
&& pip install --no-cache-dir yamale xmlschema \
&& pip3 install --no-cache-dir yamale \
&& pip3 install --no-cache-dir xmlschema==3.4.5 \
&& cat /tmp/rosdep-simulator-exec-depend-packages.txt | xargs apt-get install -y --no-install-recommends \
&& /autoware/cleanup_system.sh $LIB_DIR $ROS_DISTRO

ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
COPY docker/tools/scenario-simulator/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
28 changes: 28 additions & 0 deletions docker/tools/scenario-simulator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Open AD Kit - Scenario Simulator

Runs Scenario Simulator in a container.

## Standalone Run

```bash
docker run --rm --name scenario-simulator ghcr.io/autowarefoundation/openadkit:scenario-simulator
```

## Settings

The following environment variables can be passed to the `scenario-simulator` container:

| Variable | Default Value | Possible Values | Description |
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `SCENARIO` | [`scenario_test_runner/scenario/sample.yaml`](https://github.com/tier4/scenario_simulator_v2/blob/master/test_runner/scenario_test_runner/scenario/sample.yaml) | Any valid path | The full path to the scenario file inside the container |
| `ARCHITECTURE_TYPE` | `awf/universe/20240605` | Any valid architecture type | The architecture type to use for the scenario simulation |
| `SENSOR_MODEL` | `sample_sensor_kit` | Any valid sensor model | The sensor model to use for the scenario simulation |
| `VEHICLE_MODEL` | `sample_vehicle` | Any valid vehicle model | The vehicle model to use for the scenario simulation |
| `LAUNCH_AUTOWARE` | `false` | `true`, `false` | Set to `true` to launch Autoware for standalone scenario simulation. By default, the scenario simulator expects an Autoware running. |
| `LAUNCH_RVIZ` | `true` | `true`, `false` | Set to `true` to launch RViz for the scenario simulation |
| `INITIALIZE_DURATION` | `90` | Any positive integer | The duration to initialize the scenario simulation |
| `GLOBAL_FRAME_RATE` | `30` | Any positive integer | The frame rate of the scenario simulation |
| `GLOBAL_TIMEOUT` | `120` | Any positive integer | The timeout of the scenario simulation |
| `OUTPUT_DIRECTORY` | `/autoware/scenario-sim/output` | Any valid path | The directory to save the simulation results |
| `USE_SIM_TIME` | `false` | `true`, `false` | Whether to use simulation time instead of system time |
| `RECORD` | `false` | `true`, `false` | Whether to record the scenario simulation rosbag |
23 changes: 9 additions & 14 deletions docker/tools/scenario-simulator/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,25 @@ run_scenario_simulator() {
ARCHITECTURE_TYPE=${ARCHITECTURE_TYPE:-awf/universe/20240605}
SENSOR_MODEL=${SENSOR_MODEL:-sample_sensor_kit}
VEHICLE_MODEL=${VEHICLE_MODEL:-sample_vehicle}
LAUNCH_AUTOWARE=${LAUNCH_AUTOWARE:-false}
LAUNCH_RVIZ=${LAUNCH_RVIZ:-false}
INITIALIZE_DURATION=${INITIALIZE_DURATION:-90}
GLOBAL_FRAME_RATE=${GLOBAL_FRAME_RATE:-30}
OUTPUT_DIRECTORY=${OUTPUT_DIRECTORY:-/autoware/scenario-sim/output}
SCENARIO=${SCENARIO:-$(ros2 pkg prefix --share scenario_test_runner)/scenario/sample.yaml}
GLOBAL_TIMEOUT=${GLOBAL_TIMEOUT:-120}
RECORD=${RECORD:-false}
USE_SIM_TIME=${USE_SIM_TIME:-false}

# Print all variables
echo "ARCHITECTURE_TYPE: $ARCHITECTURE_TYPE"
echo "SENSOR_MODEL: $SENSOR_MODEL"
echo "VEHICLE_MODEL: $VEHICLE_MODEL"
echo "INITIALIZE_DURATION: $INITIALIZE_DURATION"
echo "GLOBAL_FRAME_RATE: $GLOBAL_FRAME_RATE"
echo "OUTPUT_DIRECTORY: $OUTPUT_DIRECTORY"
echo "SCENARIO: $SCENARIO"
echo "GLOBAL_TIMEOUT: $GLOBAL_TIMEOUT"
echo "RECORD: $RECORD"
echo "USE_SIM_TIME: $USE_SIM_TIME"
# Prompt if no scenario is provided
if [ -z "$SCENARIO" ]; then
echo -e "\e[33mNo scenario provided, using default sample scenario...\e[0m"
SCENARIO=$(ros2 pkg prefix --share scenario_test_runner)/scenario/sample.yaml
fi

# Launch scenario test runner
ros2 launch scenario_test_runner scenario_test_runner.launch.py \
launch_autoware:=false \
launch_rviz:=false \
launch_autoware:="$LAUNCH_AUTOWARE" \
launch_rviz:="$LAUNCH_RVIZ" \
architecture_type:="$ARCHITECTURE_TYPE" \
sensor_model:="$SENSOR_MODEL" \
vehicle_model:="$VEHICLE_MODEL" \
Expand Down
1 change: 1 addition & 0 deletions docker/tools/visualizer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ RUN echo "source /opt/ros/$ROS_DISTRO/setup.bash" >> /root/.bashrc && \
echo "source /opt/autoware/setup.bash" >> /root/.bashrc

# Copy startup scripts
ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
COPY docker/tools/visualizer/xstartup /root/.vnc/xstartup
COPY docker/tools/visualizer/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh && chmod +x /root/.vnc/xstartup
Expand Down
20 changes: 20 additions & 0 deletions docker/tools/visualizer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Open AD Kit - Visualizer

Opens a remote RViz display for Autoware.

## Standalone Run

```bash
docker run --rm --name visualizer -p 6080:6080 ghcr.io/autowarefoundation/openadkit:visualizer
```

## Settings

The following environment variables can be passed to the `visualizer` container:

| Variable | Default Value | Possible Values | Description |
| ----------------- | ------------------------------ | ------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `RVIZ_CONFIG` | `/autoware/rviz/autoware.rviz` | Any valid path | The full path to the RViz configuration file inside the container |
| `REMOTE_DISPLAY` | `true` | `true`, `false` | **(Recommended)** Light-weight and browser-based RViz display, accessible from any device. |
| `REMOTE_PASSWORD` | `openadkit` | Any string without special characters | Password for remote display (only used when `REMOTE_DISPLAY=true`). |
| `LOCAL_DISPLAY` | `false` | `true`, `false` | Local RViz display, useful for debugging and development. `/tmp/.X11-unix:/tmp/.X11-unix` volume mount required to enable local display. |
Loading
Loading