Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
aentinger committed Nov 17, 2023
0 parents commit b792ad0
Show file tree
Hide file tree
Showing 14 changed files with 375 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/spell-check/.codespellrc
# See: https://github.com/codespell-project/codespell#using-a-config-file
[codespell]
# In the event of a false positive, add the problematic word, in all lowercase, to a comma-separated list here:
ignore-words-list = ,
skip = ./.git,./.licenses,__pycache__,node_modules,./go.mod,./go.sum,./package-lock.json,./poetry.lock,./yarn.lock,./external
builtin = clear,informal,en-GB_to_en-US
check-filenames =
check-hidden =
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# See: https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#about-the-dependabotyml-file
version: 2

updates:
# Configure check for outdated GitHub Actions actions in workflows.
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/dependabot/README.md
# See: https://docs.github.com/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot
- package-ecosystem: github-actions
directory: / # Check the repository's workflows under /.github/workflows/
schedule:
interval: daily
labels:
- "topic: ci"
26 changes: 26 additions & 0 deletions .github/workflows/spell-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Source: https://github.com/per1234/.github/blob/main/workflow-templates/spell-check.md
name: Spell Check

# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
on:
push:
pull_request:
schedule:
# Run every Tuesday at 8 AM UTC to catch new misspelling detections resulting from dictionary updates.
- cron: "0 8 * * TUE"
workflow_dispatch:
repository_dispatch:

permissions:
contents: read

jobs:
spellcheck:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Spell check
uses: codespell-project/actions-codespell@master
132 changes: 132 additions & 0 deletions .github/workflows/sync-labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/sync-labels.md
name: Sync Labels

# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
on:
push:
paths:
- ".github/workflows/sync-labels.ya?ml"
- ".github/label-configuration-files/*.ya?ml"
pull_request:
paths:
- ".github/workflows/sync-labels.ya?ml"
- ".github/label-configuration-files/*.ya?ml"
schedule:
# run every Tuesday at 3 AM UTC
- cron: "0 3 * * 2"
workflow_dispatch:
repository_dispatch:

env:
CONFIGURATIONS_FOLDER: .github/label-configuration-files
CONFIGURATIONS_ARTIFACT: label-configuration-files

jobs:
check:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Download JSON schema for labels configuration file
id: download-schema
uses: carlosperate/[email protected]
with:
file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/arduino-tooling-gh-label-configuration-schema.json
location: ${{ runner.temp }}/label-configuration-schema

- name: Install JSON schema validator
run: |
sudo npm install \
--global \
ajv-cli \
ajv-formats
- name: Validate local labels configuration
run: |
# See: https://github.com/ajv-validator/ajv-cli#readme
ajv validate \
--all-errors \
-c ajv-formats \
-s "${{ steps.download-schema.outputs.file-path }}" \
-d "${{ env.CONFIGURATIONS_FOLDER }}/*.{yml,yaml}"
download:
needs: check
runs-on: ubuntu-latest

strategy:
matrix:
filename:
# Filenames of the shared configurations to apply to the repository in addition to the local configuration.
# https://github.com/107-systems/.github/blob/main/workflow-templates/assets/sync-labels
- universal.yml

steps:
- name: Download
uses: carlosperate/[email protected]
with:
file-url: https://raw.githubusercontent.com/107-systems/.github/main/workflow-templates/assets/sync-labels/${{ matrix.filename }}

- name: Pass configuration files to next job via workflow artifact
uses: actions/upload-artifact@v3
with:
path: |
*.yaml
*.yml
if-no-files-found: error
name: ${{ env.CONFIGURATIONS_ARTIFACT }}

sync:
needs: download
runs-on: ubuntu-latest

steps:
- name: Set environment variables
run: |
# See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
echo "MERGED_CONFIGURATION_PATH=${{ runner.temp }}/labels.yml" >> "$GITHUB_ENV"
- name: Determine whether to dry run
id: dry-run
if: >
github.event == 'pull_request' ||
github.ref != format('refs/heads/{0}', github.event.repository.default_branch)
run: |
# Use of this flag in the github-label-sync command will cause it to only check the validity of the
# configuration.
echo "::set-output name=flag::--dry-run"
- name: Checkout repository
uses: actions/checkout@v4

- name: Download configuration files artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.CONFIGURATIONS_ARTIFACT }}
path: ${{ env.CONFIGURATIONS_FOLDER }}

- name: Remove unneeded artifact
uses: geekyeggo/delete-artifact@v2
with:
name: ${{ env.CONFIGURATIONS_ARTIFACT }}

