Skip to content

Commit

Permalink
Add files to run autoware.proj on a Docker container (#215)
Browse files Browse the repository at this point in the history
Co-authored-by: Kenji Miyake <kenji.miyake@tier4.jp>
  • Loading branch information
IshitaTakeshi and Kenji Miyake authored Aug 16, 2021
1 parent ec9f1ea commit a30aacb
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ repos:
- id: shellcheck

- repo: https://github.com/hadolint/hadolint
rev: v2.6.1
rev: v2.6.0
hooks:
- id: hadolint
- id: hadolint-docker

exclude: ".svg"
35 changes: 35 additions & 0 deletions docker/Dockerfile.base
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM ubuntu:20.04
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

## Install APT packages
# hadolint ignore=DL3008
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
ansible \
curl \
git \
gnupg \
lsb-release \
python3-pip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

## Install vcstool
# hadolint ignore=DL3008
RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null \
&& apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends python3-vcstool \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

## Setup build environment in a temporary directory
# hadolint ignore=DL3003
RUN --mount=type=ssh \
mkdir -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts \
&& git clone git@github.com:tier4/autoware.proj.git -b main /tmp/autoware.proj \
&& cd /tmp/autoware.proj \
&& mkdir src \
&& vcs import src < autoware.proj.repos \
&& ./setup_ubuntu20.04.sh -c \
&& rm -rf /tmp/autoware.proj \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
19 changes: 19 additions & 0 deletions docker/Dockerfile.pre-built
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM autoware:base
# SHELL ["/bin/bash", "-o", "pipefail", "-c"]

## Copy autoware.proj.repos to the workspace
COPY autoware.proj.repos /autoware/autoware.proj.repos
WORKDIR /autoware

## Build
# hadolint ignore=DL3003,SC1091
RUN --mount=type=ssh \
mkdir src \
&& vcs import src < autoware.proj.repos \
&& source /opt/ros/galactic/setup.bash \
&& colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release

## Create entrypoint
COPY docker/entrypoint.sh /
ENTRYPOINT [ "/entrypoint.sh" ]
CMD ["/bin/bash"]
59 changes: 59 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Dockerfile for autoware.proj

This directory contains files to run autoware.proj on Docker.

## Build

Just run `build.sh` in this directory. This takes some time.

```sh
./docker/build.sh
```

## Run

### Prerequisites

- [rocker](https://github.com/osrf/rocker)

To enable GUI applications on Docker Containers, this script uses `rocker`.
Please see [here](http://wiki.ros.org/docker/Tutorials/GUI) for more details.

```sh
sudo apt-get install python3-rocker
```

### Examples

#### How to do a rosbag Simulation

```sh
# Build your docker image
cd ~/
git clone git@github.com:tier4/autoware.proj.git
~/autoware.proj/docker/build.sh

# Create and move to a workspace
mkdir ~/rosbag_simulation
cd ~/rosbag_simulation

# Download a sample map
gdown --id 1ovrJcFS5CZ2H51D8xVWNtEvj_oiXW-zk
unzip rosbag_sample_map.zip -d map

# Download a sample rosbag file
mkdir sample
cd sample
gdown --id 1wLWyOlfH_-k4VYBgae1KAFlKdwJnH_si

# Accept X-access from localhost
xhost +local:

# Run Autoware in the simulation mode
rocker --nvidia --x11 --user --volume ~/rosbag_simulation -- autoware:pre-built
ros2 launch autoware_launch logging_simulator.launch.xml map_path:=$HOME/rosbag_simulation/map vehicle_model:=lexus sensor_model:=aip_xx1

# Play the sample rosbag file in another terminal
rocker --nvidia --x11 --user --volume ~/rosbag_simulation -- autoware:pre-built
ros2 bag play ~/rosbag_simulation/sample/sample.625-2.bag2_0.db3 -r 0.2
```
7 changes: 7 additions & 0 deletions docker/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

SCRIPT_DIR=$(readlink -f "$(dirname "$0")")

AUTOWARE_PROJ_ROOT="$SCRIPT_DIR/../"
DOCKER_BUILDKIT=1 docker build -t autoware:base --ssh default -f "$SCRIPT_DIR/Dockerfile.base" "$AUTOWARE_PROJ_ROOT"
DOCKER_BUILDKIT=1 docker build -t autoware:pre-built --ssh default -f "$SCRIPT_DIR/Dockerfile.pre-built" "$AUTOWARE_PROJ_ROOT"
5 changes: 5 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

# shellcheck disable=SC1091
source /autoware/install/setup.bash
exec "$@"

0 comments on commit a30aacb

Please sign in to comment.