diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 00000000..3224f990 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,38 @@ +name: build + +on: + schedule: + - cron: 0 19 * * 0 # run at 4 AM JST on Sundays + workflow_dispatch: + +jobs: + build: + runs-on: ${{ matrix.os }} + container: ubuntu:20.04 + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, ARM64] + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Run setup script + run: | + ./setup-dev-env.sh -y universe + + - name: Run vcs import + run: | + mkdir src + vcs import src < autoware.repos + + - name: Run rosdep install + run: | + sudo apt-get -y update + rosdep update + DEBIAN_FRONTEND=noninteractive rosdep install -y --from-paths src --ignore-src --rosdistro galactic + + - name: Build + run: | + . /opt/ros/galactic/setup.sh + colcon build --event-handlers console_cohesion+ --cmake-args -DCMAKE_BUILD_TYPE=Release diff --git a/README.md b/README.md index 01f40c97..857b0c33 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,20 @@ If you have any questions or ideas, please feel free to start a discussion on [G > Note: Detailed setup documents will be put into [autowarefoundation/autoware-documentation](https://github.com/autowarefoundation/autoware-documentation) soon. +## How to setup development environment + +```bash +./setup-dev-env.sh +``` + +This script will install the development environment for Autoware, which cannot be installed by `rosdep`. + +> Note: Please confirm the licenses before installing NVIDIA libraries. + +- [CUDA](https://docs.nvidia.com/cuda/eula/index.html) +- [cuDNN](https://docs.nvidia.com/deeplearning/cudnn/sla/index.html) +- [TensorRT](https://docs.nvidia.com/deeplearning/tensorrt/sla/index.html) + ## How to setup workspace ```bash diff --git a/ansible-galaxy-requirements.yaml b/ansible-galaxy-requirements.yaml index 2449609d..2338d6a7 100644 --- a/ansible-galaxy-requirements.yaml +++ b/ansible-galaxy-requirements.yaml @@ -1 +1,3 @@ collections: + - source: ./ansible + type: dir diff --git a/ansible/.gitignore b/ansible/.gitignore new file mode 100644 index 00000000..a8b42eb6 --- /dev/null +++ b/ansible/.gitignore @@ -0,0 +1 @@ +*.retry diff --git a/ansible/COLCON_IGNORE b/ansible/COLCON_IGNORE new file mode 100644 index 00000000..e69de29b diff --git a/ansible/README.md b/ansible/README.md new file mode 100644 index 00000000..3a252f1a --- /dev/null +++ b/ansible/README.md @@ -0,0 +1 @@ +# Ansible Collection - autoware.dev_env diff --git a/ansible/galaxy.yml b/ansible/galaxy.yml new file mode 100644 index 00000000..82d6cc9b --- /dev/null +++ b/ansible/galaxy.yml @@ -0,0 +1,20 @@ +# Required +namespace: autoware +name: dev_env +version: 0.1.0 +readme: README.md +authors: + - Kenji Miyake + +# Optional +description: Set up development environment for Autoware +license: + - Apache-2.0 +tags: + - autoware +dependencies: {} +repository: https://github.com/autowarefoundation/autoware +documentation: https://autowarefoundation.github.io/autoware-documentation +homepage: https://www.autoware.org/ +issues: https://github.com/autowarefoundation/autoware/issues +build_ignore: [] diff --git a/ansible/playbooks/core.yaml b/ansible/playbooks/core.yaml new file mode 100644 index 00000000..a1e59646 --- /dev/null +++ b/ansible/playbooks/core.yaml @@ -0,0 +1,12 @@ +- hosts: localhost + connection: local + vars: + - rosdistro: galactic + - rmw_implementation: rmw_cyclonedds_cpp + roles: + - role: autoware.dev_env.autoware_core + - role: autoware.dev_env.docker + - role: autoware.dev_env.pre_commit + - role: autoware.dev_env.ros2 + - role: autoware.dev_env.ros2_dev_tools + - role: autoware.dev_env.rmw_implementation diff --git a/ansible/playbooks/universe.yaml b/ansible/playbooks/universe.yaml new file mode 100644 index 00000000..484f1411 --- /dev/null +++ b/ansible/playbooks/universe.yaml @@ -0,0 +1,37 @@ +- hosts: localhost + connection: local + vars: + - rosdistro: galactic + - rmw_implementation: rmw_cyclonedds_cpp + - cuda_version: 11-4 + - cudnn_version: 8.2.2.26-1+cuda11.4 + - tensorrt_version: 8.2.2-1+cuda11.4 + vars_prompt: + - name: install_nvidia + prompt: |- + [Warning] Some components depend on NVIDIA libraries (CUDA, cuDNN, TensorRT), which require license agreements. + Did you confirm the licenses and are you sure to to install them? [y/N] + private: false + pre_tasks: + - name: Show warnings that NVIDIA libraries will not be installed + ansible.builtin.pause: + seconds: 10 + prompt: | + [Warning] Skipping installation of NVIDIA libraries. Please manually install them if you use the depending components. + when: install_nvidia != 'y' + roles: + # Core + - role: autoware.dev_env.autoware_core + - role: autoware.dev_env.docker + - role: autoware.dev_env.pre_commit + - role: autoware.dev_env.ros2 + - role: autoware.dev_env.ros2_dev_tools + - role: autoware.dev_env.rmw_implementation + + # Universe + - role: autoware.dev_env.autoware_universe + - role: autoware.dev_env.cuda + when: install_nvidia == 'y' + - role: autoware.dev_env.pacmod + - role: autoware.dev_env.tensorrt + when: install_nvidia == 'y' diff --git a/ansible/roles/autoware_core/README.md b/ansible/roles/autoware_core/README.md new file mode 100644 index 00000000..de34bfe1 --- /dev/null +++ b/ansible/roles/autoware_core/README.md @@ -0,0 +1,7 @@ +# autoware_core + +This role installs development/runtime dependencies for Autoware Core. + +## Inputs + +None. diff --git a/ansible/roles/autoware_core/defaults/main.yaml b/ansible/roles/autoware_core/defaults/main.yaml new file mode 100644 index 00000000..e69de29b diff --git a/ansible/roles/autoware_core/meta/main.yaml b/ansible/roles/autoware_core/meta/main.yaml new file mode 100644 index 00000000..e69de29b diff --git a/ansible/roles/autoware_core/tasks/main.yaml b/ansible/roles/autoware_core/tasks/main.yaml new file mode 100644 index 00000000..c1de001d --- /dev/null +++ b/ansible/roles/autoware_core/tasks/main.yaml @@ -0,0 +1,7 @@ +- name: Install gdown to download files from CMakeLists.txt + become: true + ansible.builtin.pip: + name: + - gdown + state: latest + executable: pip3 diff --git a/ansible/roles/autoware_universe/README.md b/ansible/roles/autoware_universe/README.md new file mode 100644 index 00000000..e9ab769d --- /dev/null +++ b/ansible/roles/autoware_universe/README.md @@ -0,0 +1,7 @@ +# autoware_universe + +This role installs development/runtime dependencies for Autoware Universe. + +## Inputs + +None. diff --git a/ansible/roles/autoware_universe/defaults/main.yaml b/ansible/roles/autoware_universe/defaults/main.yaml new file mode 100644 index 00000000..e69de29b diff --git a/ansible/roles/autoware_universe/meta/main.yaml b/ansible/roles/autoware_universe/meta/main.yaml new file mode 100644 index 00000000..41466877 --- /dev/null +++ b/ansible/roles/autoware_universe/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - autoware_core diff --git a/ansible/roles/autoware_universe/tasks/main.yaml b/ansible/roles/autoware_universe/tasks/main.yaml new file mode 100644 index 00000000..c59e688f --- /dev/null +++ b/ansible/roles/autoware_universe/tasks/main.yaml @@ -0,0 +1,12 @@ +- name: Install geographiclib-tools + become: true + ansible.builtin.apt: + name: geographiclib-tools + state: latest + update_cache: true + +- name: Install egm2008-1 + become: true + ansible.builtin.command: + cmd: geographiclib-get-geoids egm2008-1 + creates: /usr/share/GeographicLib/geoids/egm2008-1.pgm diff --git a/ansible/roles/cuda/README.md b/ansible/roles/cuda/README.md new file mode 100644 index 00000000..dcfa1bee --- /dev/null +++ b/ansible/roles/cuda/README.md @@ -0,0 +1,9 @@ +# cuda + +This role installs [CUDA Toolkit](https://developer.nvidia.com/cuda-toolkit) following [this page](https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=20.04&target_type=deb_network) and [this page](https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#post-installation-actions). + +## Inputs + +| Name | Required | Description | +| ------------ | -------- | ---------------------------- | +| cuda_version | true | The version of CUDA Toolkit. | diff --git a/ansible/roles/cuda/defaults/main.yaml b/ansible/roles/cuda/defaults/main.yaml new file mode 100644 index 00000000..e69de29b diff --git a/ansible/roles/cuda/meta/main.yaml b/ansible/roles/cuda/meta/main.yaml new file mode 100644 index 00000000..e69de29b diff --git a/ansible/roles/cuda/tasks/main.yaml b/ansible/roles/cuda/tasks/main.yaml new file mode 100644 index 00000000..cfdbc27b --- /dev/null +++ b/ansible/roles/cuda/tasks/main.yaml @@ -0,0 +1,46 @@ +- name: Get CUDA architecture name + ansible.builtin.shell: | + if [ "$(uname -m)" = "x86_64" ]; then + echo "x86_64" + else + echo "sbsa" + fi + register: cuda_architecture + changed_when: false + +- name: Download pin file + become: true + ansible.builtin.get_url: + url: https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/{{ cuda_architecture.stdout }}/cuda-ubuntu2004.pin + dest: /etc/apt/preferences.d/cuda-repository-pin-600 + +- name: Add NVIDIA apt key + become: true + ansible.builtin.apt_key: + url: https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/{{ cuda_architecture.stdout }}/7fa2af80.pub + +- name: Add CUDA repository into sources.list + become: true + ansible.builtin.apt_repository: + repo: deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/{{ cuda_architecture.stdout }}/ / + state: present + +- name: Install cuda-{{ cuda_version }} + become: true + ansible.builtin.apt: + name: cuda-{{ cuda_version }} + update_cache: true + +- name: Add PATH to .bashrc + ansible.builtin.lineinfile: + dest: ~/.bashrc + line: export PATH="/usr/local/cuda/bin:$PATH" + state: present + create: true + +- name: Add LD_LIBRARY_PATH to bashrc + ansible.builtin.lineinfile: + dest: ~/.bashrc + line: export LD_LIBRARY_PATH="/usr/local/cuda/lib64:$LD_LIBRARY_PATH" + state: present + create: true diff --git a/ansible/roles/docker/README.md b/ansible/roles/docker/README.md new file mode 100644 index 00000000..3caa7113 --- /dev/null +++ b/ansible/roles/docker/README.md @@ -0,0 +1,11 @@ +# pre_commit + +This role installs Docker environment following [this page](https://docs.docker.com/engine/install/ubuntu/) and sets up rootless execution following [this page](https://docs.docker.com/engine/install/linux-postinstall/). + +Also, it installs [rocker](https://github.com/osrf/rocker) for easy NVIDIA support. + +## Inputs + +| Name | Required | Description | +| ---------------------- | -------- | ------------------------------ | +| docker_compose_version | false | The version of Docker Compose. | diff --git a/ansible/roles/docker/defaults/main.yaml b/ansible/roles/docker/defaults/main.yaml new file mode 100644 index 00000000..9f682b03 --- /dev/null +++ b/ansible/roles/docker/defaults/main.yaml @@ -0,0 +1 @@ +docker_compose_version: v2.2.2 diff --git a/ansible/roles/docker/tasks/main.yaml b/ansible/roles/docker/tasks/main.yaml new file mode 100644 index 00000000..39712c58 --- /dev/null +++ b/ansible/roles/docker/tasks/main.yaml @@ -0,0 +1,86 @@ +- name: Uninstall old versions + become: true + ansible.builtin.apt: + name: + - docker + - docker-engine + - docker.io + - containerd + - runc + state: absent + update_cache: true + +- name: Install dependencies for setting up apt sources + become: true + ansible.builtin.apt: + name: + - ca-certificates + - curl + - gnupg + - lsb-release + update_cache: true + +# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg +- name: Authorize Docker GPG key + become: true + ansible.builtin.apt_key: + url: https://download.docker.com/linux/ubuntu/gpg + keyring: /usr/share/keyrings/docker-archive-keyring.gpg + +- name: Save result of 'dpkg --print-architecture' + ansible.builtin.command: dpkg --print-architecture + register: deb_architecture + changed_when: false + +- name: Save result of 'lsb_release -cs' + ansible.builtin.command: lsb_release -cs + register: lsb_release + changed_when: false + +# echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null +- name: Add Docker apt repository to source list + become: true + ansible.builtin.apt_repository: + repo: deb [arch={{ deb_architecture.stdout }} signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu {{ lsb_release.stdout }} stable + filename: docker + state: present + update_cache: true + +- name: Install Docker Engine + become: true + ansible.builtin.apt: + name: + - docker-ce + - docker-ce-cli + - containerd.io + update_cache: true + +# sudo groupadd docker +- name: Add docker group + become: true + ansible.builtin.group: + name: docker + state: present + +# sudo usermod -aG docker $USER +- name: Add user to docker group + become: true + ansible.builtin.user: + name: "{{ ansible_user_id }}" + groups: docker + append: true + +- name: Install Docker Compose + become: true + ansible.builtin.get_url: + url: https://github.com/docker/compose/releases/download/{{ docker_compose_version }}/docker-compose-{{ ansible_system }}-{{ ansible_architecture }} + dest: /usr/local/bin/docker-compose + force: true + mode: 0775 + +- name: Install rocker + become: true + ansible.builtin.pip: + name: rocker + state: latest + executable: pip3 diff --git a/ansible/roles/pacmod/README.md b/ansible/roles/pacmod/README.md new file mode 100644 index 00000000..09bab01d --- /dev/null +++ b/ansible/roles/pacmod/README.md @@ -0,0 +1,9 @@ +# pacmod + +This role sets up the prerequisites to install pacmod3_msgs following [this page](https://github.com/astuff/pacmod3_msgs#installation) and [this page](https://github.com/astuff/docker-builds/blob/e9f563ef04b0578ba0b545711ea3e41b20a51d27/ros2/foxy/ros-core/Dockerfile). + +## Inputs + +| Name | Required | Description | +| --------- | -------- | ----------- | +| rosdistro | true | ROS distro. | diff --git a/ansible/roles/pacmod/defaults/main.yaml b/ansible/roles/pacmod/defaults/main.yaml new file mode 100644 index 00000000..e69de29b diff --git a/ansible/roles/pacmod/meta/main.yaml b/ansible/roles/pacmod/meta/main.yaml new file mode 100644 index 00000000..4201f18a --- /dev/null +++ b/ansible/roles/pacmod/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - ros2 diff --git a/ansible/roles/pacmod/tasks/main.yaml b/ansible/roles/pacmod/tasks/main.yaml new file mode 100644 index 00000000..d7d96c54 --- /dev/null +++ b/ansible/roles/pacmod/tasks/main.yaml @@ -0,0 +1,29 @@ +- name: Install apt-transport-https + become: true + ansible.builtin.apt: + name: apt-transport-https + update_cache: true + +- name: Save result of 'lsb_release -sc' + ansible.builtin.command: lsb_release -sc + register: lsb_release + changed_when: false + +# echo "deb [trusted=yes] https://s3.amazonaws.com/autonomoustuff-repo/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/autonomoustuff-public.list +- name: Add AutonomouStuff apt repository to source list + become: true + ansible.builtin.apt_repository: + repo: deb [trusted=yes] https://s3.amazonaws.com/autonomoustuff-repo/ {{ lsb_release.stdout }} main + filename: autonomoustuff-public + state: present + update_cache: true + +# echo "yaml https://s3.amazonaws.com/autonomoustuff-repo/autonomoustuff-public-$ROS_DISTRO.yaml $ROS_DISTRO" > /etc/ros/rosdep/sources.list.d/40-autonomoustuff-public-'$ROS_DISTRO'.list +- name: Add AutonomouStuff rosdep yaml + become: true + ansible.builtin.lineinfile: + path: /etc/ros/rosdep/sources.list.d/40-autonomoustuff-public-{{ rosdistro }}.list + line: yaml https://s3.amazonaws.com/autonomoustuff-repo/autonomoustuff-public-{{ rosdistro }}.yaml + state: present + create: true + mode: 0644 diff --git a/ansible/roles/pre_commit/README.md b/ansible/roles/pre_commit/README.md new file mode 100644 index 00000000..bf5d05b7 --- /dev/null +++ b/ansible/roles/pre_commit/README.md @@ -0,0 +1,9 @@ +# pre_commit + +This role installs dependent tools for [pre-commit](https://pre-commit.com/). + +## Inputs + +| Name | Required | Description | +| -------------------- | -------- | --------------------------- | +| clang_format_version | false | The version of ClangFormat. | diff --git a/ansible/roles/pre_commit/defaults/main.yaml b/ansible/roles/pre_commit/defaults/main.yaml new file mode 100644 index 00000000..9ed7cf8a --- /dev/null +++ b/ansible/roles/pre_commit/defaults/main.yaml @@ -0,0 +1 @@ +clang_format_version: 13.0.0 diff --git a/ansible/roles/pre_commit/tasks/main.yaml b/ansible/roles/pre_commit/tasks/main.yaml new file mode 100644 index 00000000..1d464fb1 --- /dev/null +++ b/ansible/roles/pre_commit/tasks/main.yaml @@ -0,0 +1,19 @@ +- name: Install clang-format + become: true + ansible.builtin.pip: + name: clang-format + version: "{{ clang_format_version }}" + executable: pip3 + +# TODO: Remove after we move to Ubuntu 22.04 +- name: Add Go PPA for shfmt + become: true + ansible.builtin.apt_repository: + repo: ppa:longsleep/golang-backports # cspell:disable-line + +- name: Install Go + become: true + ansible.builtin.apt: + name: golang + state: latest + update_cache: true diff --git a/ansible/roles/rmw_implementation/README.md b/ansible/roles/rmw_implementation/README.md new file mode 100644 index 00000000..a8355d79 --- /dev/null +++ b/ansible/roles/rmw_implementation/README.md @@ -0,0 +1,10 @@ +# rmw_implementation + +This role sets up ROS 2 RMW implementation following [this page](https://docs.ros.org/en/galactic/How-To-Guides/Working-with-multiple-RMW-implementations.html). + +## Inputs + +| Name | Required | Description | +| ------------------ | -------- | ------------------- | +| rosdistro | true | ROS distro. | +| rmw_implementation | true | RMW implementation. | diff --git a/ansible/roles/rmw_implementation/defaults/main.yaml b/ansible/roles/rmw_implementation/defaults/main.yaml new file mode 100644 index 00000000..e69de29b diff --git a/ansible/roles/rmw_implementation/meta/main.yaml b/ansible/roles/rmw_implementation/meta/main.yaml new file mode 100644 index 00000000..4201f18a --- /dev/null +++ b/ansible/roles/rmw_implementation/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - ros2 diff --git a/ansible/roles/rmw_implementation/tasks/main.yaml b/ansible/roles/rmw_implementation/tasks/main.yaml new file mode 100644 index 00000000..a5d482c5 --- /dev/null +++ b/ansible/roles/rmw_implementation/tasks/main.yaml @@ -0,0 +1,18 @@ +- name: Get kebab-case name + ansible.builtin.shell: bash -c 'sed -e "s/_/-/g" <<< $(echo {{ rmw_implementation }})' + register: kebab_case_name + changed_when: false + +- name: Install ros-{{ rosdistro }}-{{ kebab_case_name.stdout }} + become: true + ansible.builtin.apt: + name: ros-{{ rosdistro }}-{{ kebab_case_name.stdout }} + state: latest + update_cache: true + +- name: Add RMW_IMPLEMENTATION to .bashrc + ansible.builtin.lineinfile: + dest: ~/.bashrc + line: export RMW_IMPLEMENTATION={{ rmw_implementation }} + state: present + create: true diff --git a/ansible/roles/ros2/README.md b/ansible/roles/ros2/README.md new file mode 100644 index 00000000..b60e4b9c --- /dev/null +++ b/ansible/roles/ros2/README.md @@ -0,0 +1,22 @@ +# ros2 + +This role installs [ROS 2](http://www.ros2.org/) following [this page](https://docs.ros.org/en/galactic/Installation/Ubuntu-Install-Debians.html). + +Additional steps may be needed depending on the `rosdistro` you choose. + + + +```bash +$ sudo apt install software-properties-common +$ sudo add-apt-repository universe +$ apt-cache policy | grep universe + 500 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 Packages + release v=20.04,o=Ubuntu,a=focal,n=focal,l=Ubuntu,c=universe,b=amd64 +``` + +## Inputs + +| Name | Required | Description | +| ----------------- | -------- | ------------------------------------------------ | +| rosdistro | true | ROS distro. | +| installation_type | false | The installation type (`desktop` or `ros-base`). | diff --git a/ansible/roles/ros2/defaults/main.yaml b/ansible/roles/ros2/defaults/main.yaml new file mode 100644 index 00000000..fca2d3a0 --- /dev/null +++ b/ansible/roles/ros2/defaults/main.yaml @@ -0,0 +1 @@ +installation_type: desktop diff --git a/ansible/roles/ros2/meta/main.yaml b/ansible/roles/ros2/meta/main.yaml new file mode 100644 index 00000000..e69de29b diff --git a/ansible/roles/ros2/tasks/main.yaml b/ansible/roles/ros2/tasks/main.yaml new file mode 100644 index 00000000..61794b20 --- /dev/null +++ b/ansible/roles/ros2/tasks/main.yaml @@ -0,0 +1,48 @@ +- name: Install dependencies for setting up apt sources + become: true + ansible.builtin.apt: + name: + - curl + - gnupg + - lsb-release + update_cache: true + +# sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg +- name: Authorize ROS GPG key + become: true + ansible.builtin.get_url: + url: https://raw.githubusercontent.com/ros/rosdistro/master/ros.key + dest: /usr/share/keyrings/ros-archive-keyring.gpg + +- name: Save result of 'dpkg --print-architecture' + ansible.builtin.command: dpkg --print-architecture + register: deb_architecture + changed_when: false + +- name: Save result of 'source /etc/os-release && echo $UBUNTU_CODENAME' + ansible.builtin.shell: bash -c 'source /etc/os-release && echo $UBUNTU_CODENAME' + register: ubuntu_codename + changed_when: false + +# echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null +- name: Add ROS 2 apt repository to source list + become: true + ansible.builtin.apt_repository: + repo: deb [arch={{ deb_architecture.stdout }} signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu {{ ubuntu_codename.stdout }} main + filename: ros2 + state: present + update_cache: true + +- name: Install ros-{{ rosdistro }}-{{ installation_type }} + become: true + ansible.builtin.apt: + name: ros-{{ rosdistro }}-{{ installation_type }} + state: latest + update_cache: true + +- name: Add PATH to .bashrc + ansible.builtin.lineinfile: + dest: ~/.bashrc + line: source /opt/ros/{{ rosdistro }}/setup.bash + state: present + create: true diff --git a/ansible/roles/ros2_dev_tools/README.md b/ansible/roles/ros2_dev_tools/README.md new file mode 100644 index 00000000..e35b462d --- /dev/null +++ b/ansible/roles/ros2_dev_tools/README.md @@ -0,0 +1,7 @@ +# ros2_dev_tools + +This role installs ROS 2 development tools following [this page](https://docs.ros.org/en/galactic/Installation/Ubuntu-Development-Setup.html). + +## Inputs + +None. diff --git a/ansible/roles/ros2_dev_tools/defaults/main.yaml b/ansible/roles/ros2_dev_tools/defaults/main.yaml new file mode 100644 index 00000000..e69de29b diff --git a/ansible/roles/ros2_dev_tools/meta/main.yaml b/ansible/roles/ros2_dev_tools/meta/main.yaml new file mode 100644 index 00000000..4201f18a --- /dev/null +++ b/ansible/roles/ros2_dev_tools/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - ros2 diff --git a/ansible/roles/ros2_dev_tools/tasks/main.yaml b/ansible/roles/ros2_dev_tools/tasks/main.yaml new file mode 100644 index 00000000..ae4919c0 --- /dev/null +++ b/ansible/roles/ros2_dev_tools/tasks/main.yaml @@ -0,0 +1,42 @@ +- name: Install apt packages + become: true + ansible.builtin.apt: + name: + - build-essential + - cmake + - git + - python3-colcon-common-extensions + - python3-flake8 + - python3-pip + - python3-pytest-cov + - python3-rosdep + - python3-setuptools + - python3-vcstool + - wget + state: latest + update_cache: true + +- name: Install pip packages + become: true + ansible.builtin.pip: + name: + - flake8-blind-except + - flake8-builtins + - flake8-class-newline + - flake8-comprehensions + - flake8-deprecated + - flake8-docstrings + - flake8-import-order + - flake8-quotes + - pytest-repeat + - pytest-rerunfailures + - pytest + - setuptools + state: latest + executable: pip3 + +- name: Run 'sudo rosdep init' + become: true + ansible.builtin.command: + cmd: rosdep init + creates: /etc/ros/rosdep/sources.list.d/20-default.list diff --git a/ansible/roles/tensorrt/README.md b/ansible/roles/tensorrt/README.md new file mode 100644 index 00000000..1ab6b419 --- /dev/null +++ b/ansible/roles/tensorrt/README.md @@ -0,0 +1,10 @@ +# tensorrt + +This role installs TensorRT and cuDNN following [this page](https://docs.nvidia.com/deeplearning/tensorrt/install-guide/index.html#installing). + +## Inputs + +| Name | Required | Description | +| ---------------- | -------- | ------------------------ | +| cudnn_version | true | The version of cuDNN. | +| tensorrt_version | true | The version of TensorRT. | diff --git a/ansible/roles/tensorrt/defaults/main.yaml b/ansible/roles/tensorrt/defaults/main.yaml new file mode 100644 index 00000000..e69de29b diff --git a/ansible/roles/tensorrt/meta/main.yaml b/ansible/roles/tensorrt/meta/main.yaml new file mode 100644 index 00000000..30c16f55 --- /dev/null +++ b/ansible/roles/tensorrt/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - cuda diff --git a/ansible/roles/tensorrt/tasks/main.yaml b/ansible/roles/tensorrt/tasks/main.yaml new file mode 100644 index 00000000..1978d5b0 --- /dev/null +++ b/ansible/roles/tensorrt/tasks/main.yaml @@ -0,0 +1,34 @@ +- name: Install cuDNN and TensorRT + become: true + ansible.builtin.apt: + name: + - libcudnn8={{ cudnn_version }} + - libcudnn8-dev={{ cudnn_version }} + - libnvinfer8={{ tensorrt_version }} + - libnvinfer-dev={{ tensorrt_version }} + - libnvinfer-plugin8={{ tensorrt_version }} + - libnvinfer-plugin-dev={{ tensorrt_version }} + - libnvonnxparsers8={{ tensorrt_version }} + - libnvonnxparsers-dev={{ tensorrt_version }} + - libnvparsers8={{ tensorrt_version }} + - libnvparsers-dev={{ tensorrt_version }} + allow_downgrade: true + update_cache: true + +# apt-mark hold +- name: Prevent CUDA-related packages from upgrading + become: true + ansible.builtin.dpkg_selections: + name: "{{ item }}" + selection: hold + with_items: + - libcudnn8 + - libcudnn8-dev + - libnvinfer8 + - libnvinfer-dev + - libnvinfer-plugin8 + - libnvinfer-plugin-dev + - libnvonnxparsers8 + - libnvonnxparsers-dev + - libnvparsers8 + - libnvparsers-dev diff --git a/autoware.repos b/autoware.repos index a684f044..37b88505 100644 --- a/autoware.repos +++ b/autoware.repos @@ -41,23 +41,23 @@ repositories: type: git url: https://github.com/tier4/topic_tools.git version: tier4/main - # simulator - simulator/scenario_simulator: - type: git - url: https://github.com/tier4/scenario_simulator_v2.git - version: master - simulator/vendor/quaternion_operation: - type: git - url: https://github.com/OUXT-Polaris/quaternion_operation.git - version: f08cd28b357f9feede55f1fb485cb21964f5d594 - simulator/tmp/tier4_autoware_msgs: # TODO(Tier IV): Remove depends from scenario_simulator - type: git - url: https://github.com/tier4/AutowareArchitectureProposal_msgs.git - version: main - simulator/tmp/api_adaptor: # TODO(Tier IV): Remove depends from scenario_simulator - type: git - url: https://github.com/tier4/AutowareArchitectureProposal_api_adaptor.git - version: tier4/universe + # # simulator + # simulator/scenario_simulator: + # type: git + # url: https://github.com/tier4/scenario_simulator_v2.git + # version: master + # simulator/vendor/quaternion_operation: + # type: git + # url: https://github.com/OUXT-Polaris/quaternion_operation.git + # version: f08cd28b357f9feede55f1fb485cb21964f5d594 + # simulator/tmp/tier4_autoware_msgs: # TODO(Tier IV): Remove depends from scenario_simulator + # type: git + # url: https://github.com/tier4/AutowareArchitectureProposal_msgs.git + # version: main + # simulator/tmp/api_adaptor: # TODO(Tier IV): Remove depends from scenario_simulator + # type: git + # url: https://github.com/tier4/AutowareArchitectureProposal_api_adaptor.git + # version: tier4/universe # sensor_component sensor_component/tmp/velodyne_description: # TODO(Tier IV): Remove after https://github.com/ros/rosdistro/pull/31611 is released type: git diff --git a/setup-dev-env.sh b/setup-dev-env.sh new file mode 100755 index 00000000..c9684ba6 --- /dev/null +++ b/setup-dev-env.sh @@ -0,0 +1,102 @@ +#!/usr/bin/env bash +# Setup development environment for Autoware Core/Universe. +# Usage: setup-dev-env.sh [-y] [-v] [--no-nvidia] +# Note: -y option is only for CI. + +set -e + +SCRIPT_DIR=$(readlink -f "$(dirname "$0")") + +# Parse arguments +args=() +while [ "$1" != "" ]; do + case "$1" in + -y) + option_yes=true + ;; + -v) + option_verbose=true + ;; + --no-nvidia) + option_no_nvidia=true + ;; + *) + args+=("$1") + ;; + esac + shift +done + +# Select installation type +core_universe=universe # default + +if [ ${#args[@]} -ge 1 ]; then + core_universe=${args[0]} +fi + +if [ "$core_universe" != "core" ] && [ "$core_universe" != "universe" ]; then + echo -e "\e[31mPlease input a valid installation type 'core' or 'universe' as the 1st argument, or keep it empty to use the default.\e[m" + exit 1 +fi + +# Initialize ansible args +ansible_args=() + +# Confirm to start installation +if [ "$option_yes" = "true" ]; then + echo -e "\e[36mRun setup in non-interactive mode.\e[m" +else + echo -e "\e[33mSetting up the build environment take up to 1 hour.\e[m" + read -rp "> Are you sure to run setup? [y/N] " answer + + # Check whether to cancel + if ! [[ ${answer:0:1} =~ y|Y ]]; then + echo -e "\e[33mCancelled.\e[0m" + exit 1 + fi + + ansible_args+=("--ask-become-pass") +fi + +# Check verbose option +if [ "$option_verbose" = "true" ]; then + ansible_args+=("-v") +fi + +# Check NVIDIA Installation +if [ "$option_no_nvidia" = "true" ]; then + ansible_args+=("--extra-vars" "install_nvidia=n") +elif [ "$option_yes" = "true" ]; then + ansible_args+=("--extra-vars" "install_nvidia=y") +fi + +# Install sudo +if ! (command -v sudo >/dev/null 2>&1); then + apt-get -y update + apt-get -y install sudo +fi + +# Install pip for ansible +if ! (command -v pip3 >/dev/null 2>&1); then + sudo apt-get -y update + sudo apt-get -y install python3-pip +fi + +# Install ansible +ansible_version=$(pip3 list | grep -oP "^ansible\s+\K([0-9]+)" || true) +if [ "$ansible_version" != "5" ]; then + sudo pip3 install -U "ansible==5.*" +fi + +# Install ansible collections +ansible-galaxy collection install -f -r "$SCRIPT_DIR/ansible-galaxy-requirements.yaml" + +# Run ansible +echo Run ansible-playbook "autoware.dev_env.$core_universe" "${ansible_args[@]}" +if ansible-playbook "autoware.dev_env.$core_universe" "${ansible_args[@]}"; then + echo -e "\e[32mCompleted.\e[0m" + exit 0 +else + echo -e "\e[31mFailed.\e[0m" + exit 1 +fi