- name: Merge label configuration files
run: |
# Merge all configuration files
shopt -s extglob
cat "${{ env.CONFIGURATIONS_FOLDER }}"/*.@(yml|yaml) > "${{ env.MERGED_CONFIGURATION_PATH }}"
- name: Install github-label-sync
run: sudo npm install --global github-label-sync

- name: Sync labels
env:
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# See: https://github.com/Financial-Times/github-label-sync
github-label-sync \
--labels "${{ env.MERGED_CONFIGURATION_PATH }}" \
${{ steps.dry-run.outputs.flag }} \
${{ github.repository }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Alexander Entinger, MSc / LXRobotics GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<a href="https://107-systems.org/"><img align="right" src="https://raw.githubusercontent.com/107-systems/.github/main/logo/107-systems.png" width="15%"></a>
:floppy_disk: `viper-docker`
============================
[![Spell Check status](https://github.com/107-systems/viper-docker/actions/workflows/spell-check.yml/badge.svg)](https://github.com/107-systems/viper-docker/actions/workflows/spell-check.yml)

Dockerfile and scripts to run [viper](https://github.com/107-systems/viper) generic drone software stack on the [Pika Spark](https://pika-spark.io/).

<p align="center">
<a href="https://github.com/107-systems/viper"><img src="https://github.com/107-systems/.github/raw/main/logo/viper.jpg" width="40%"></a>
</p>

#### How-to-Docker
This section is for building and executing this ROS node on the [Pika Spark](https://pika-spark.io/) via [Docker](https://www.docker.com/). You have to `cd docker/build-and-run` or `cd docker/devel` and then build and run the docker container.
```bash
./docker-build.sh
sudo ./docker-run.sh
```
37 changes: 37 additions & 0 deletions docker/build-and-run/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM docker.io/arm64v8/ros:humble-ros-base

WORKDIR /tmp
RUN git clone https://github.com/gsl-lite/gsl-lite && cd gsl-lite
RUN mkdir build && cd build
RUN cmake .. && make -j8
RUN sudo make install

RUN git clone https://github.com/catchorg/Catch2 && cd Catch2
RUN mkdir build && cd build
RUN cmake .. && make -j8
RUN sudo make install

RUN git clone https://github.com/fmtlib/fmt && cd fmt
RUN mkdir build && cd build
RUN cmake -DFMT_TEST=OFF ..
RUN make -j8
RUN sudo make install

RUN git clone https://github.com/mpusz/mp-units && cd mp-units
RUN mkdir build && cd build
RUN cmake -DMP_UNITS_AS_SYSTEM_HEADERS=ON -DMP_UNITS_BUILD_LA=OFF ..
RUN make -j8
RUN sudo make install

RUN mkdir -p /tmp/colcon_ws/src
WORKDIR /tmp/colcon_ws/src
RUN git clone --recursive https://github.com/107-systems/viper

WORKDIR /tmp/colcon_ws
RUN . /opt/ros/humble/setup.sh && \
colcon_ws build --symlink-install

COPY start.sh /
RUN chmod ugo+x /start.sh

ENTRYPOINT ["/start.sh"]
4 changes: 4 additions & 0 deletions docker/build-and-run/docker-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
docker build --pull --no-cache --tag pika_spark_docker_build_and_run .
37 changes: 37 additions & 0 deletions docker/build-and-run/docker-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'

if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root."
exit 1
fi

CAN=can0
CAN_BITRATE=250000
GPIO_CAN0_STBY=160

echo "Configuring $CAN for a bitrate of $CAN_BITRATE bits/s"

function finish
{
ip link set $CAN down
echo 1 > /sys/class/gpio/gpio$GPIO_CAN0_STBY/value
echo $GPIO_CAN0_STBY > /sys/class/gpio/unexport
}
trap finish EXIT

echo $GPIO_CAN0_STBY > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio$GPIO_CAN0_STBY/direction
echo 0 > /sys/class/gpio/gpio$GPIO_CAN0_STBY/value

ip link set $CAN type can bitrate $CAN_BITRATE
ip link set $CAN up

sudo -u fio ifconfig $CAN

docker run -it \
-u 0 \
--privileged \
--network host \
pika_spark_docker_build_and_run
5 changes: 5 additions & 0 deletions docker/build-and-run/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
cd tmp/colcon_ws
. /opt/ros/humble/setup.sh
. install/setup.sh
ros2 launch viper viper-quad.py
32 changes: 32 additions & 0 deletions docker/devel/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM docker.io/arm64v8/ros:humble-ros-base

WORKDIR /tmp
RUN git clone https://github.com/gsl-lite/gsl-lite && cd gsl-lite
RUN mkdir build && cd build
RUN cmake .. && make -j8
RUN sudo make install

RUN git clone https://github.com/catchorg/Catch2 && cd Catch2
RUN mkdir build && cd build
RUN cmake .. && make -j8
RUN sudo make install

RUN git clone https://github.com/fmtlib/fmt && cd fmt
RUN mkdir build && cd build
RUN cmake -DFMT_TEST=OFF ..
RUN make -j8
RUN sudo make install

RUN git clone https://github.com/mpusz/mp-units && cd mp-units
RUN mkdir build && cd build
RUN cmake -DMP_UNITS_AS_SYSTEM_HEADERS=ON -DMP_UNITS_BUILD_LA=OFF ..
RUN make -j8
RUN sudo make install

RUN mkdir -p /tmp/colcon_ws/src
WORKDIR /tmp/colcon_ws/src
RUN git clone --recursive https://github.com/107-systems/viper

WORKDIR /tmp/colcon_ws
RUN . /opt/ros/humble/setup.sh && \
colcon_ws build --symlink-install
4 changes: 4 additions & 0 deletions docker/devel/docker-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
docker build --pull --no-cache --tag pika_spark_docker_devel .
37 changes: 37 additions & 0 deletions docker/devel/docker-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'

if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root."
exit 1
fi

CAN=can0
CAN_BITRATE=250000
GPIO_CAN0_STBY=160

echo "Configuring $CAN for a bitrate of $CAN_BITRATE bits/s"

function finish
{
ip link set $CAN down
echo 1 > /sys/class/gpio/gpio$GPIO_CAN0_STBY/value
echo $GPIO_CAN0_STBY > /sys/class/gpio/unexport
}
trap finish EXIT

echo $GPIO_CAN0_STBY > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio$GPIO_CAN0_STBY/direction
echo 0 > /sys/class/gpio/gpio$GPIO_CAN0_STBY/value

ip link set $CAN type can bitrate $CAN_BITRATE
ip link set $CAN up

sudo -u fio ifconfig $CAN

docker run -it \
-u 0 \
--privileged \
--network host \
pika_spark_docker_devel sh

0 comments on commit b792ad0

Please sign in to comment.