diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..85a56f0 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,98 @@ +### +### Base: base image +### + +FROM ubuntu:20.04 AS base +LABEL maintainer="James Goppert " + +# Set default shell during Docker image build to bash +SHELL ["/bin/bash", "-c"] + +COPY docker_clean.sh /docker_clean.sh +RUN chmod +x /docker_clean.sh + +# Install base packages +RUN apt-get -y update && \ + apt-get -y upgrade && \ + apt-get install --no-install-recommends -y \ + sudo \ + locales \ + && \ + /docker_clean.sh + +# set locale +RUN locale-gen en_US.UTF-8 + +# set user as default so install scripts look the same for local host install +RUN groupadd -r -g 110 render \ + && adduser --disabled-password --gecos '' user \ + && adduser user sudo \ + && adduser user render \ + && echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers +USER user + +# initialise system locale +ENV LANG=en_US.UTF-8 +ENV LANGUAGE=en_US:en +ENV LC_ALL=en_US.UTF-8 +# required to allow nanopb to build on ubuntu 22.04 currently +ENV PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python +ENV XDG_RUNTIME_DIR=/tmp/runtime-docker + +# install dependencies using scripts in a manner that will cache build +# when one script is modified +COPY install/base.sh /tmp/install/base.sh +RUN /tmp/install/base.sh && /docker_clean.sh + +### +### Build: bare minimum to run the simulator +### +FROM base AS sim + +### +### Build: bare minimum to build the binary +### +FROM base AS build + +COPY install/ros.sh /tmp/install/ros.sh +RUN /tmp/install/ros.sh && /docker_clean.sh + +COPY install/gazebo.sh /tmp/install/gazebo.sh +RUN /tmp/install/gazebo.sh && /docker_clean.sh + +COPY install/open_vino.sh /tmp/install/open_vino.sh +RUN /tmp/install/open_vino.sh && /docker_clean.sh + +COPY install/extra.sh /tmp/install/extra.sh +RUN /tmp/install/extra.sh && /docker_clean.sh + +# enable apt auto-completion by deleting autoclean task +RUN sudo rm /etc/apt/apt.conf.d/docker-clean + +# create setting directory for ignition gazebo +RUN mkdir -p /home/user/.ignition \ + && chown -R user:user /home/user/.ignition + +# avoid .bashrc warning +RUN mkdir -p /home/user/.bash_completion.d + +# create XDG runtime dir +RUN mkdir /tmp/runtime-docker && sudo chmod 700 /tmp/runtime-docker + +# create src dir +RUN sudo mkdir -p /workdir && sudo chown -R user:user /workdir && mkdir -p /workdir/src + +# setup .bashrc +RUN mkdir -p /home/user/.bash_completion.d && \ + echo "source /home/user/ws/devel/setup.bash" >> ~/.bashrc + +# enable entrypoint +ENV PATH="/home/user/bin:${PATH}" +ENV DISPLAY=${DISPLAY} + +WORKDIR /workdir +COPY entrypoint.sh / +RUN sudo chmod +x /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] + +# vim: set et fenc=utf-8 ff=unix ft=dockerfile sts=0 sw=2 ts=2 : diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..4a20624 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,54 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/docker-existing-docker-compose +// If you want to run as a non-root user in the container, see .devcontainer/docker-compose.yml. +{ + "name": "auav", + + // Update the 'dockerComposeFile' list if you have more compose files or use different names. + // The .devcontainer/docker-compose.yml file contains any overrides you need/want to make. + "dockerComposeFile": [ + "./docker-compose.yml" + ], + + // The 'service' property is the name of the service for the container that VS Code should + // use. Update this value and .devcontainer/docker-compose.yml to the real service name. + "service": "auav", + + // The optional 'workspaceFolder' property is the path VS Code should open by default when + // connected. This is typically a file mount in .devcontainer/docker-compose.yml + "workspaceFolder": "/workdir", + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Uncomment the next line if you want start specific services in your Docker Compose config. + // "runServices": [], + + // Uncomment the next line if you want to keep your containers running after VS Code shuts down. + // "shutdownAction": "none", + + // Uncomment the next line to run commands after the container is created - for example installing curl. + // "postCreateCommand": "apt-get update && apt-get install -y curl", + + // Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root. + // "remoteUser": "vscode" + + "customizations": { + // Configure properties specific to VS Code. + "vscode": { + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "ms-azuretools.vscode-docker", + "ms-vscode.cpptools", + "ms-vscode.cmake-tools", + "ms-vscode.cpptools-extension-pack", + "ms-vscode.cpptools-themes", + "trond-snekvik.devicetree", + "trond-snekvik.kconfig-lang", + "ms-python.python", + "eamodio.gitlens", + "akiramiyakoda.cppincludeguard" + ] + } + } +} diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 0000000..9cdcd4f --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,32 @@ +version: "3.9" + +volumes: + # remembers ignition config, downloaded models etc + ignition_config: + +services: + + auav: + image: jgoppert/auav_23_ros1:latest + build: + context: . + tty: true + stdin_open: true + privileged: true + hostname: auav + devices: + - /dev/net/tun:/dev/net/tun + environment: + - DISPLAY=${DISPLAY} + volumes: + - ./workdir:/workdir + - ..:/workdir/src/ + - /tmp/.X11-unix:/tmp/.X11-unix:ro + - ignition_config:/home/user/.ignition:rw + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: 1 + capabilities: [gpu] diff --git a/.devcontainer/docker_clean.sh b/.devcontainer/docker_clean.sh new file mode 100644 index 0000000..2ee2875 --- /dev/null +++ b/.devcontainer/docker_clean.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -e +sudo apt-get clean -y +sudo apt-get autoremove --purge -y +sudo rm -rf /var/lib/apt/lists/* +sudo rm -rf /tmp/* diff --git a/.devcontainer/entrypoint.sh b/.devcontainer/entrypoint.sh new file mode 100644 index 0000000..282e830 --- /dev/null +++ b/.devcontainer/entrypoint.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +bash diff --git a/.devcontainer/install/base.sh b/.devcontainer/install/base.sh new file mode 100755 index 0000000..36e5419 --- /dev/null +++ b/.devcontainer/install/base.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -e + +sudo apt-get -y update +sudo apt-get -y upgrade +sudo DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ + bash-completion \ + build-essential \ + curl \ + git \ + gnupg \ + lsb-release \ + python3-pip \ + python3-setuptools \ + python3-venv \ + unzip \ + wget diff --git a/.devcontainer/install/docker.sh b/.devcontainer/install/docker.sh new file mode 100755 index 0000000..b970ae1 --- /dev/null +++ b/.devcontainer/install/docker.sh @@ -0,0 +1,18 @@ +#!/bin/bash -x +sudo apt-get update +sudo apt-get install \ + ca-certificates \ + curl \ + gnupg \ + lsb-release +sudo mkdir -p /etc/apt/keyrings +curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg + +echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null + +sudo apt-get update +sudo chmod a+r /etc/apt/keyrings/docker.gpg +sudo apt-get update + +sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin +sudo docker run hello-world diff --git a/.devcontainer/install/extra.sh b/.devcontainer/install/extra.sh new file mode 100755 index 0000000..6625a1a --- /dev/null +++ b/.devcontainer/install/extra.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +sudo apt-get -y update +sudo apt-get -y upgrade +sudo DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ + screen \ + tcpdump \ + vim diff --git a/.devcontainer/install/gazebo.sh b/.devcontainer/install/gazebo.sh new file mode 100755 index 0000000..3e8468f --- /dev/null +++ b/.devcontainer/install/gazebo.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +sudo wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg +echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null +sudo apt-get -y update +sudo apt-get -y upgrade +sudo DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ + gazebo11 diff --git a/.devcontainer/install/open_vino.sh b/.devcontainer/install/open_vino.sh new file mode 100755 index 0000000..23b122c --- /dev/null +++ b/.devcontainer/install/open_vino.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# install openvino +# source: https://docs.openvino.ai/latest/openvino_docs_install_guides_installing_openvino_apt.html +wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB +sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB && rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB +sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ACFA9FC57E6C5DBE +echo "deb https://apt.repos.intel.com/openvino/2022 focal main" | sudo tee /etc/apt/sources.list.d/intel-openvino-2022.list +sudo apt update +sudo apt install openvino libngraph0-dev +SOURCE_OPENVINO="source /opt/intel/openvino_2022/setupvars.sh" +grep -qxF "$SOURCE_OPENVINO" ~/.bashrc || echo "$SOURCE_OPENVINO" >> ~/.bashrc +source ~/.bashrc diff --git a/.devcontainer/install/ros.sh b/.devcontainer/install/ros.sh new file mode 100755 index 0000000..960dabd --- /dev/null +++ b/.devcontainer/install/ros.sh @@ -0,0 +1,14 @@ +#!/bin/bash +set -e +ROS_VERSION="noetic" + +sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' +curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add - +sudo apt-get -y update +sudo apt-get -y upgrade +sudo DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ + ros-${ROS_VERSION}-desktop-full \ + python3-rosdep \ + python3-catkin-tools + +pip install pymavlink --user diff --git a/.devcontainer/workdir/.gitignore b/.devcontainer/workdir/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/.devcontainer/workdir/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore