Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/pr-docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: PR Docker Build Check

on: [push]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: 'arm64,arm'

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
# Enable docker layer caching
buildkitd-flags: --debug

- name: Build Docker image
uses: docker/build-push-action@v5
timeout-minutes: 30
with:
context: ./raspberry_pi
cache-from: type=gha
cache-to: type=gha,mode=max`
platforms: linux/arm64,linux/arm/v7
push: false
tags: team100-pi:${{ github.sha }}

# - name: Add PR Comment on Failure
# if: failure()
# uses: actions/github-script@v7
# with:
# script: |
# github.rest.issues.createComment({
# issue_number: context.issue.number,
# owner: context.repo.owner,
# repo: context.repo.repo,
# body: '❌ Docker build failed! Please check the workflow logs for details.'
# })
44 changes: 44 additions & 0 deletions .github/workflows/swerve-100-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Swerve100 Docker Build

on: [push]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

# - name: Set up QEMU
# uses: docker/setup-qemu-action@v3
# with:
# platforms: 'arm64,arm'

# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
# with:
# # Enable docker layer caching
# buildkitd-flags: --debug

- name: Build Docker image
uses: docker/build-push-action@v5
timeout-minutes: 30
with:
context: .
# cache-from: type=gha
# cache-to: type=gha,mode=max`
# platforms: linux/arm64,linux/arm/v7
push: false
tags: team100-pi:${{ github.sha }}

# - name: Add PR Comment on Failure
# if: failure()
# uses: actions/github-script@v7
# with:
# script: |
# github.rest.issues.createComment({
# issue_number: context.issue.number,
# owner: context.repo.owner,
# repo: context.repo.repo,
# body: '❌ Docker build failed! Please check the workflow logs for details.'
# })
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Use the same WPILib container as the GitHub Action
FROM wpilib/roborio-cross-ubuntu:2024-22.04

# Set working directory
WORKDIR /team100/comp/swerve100

# Copy only wrapper files first
COPY comp/swerve100/gradle ./gradle
COPY comp/swerve100/gradlew comp/swerve100/gradlew.bat ./

# Make gradlew executable (same as in GitHub Action)
RUN chmod +x gradlew

# Copy build configuration
COPY comp/swerve100/*.gradle comp/swerve100/gradle.properties ./

# Download dependencies using wrapper
RUN ./gradlew

# Lib doesn't change often; copy before the other code
WORKDIR /team100
COPY lib ./lib

# Now copy the rest of your code
WORKDIR /team100/comp/swerve100
COPY comp/swerve100/src ./src

# Build and test (same command as in GitHub Action)
RUN ./gradlew build
31 changes: 31 additions & 0 deletions Dockerfile copy
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM wpilib/roborio-cross-ubuntu:2024-22.04

WORKDIR /app

# Copy only wrapper files first
COPY gradle ./gradle
COPY gradlew gradlew.bat ./

# Make gradlew executable
RUN chmod +x gradlew

# Copy build configuration
COPY *.gradle gradle.properties ./


# Download dependencies using wrapper
RUN --mount=type=cache,target=/root/.gradle ./gradlew --build-cache dependencies
RUN ./gradlew

# Create a custom gradle.properties to override desktop/simulation settings
RUN echo "includeDesktopSupport=false" > gradle.properties

# Now copy the rest of your code
COPY src ./src

# Build with specific options, focusing only on robot code
RUN ./gradlew build --no-daemon \
-PskipTests \
-x simulateJava \
-x test

2 changes: 1 addition & 1 deletion comp/swerve100/.wpilib/wpilib_preferences.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"currentLanguage": "java",
"projectYear": "2024beta",
"teamNumber": 100
}
}
46 changes: 46 additions & 0 deletions comp/swerve100/Dockerfile.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
FROM eclipse-temurin:17-jdk

# Install necessary tools
RUN apt-get update && apt-get install -y \
curl \
unzip \
vim \
&& rm -rf /var/lib/apt/lists/*

# Set the working directory in the container
WORKDIR /app

# Install Gradle
ENV GRADLE_VERSION=8.4
RUN curl -L https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip -o gradle.zip \
&& unzip gradle.zip \
&& rm gradle.zip \
&& mv gradle-${GRADLE_VERSION} /opt/gradle \
&& ln -s /opt/gradle/bin/gradle /usr/bin/gradle

# Set Gradle environment variables
ENV GRADLE_HOME=/opt/gradle
ENV PATH=$PATH:$GRADLE_HOME/bin

# Copy just the build.gradle and gradle files
COPY build.gradle settings.gradle gradle.properties ./
COPY gradle ./gradle
# COPY gradlew ./

# Make the gradlew script executable
# RUN chmod +x ./gradlew

# Download dependencies
RUN --mount=type=cache,target=/root/.gradle gradle --build-cache dependencies

# Now copy the rest of your code
COPY . .

# Build the project
# RUN --mount=type=cache,target=/root/.gradle gradle --build-cache build --offline

# Expose the JMX port
# EXPOSE 1099

# Run the Java application
# CMD ["gradle", "run"]
10 changes: 10 additions & 0 deletions comp/swerve100/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,13 @@ This is the main comp bot repo.

Part of the code here was (somewhat distantly) derived from 254 code, and other parts were inspired by Roadrunner.

# Starting Development

1. Make sure you have Java installed. Download it [here](https://www.oracle.com/java/technologies/downloads/).
1. From your command line you should be able to run:
`./gradlew build` . This should start downloading all the relevant libraries and install them.
1. Visit the WPILib installation instructions [here](https://docs.wpilib.org/en/stable/docs/zero-to-robot/step-2/offline-installation-preparations.html). This is a big file and will take a while to download + install.
1. Once installed,

# Misc
https://docs.wpilib.org/en/stable/docs/software/vscode-overview/deploying-robot-code.html
16 changes: 15 additions & 1 deletion comp/swerve100/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ deploy {
// or from command line. If not found an exception will be thrown.
// You can use getTeamOrDefault(team) instead of getTeamNumber if you
// want to store a team number in this file.
team = project.frc.getTeamNumber()
// team = project.frc.getTeamNumber()
// TODO(dmontauk): a better approach would be to have build dependencies pulled separately
// from the actual build.
team = project.frc.getTeamOrDefault(100)
debug = project.frc.getDebugOrDefault(false)

artifacts {
Expand Down Expand Up @@ -218,3 +221,14 @@ wpi.java.configureTestTasks(test)
tasks.withType(JavaCompile) {
options.compilerArgs.add '-XDstringConcat=inline'
}

// Add this at the end of your build.gradle file
task downloadDependencies() {
doLast {
configurations.all { c ->
if (c.canBeResolved) {
c.resolve()
}
}
}
}
1 change: 1 addition & 0 deletions comp/swerve100/setup_dev_container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 1 addition & 1 deletion comp/swerve100/swerve100.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"java.configuration.updateBuildConfiguration": "automatic",
"java.server.launchMode": "Standard",
"terminal.integrated.scrollback": 100000,
"workbench.colorTheme": "Default Light+",
"workbench.colorTheme": "Anysphere",
"files.autoSave": "afterDelay",
"java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx32G -Xms100m -Xlog:disable",
"workbench.editor.revealIfOpen": true,
Expand Down
1 change: 1 addition & 0 deletions raspberry_pi/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions raspberry_pi/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

20 changes: 20 additions & 0 deletions raspberry_pi/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Docker: Attach to Vision App",
"type": "debugpy",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/team100"
}
],
},
]
}
2 changes: 1 addition & 1 deletion raspberry_pi/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
],
"python.testing.pytestEnabled": false,
"python.testing.unittestEnabled": true,
"workbench.colorTheme": "Default Light Modern",
"workbench.colorTheme": "Default Dark Modern",
"editor.minimap.enabled": false,
"python.analysis.typeCheckingMode": "standard",
"mypy-type-checker.reportingScope": "workspace",
Expand Down
65 changes: 65 additions & 0 deletions raspberry_pi/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Use the official Raspberry Pi OS image as a base
FROM dtcooper/raspberrypi-os:bookworm

# Install system dependencies
RUN echo 'Acquire::Retries "3";' > /etc/apt/apt.conf.d/80-retries
RUN apt-get update
RUN apt-get install -y python3-pip
RUN apt-get install -y python3-setuptools
RUN apt-get install -y python3-wheel
RUN apt-get install -y python3-numpy
RUN apt-get install -y libcamera-dev
RUN apt-get install -y python3-aiohttp
RUN apt-get install -y python3-opencv
RUN apt-get install -y python3-venv
RUN apt-get install -y build-essential
RUN apt-get install -y python3-dev

RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# Install Python dependencies
# Create a virtual environment
RUN python3 -m venv /team100/venv

# Activate the virtual environment
ENV PATH="/team100/venv/bin:$PATH"

# Copy requirements file
COPY requirements.txt /tmp/requirements.txt

# Install dependencies in the virtual environment
# RUN pip3 install --no-cache-dir -r /tmp/requirements.txt
RUN pip3 install hidapi
RUN pip3 install adafruit-blinka
RUN pip3 install adafruit-circuitpython-lsm6ds
RUN pip3 install debugpy
RUN pip3 install numpy
RUN pip3 install aiohttp
# RUN pip3 install opencv-python
# RUN pip3 install --prefer-binary robotpy-wpiutil
# RUN pip3 install --prefer-binary robotpy-wpimath
# RUN pip3 install --prefer-binary robotpy-wpinet
# RUN pip3 install --prefer-binary robotpy-hal
# RUN pip3 install --prefer-binary robotpy-halsim
# RUN pip3 install --prefer-binary robotpy-commands-v2
# RUN pip3 install --prefer-binary robotpy
# # Then install the additional robotpy packages
# RUN pip3 install robotpy-cscore
# RUN pip3 install robotpy-apriltag

# Create app directory
WORKDIR /team100

# Copy the app files
COPY app /team100/app
COPY app/config /team100/app/config

# Copy the runapp.py script
COPY runapp.py /team100/runapp.py

# Remove any __pycache__ directories
#RUN find /team100 -type d -name "__pycache__" -exec rm -rf {} +
EXPOSE 5678

# Set the entrypoint to run the app with debugger
#ENTRYPOINT ["python3", "-m", "debugpy", "--listen", "0.0.0.0:5678", "runapp.py"]
12 changes: 12 additions & 0 deletions raspberry_pi/app/fake_display.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Display:
def __init__(self, width, height, camera_num) -> None:
pass

def draw_result(self, image, result_item, pose) -> None:
pass

def draw_text(self, image, msg, loc) -> None:
pass

def put_frame(self, img) -> None:
pass
6 changes: 6 additions & 0 deletions raspberry_pi/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
hidapi
adafruit-blinka
adafruit-circuitpython-lsm6ds
robotpy
robotpy-cscore
robotpy-apriltag
Loading