From 865257f68ed272cc28b83b5aeb73c992f6d9abee Mon Sep 17 00:00:00 2001 From: Michael Wrock Date: Thu, 24 Oct 2024 15:06:35 -0700 Subject: [PATCH] added required files --- .github/workflows/ci.yaml | 30 ++++++++ .github/workflows/format.yaml | 17 +++++ .pre-commit-config.yaml | 85 +++++++++++++++++++++++ .prettierrc.cjs | 5 ++ CONTRIBUTING.md | 7 ++ Dockerfile | 124 ++++++++++++++++++++++++++++++++++ LICENSE | 29 ++++++++ README.md | 8 ++- colcon-defaults.yaml | 19 ++++++ docker-compose.yaml | 106 +++++++++++++++++++++++++++++ 10 files changed, 429 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/format.yaml create mode 100644 .pre-commit-config.yaml create mode 100644 .prettierrc.cjs create mode 100644 CONTRIBUTING.md create mode 100644 Dockerfile create mode 100644 LICENSE create mode 100644 colcon-defaults.yaml create mode 100644 docker-compose.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..69ccf1f5 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,30 @@ +name: CI +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + inputs: + image_tag: + description: 'The tag of the image to use for the container' + required: false + default: '' + # Run every 6 hours Mon-Fri + schedule: + - cron: "0 */6 * * 1-5" + +jobs: + integration-test-in-studio-container: + uses: PickNikRobotics/moveit_pro_ci/.github/workflows/workspace_integration_test.yaml@virtual-buffer + with: + image_tag: ${{ github.event.inputs.image_tag || null }} + colcon_test_args: "--executor sequential" + secrets: inherit + + ensure-no-ssh-in-gitmodules: + name: Ensure no SSH URLs in .gitmodules + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + - name: Check .gitmodules file for Git-over-SSH URLs + run: "! grep 'git@' .gitmodules" diff --git a/.github/workflows/format.yaml b/.github/workflows/format.yaml new file mode 100644 index 00000000..8107c173 --- /dev/null +++ b/.github/workflows/format.yaml @@ -0,0 +1,17 @@ +name: Format + +on: + workflow_dispatch: + pull_request: + push: + branches: + - main + +jobs: + pre-commit: + name: pre-commit + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v3 + - uses: pre-commit/action@v3.0.0 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..23e59a05 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,85 @@ +# To use: +# +# pre-commit run -a +# +# Or: +# +# pre-commit install # (runs every time you commit in git) +# +# To update this file: +# +# pre-commit autoupdate +# +# See https://github.com/pre-commit/pre-commit +repos: + # Standard hooks + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.4.0 + hooks: + - id: check-ast + - id: check-case-conflict + - id: check-docstring-first + - id: check-merge-conflict + - id: check-symlinks + - id: check-yaml + args: ["--unsafe"] # Fixes errors parsing custom YAML constructors like ur_description's !degrees + - id: debug-statements + - id: end-of-file-fixer + exclude: (\.(svg|stl|dae))$ + - id: mixed-line-ending + - id: fix-byte-order-marker + + - repo: https://github.com/psf/black + rev: 22.3.0 + hooks: + - id: black + + - repo: https://github.com/codespell-project/codespell + rev: v2.0.0 + hooks: + - id: codespell + args: ["--write-changes", "-L", "atleast,inout,ether"] # Provide a comma-separated list of misspelled words that codespell should ignore (for example: '-L', 'word1,word2,word3'). + exclude: \.(svg|pyc|stl|dae|lock)$ + + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v14.0.6 + hooks: + - id: clang-format + files: \.(c|cc|cxx|cpp|frag|glsl|h|hpp|hxx|ih|ispc|ipp|java|m|proto|vert)$ + # -i arg is included by default by the hook + args: ["-fallback-style=none"] + + - repo: https://github.com/adrienverge/yamllint + rev: v1.27.1 + hooks: + - id: yamllint + args: + [ + "--no-warnings", + "--config-data", + "{extends: default, rules: {line-length: disable, braces: {max-spaces-inside: 1}}}", + ] + types: [text] + files: \.(yml|yaml)$ + + - repo: https://github.com/tcort/markdown-link-check + rev: v3.10.3 + hooks: + - id: markdown-link-check + + # NOTE: Broken on arm64. Will need to bump once https://github.com/hadolint/hadolint/issues/840 is fixed. + - repo: https://github.com/hadolint/hadolint + rev: v2.10.0 + hooks: + - id: hadolint-docker + + - repo: https://github.com/pre-commit/mirrors-prettier + rev: "v3.1.0" + hooks: + # Use Prettier to lint XML files because, well.. its rules are prettier than most linters, as the name implies. + # Also we use it in the UI, so it's familiar. + - id: prettier + additional_dependencies: + - "prettier@3.1.0" + - "@prettier/plugin-xml@3.3.1" + files: \.(xml)$ diff --git a/.prettierrc.cjs b/.prettierrc.cjs new file mode 100644 index 00000000..4e04acc2 --- /dev/null +++ b/.prettierrc.cjs @@ -0,0 +1,5 @@ +module.exports = { + plugins: [require.resolve("@prettier/plugin-xml")], + xmlWhitespaceSensitivity: "ignore", + xmlQuoteAttributes: "double" +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..be449dc4 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,7 @@ +Any contribution that you make to this repository will +be under the 3-Clause BSD License, as dictated by that +[license](https://opensource.org/licenses/BSD-3-Clause). + +# Contributing to this Repository + +Thanks for getting involved! If you want to add to this repository, please reach out to support@picknik.ai. diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..8006e4e0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,124 @@ +# Docker image for extending MoveIt Pro with a custom overlay. +# +# Example build command (with defaults): +# +# docker build -f ./Dockerfile . +# + +# Specify the MoveIt Pro release to build on top of. +ARG MOVEIT_STUDIO_BASE_IMAGE +ARG USERNAME=studio-user +ARG USER_UID=1000 +ARG USER_GID=1000 + +################################################## +# Starting from the specified MoveIt Pro release # +################################################## +# The image tag is specified in the argument itself. +# hadolint ignore=DL3006 +FROM ${MOVEIT_STUDIO_BASE_IMAGE} AS base + +# Create a non-root user +ARG USERNAME +ARG USER_UID +ARG USER_GID + +# Copy source code from the workspace's ROS 2 packages to a workspace inside the container +ARG USER_WS=/home/${USERNAME}/user_ws +ENV USER_WS=${USER_WS} +RUN mkdir -p ${USER_WS}/src ${USER_WS}/build ${USER_WS}/install ${USER_WS}/log +COPY ./src ${USER_WS}/src + +# Also mkdir with user permission directories which will be mounted later to avoid docker creating them as root +WORKDIR $USER_WS +# hadolint ignore=DL3008 +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + groupadd --gid $USER_GID ${USERNAME} && \ + useradd --uid $USER_UID --gid $USER_GID --shell /bin/bash --create-home ${USERNAME} && \ + apt-get update && \ + apt-get install -q -y --no-install-recommends sudo && \ + echo ${USERNAME} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${USERNAME} && \ + chmod 0440 /etc/sudoers.d/${USERNAME} && \ + cp -r /etc/skel/. /home/${USERNAME} && \ + mkdir -p \ + /home/${USERNAME}/.ccache \ + /home/${USERNAME}/.config \ + /home/${USERNAME}/.ignition \ + /home/${USERNAME}/.colcon \ + /home/${USERNAME}/.ros && \ + chown -R $USER_UID:$USER_GID /home/${USERNAME} /opt/overlay_ws/ + +# IMPORTANT: Optionally install Nvidia drivers for improved simulator performance with Nvidia GPUs. +# To do this you must +# 1. Uncomment the ENV and RUN entries below +# 2. Replace the 'nvidia-driver-555' apt package with the Nvidia driver version on your host, e.g. nvidia-driver-535, nvidia-driver-555. Use nvidia-smi on your host to determine the driver version. +# After rebuilding via `moveit_pro build` verify the drivers are active in your container by running `nvidia_smi` inside of `moveit_pro shell`. +# ENV DEBIAN_FRONTEND=noninteractive +# RUN apt update && apt install -y software-properties-common +# RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ +# --mount=type=cache,target=/var/lib/apt,sharing=locked \ +# add-apt-repository ppa:graphics-drivers/ppa && \ +# apt update && apt upgrade -y && apt install -y nvidia-driver-555 + +# Install additional dependencies +# You can also add any necessary apt-get install, pip install, etc. commands at this point. +# NOTE: The /opt/overlay_ws folder contains MoveIt Pro binary packages and the source file. +# hadolint ignore=SC1091 +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + . /opt/overlay_ws/install/setup.sh && \ + apt-get update && \ + rosdep install -q -y \ + --from-paths src \ + --ignore-src + +# Set up colcon defaults for the new user +USER ${USERNAME} +RUN colcon mixin add default \ + https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml && \ + colcon mixin update && \ + colcon metadata add default \ + https://raw.githubusercontent.com/colcon/colcon-metadata-repository/master/index.yaml && \ + colcon metadata update +COPY colcon-defaults.yaml /home/${USERNAME}/.colcon/defaults.yaml + +# hadolint ignore=DL3002 +USER root + +################################################################### +# Target for the developer build which does not compile any code. # +################################################################### +FROM base AS user-overlay-dev + +ARG USERNAME +ARG USER_WS=/home/${USERNAME}/user_ws +ENV USER_WS=${USER_WS} + +# Install any additional packages for development work +# hadolint ignore=DL3008 +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + apt-get update && \ + apt-get install -y --no-install-recommends \ + less \ + gdb \ + nano + +# Set up the user's .bashrc file and shell. +CMD ["/usr/bin/bash"] + +######################################### +# Target for compiled, deployable image # +######################################### +FROM base AS user-overlay + +ARG USERNAME +ARG USER_WS=/home/${USERNAME}/user_ws +ENV USER_WS=${USER_WS} + +# Compile the workspace +WORKDIR $USER_WS + +# Set up the user's .bashrc file and shell. +CMD ["/usr/bin/bash"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..7c2e04eb --- /dev/null +++ b/LICENSE @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) 2023 PickNik Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md index 4d53294b..bfa76772 100644 --- a/README.md +++ b/README.md @@ -1 +1,7 @@ -# moveit_pro_empty_ws \ No newline at end of file +# MoveIt Pro Workspace + +This is a minimal user workspace that can be used to build customized MoveIt Pro workspaces. + +You may fork this repository and add the MoveIt Pro configurations and ROS 2 packages of your choosing to the `src` folder. + +For more information, refer to the [MoveIt Pro Documentation](https://docs.picknik.ai/). diff --git a/colcon-defaults.yaml b/colcon-defaults.yaml new file mode 100644 index 00000000..9aedbf87 --- /dev/null +++ b/colcon-defaults.yaml @@ -0,0 +1,19 @@ +# Contains colcon default settings for user overlay containers. +build: + # Enable this for bidirectional syncing from the UI + symlink-install: true + mixin: + # Enable ccache support + - ccache + # Multithreaded linker to speed up linking step during compilation + - lld + - compile-commands + # Debug info and build testing for dev workflows + - rel-with-deb-info + - build-testing-on + - coverage-gcc + - coverage-pytest +test: + event-handlers: + - console_direct+ + - desktop_notification+ diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 00000000..2c94baf9 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,106 @@ +# Docker Compose file for user overlays of the MoveIt Pro images. + +services: + # Sets common properties for other services. Should not be instantiated directly. + base: + # Extend the installed MoveIt Pro docker compose file. + # Change this to match your environment, if MoveIt Pro was installed to a different location. + extends: + file: /opt/moveit_pro/docker-compose.yaml + service: base + image: moveit-pro-overlay + build: + context: . + target: user-overlay + args: + - USER_UID=${STUDIO_USER_UID:-1000} + - USER_GID=${STUDIO_USER_GID:-1000} + - USERNAME=${STUDIO_USERNAME:-studio-user} + - MOVEIT_STUDIO_BASE_IMAGE=picknikciuser/moveit-studio:${STUDIO_DOCKER_TAG:-main} + + # Starts the MoveIt Pro Agent and the Bridge between the Agent and the Web UI + agent_bridge: + extends: base + privileged: true + # This service relies on cgroup_rules defined in base which allow the user to use the host's network video4linux and usb_device devices. + depends_on: + rest_api: + condition: service_healthy + volumes: + # Allow the user to run graphical programs from within the docker container. + - /tmp/.X11-unix:/tmp/.X11-unix:ro + # Allow access to host hardware e.g. RealSense cameras + - /dev:/dev + deploy: + restart_policy: + condition: any + delay: 2s + command: agent_bridge.app + + # Starts the REST API for the Web UI. + rest_api: + extends: base + healthcheck: + test: "curl -f http://localhost:3200/objectives" + interval: 5s + timeout: 1m + command: rest_api.app + + # Starts the robot drivers. + drivers: + extends: base + privileged: true + # Ensures the drivers container has RT priority + ulimits: + rtprio: 99 + devices: + - "/dev/ttyUSB0:/dev/ttyUSB0" # Allow access to the gripper. + command: robot.app + + # Starts the web UI frontend. + web_ui: + image: picknikciuser/moveit-studio-frontend:${STUDIO_DOCKER_TAG:-main} + ports: + - "80:80" + network_mode: host + + # Starts RViz for visualization. + rviz: + extends: base + profiles: + - rviz + command: bash -c "ros2 launch moveit_studio_agent developer_rviz.launch.py" + + # Starts MoveIt Setup Assistant for creating MoveIt configurations. + setup_assistant: + extends: base + profiles: + - setup_assistant + command: bash -c "ros2 launch moveit_setup_assistant setup_assistant.launch.py" + + # Developer specific configuration + dev: + extends: base + build: + target: user-overlay-dev + image: moveit-studio-overlay-dev + stdin_open: true + tty: true + privileged: true + volumes: + # Mount the source code, colcon generated artifacts, and ccache + - ./src/:/home/${STUDIO_USERNAME:-studio-user}/user_ws/src:rw + - ./build/:/home/${STUDIO_USERNAME:-studio-user}/user_ws/build:rw + - ./install/:/home/${STUDIO_USERNAME:-studio-user}/user_ws/install:rw + - ./log/:/home/${STUDIO_USERNAME:-studio-user}/user_ws/log:rw + - ./.ccache/:/home/${STUDIO_USERNAME:-studio-user}/.ccache:rw + - ${HOME}/.ros/log_moveit_pro:/home/${STUDIO_USERNAME:-studio-user}/.ros/log + # Allow access to host hardware e.g. RealSense cameras + - /dev:/dev + command: sleep infinity + # Making a separate profile prevents this service from being built when using `docker compose build` + # and launched when using `docker compose up`. + profiles: ["dev"] + +volumes: + ignition_resources: