Skip to content
Merged
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
28 changes: 12 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -416,35 +416,31 @@ jobs:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04
artifact-name: LinuxArm64
image_suffix: RaspberryPi
- image_suffix: RaspberryPi
image_url: https://github.com/PhotonVision/photon-image-modifier/releases/download/$IMAGE_VERSION/photonvision_raspi.img.xz
cpu: cortex-a7
image_additional_mb: 0
extraOpts: -Djdk.lang.Process.launchMechanism=vfork
- image_suffix: rubikpi3
image_url: https://github.com/PhotonVision/photon-image-modifier/releases/download/$IMAGE_VERSION/photonvision_rubikpi3.tar.xz
root_location: 'offset=569376768'
- image_suffix: orangepi5
image_url: https://github.com/PhotonVision/photon-image-modifier/releases/download/$IMAGE_VERSION/photonvision_opi5.img.xz

runs-on: ${{ matrix.os }}
runs-on: ubuntu-24.04-arm
name: smoketest-${{ matrix.image_suffix }}

steps:
- uses: actions/download-artifact@v4
with:
name: jar-${{ matrix.artifact-name }}
name: jar-LinuxArm64

- uses: pguyot/arm-runner-action@v2
- uses: photonvision/photon-image-runner@HEAD
name: Run photon smoketest
id: generate_image
with:
base_image: ${{ matrix.image_url }}
image_additional_mb: ${{ matrix.image_additional_mb }}
optimize_image: yes
cpu: ${{ matrix.cpu }}
# We do _not_ wanna copy photon into the image. Bind mount instead
bind_mount_repository: true
image_url: ${{ matrix.image_url }}
root_location: ${{ matrix.root_location || 'partition=2' }}
# our image better have java installed already
commands: |
java -jar ${{ matrix.extraOpts }} *.jar --smoketest
java -jar *.jar --smoketest

build-image:
needs: [build-package]
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ ext {
openCVYear = "2025"
openCVversion = "4.10.0-3"
javalinVersion = "6.7.0"
libcameraDriverVersion = "v2025.0.4"
rknnVersion = "dev-v2025.0.0-5-g666c0c6"
rubikVersion = "dev-v2025.1.0-6-g4a5e508"
libcameraDriverVersion = "dev-v2025.0.4-2-gc91d4b7"
rknnVersion = "dev-v2025.0.0-7-g83c1bf3"
rubikVersion = "dev-v2025.1.0-7-g39588a8"
frcYear = "2025"
mrcalVersion = "dev-v2025.0.0-2-g2adb187";

Expand Down
26 changes: 16 additions & 10 deletions photon-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,31 @@ dependencies {
wpilibNatives wpilibTools.deps.wpilib("hal")
wpilibNatives wpilibTools.deps.wpilibOpenCv("frc" + openCVYear, wpi.versions.opencvVersion.get())

// Zip
// These stay as implementation dependencies since they don't have native code that gets packaged
implementation 'org.zeroturnaround:zt-zip:1.14'

implementation "org.xerial:sqlite-jdbc:3.41.0.0"
implementation("org.photonvision:rknn_jni-jni:$rknnVersion:linuxarm64") {
transitive = false

// The JNI libraries use wpilibNatives, the java libraries use implementation
if (jniPlatform == "linuxarm64") {
wpilibNatives("org.photonvision:rknn_jni-jni:$rknnVersion:$wpilibNativeName") {
transitive = false
}
wpilibNatives("org.photonvision:rubik_jni-jni:$rubikVersion:$wpilibNativeName") {
transitive = false
}
wpilibNatives("org.photonvision:photon-libcamera-gl-driver-jni:$libcameraDriverVersion:$wpilibNativeName") {
transitive = false
}
}

implementation("org.photonvision:rknn_jni-java:$rknnVersion") {
transitive = false
}
implementation("org.photonvision:rubik_jni-jni:$rubikVersion:linuxarm64") {
transitive = false
}

implementation("org.photonvision:rubik_jni-java:$rubikVersion") {
transitive = false
}
implementation("org.photonvision:photon-libcamera-gl-driver-jni:$libcameraDriverVersion:linuxarm64") {
transitive = false
}

implementation "org.photonvision:photon-libcamera-gl-driver-java:$libcameraDriverVersion"

implementation "org.photonvision:photon-mrcal-java:$mrcalVersion"
Expand Down
59 changes: 59 additions & 0 deletions photon-core/src/main/java/org/photonvision/common/LoadJNI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright (C) Photon Vision.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package org.photonvision.common;

import edu.wpi.first.util.CombinedRuntimeLoader;
import java.io.IOException;
import java.util.HashMap;
import org.photonvision.jni.LibraryLoader;

public class LoadJNI {
private static HashMap<JNITypes, Boolean> loadedMap = new HashMap<>();

public enum JNITypes {
RUBIK_DETECTOR("tensorflowlite", "tensorflowlite_c", "external_delegate", "rubik_jni"),
RKNN_DETECTOR("rga", "rknnrt", "rknn_jni"),
MRCAL("mrcal_jni"),
LIBCAMERA("photonlibcamera");

public final String[] libraries;

JNITypes(String... libraries) {
this.libraries = libraries;
}
}

public static synchronized void forceLoad(JNITypes type) throws IOException {
loadLibraries();

if (loadedMap.getOrDefault(type, false)) {
return;
}

CombinedRuntimeLoader.loadLibraries(LoadJNI.class, type.libraries);
loadedMap.put(type, true);
}

public static boolean loadLibraries() {
return LibraryLoader.loadWpiLibraries() && LibraryLoader.loadTargeting();
}

public static boolean hasLoaded(JNITypes t) {
return loadedMap.getOrDefault(t, false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@

import java.util.List;
import org.photonvision.PhotonVersion;
import org.photonvision.common.LoadJNI;
import org.photonvision.common.LoadJNI.JNITypes;
import org.photonvision.common.configuration.NeuralNetworkModelManager;
import org.photonvision.common.configuration.PhotonConfiguration;
import org.photonvision.common.dataflow.networktables.NetworkTablesManager;
import org.photonvision.common.hardware.Platform;
import org.photonvision.common.networking.NetworkManager;
import org.photonvision.common.networking.NetworkUtils;
import org.photonvision.common.util.TestUtils;
import org.photonvision.raspi.LibCameraJNILoader;
import org.photonvision.vision.processes.VisionModule;
import org.photonvision.vision.processes.VisionSourceManager;

Expand All @@ -53,8 +53,8 @@ public static UIPhotonConfiguration programStateToUi(PhotonConfiguration c) {
new UIGeneralSettings(
PhotonVersion.versionString,
// TODO add support for other types of GPU accel
LibCameraJNILoader.getInstance().isSupported() ? "Zerocopy Libcamera Working" : "",
TestUtils.isMrcalLoaded(),
LoadJNI.hasLoaded(JNITypes.LIBCAMERA) ? "Zerocopy Libcamera Working" : "",
LoadJNI.hasLoaded(JNITypes.MRCAL),
c.neuralNetworkPropertyManager().getModels(),
NeuralNetworkModelManager.getInstance().getSupportedBackends(),
c.getHardwareConfig().deviceName.isEmpty()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,41 +20,17 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import edu.wpi.first.math.geometry.Translation2d;
import edu.wpi.first.math.util.Units;
import edu.wpi.first.util.CombinedRuntimeLoader;
import java.awt.HeadlessException;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import org.opencv.core.Mat;
import org.opencv.highgui.HighGui;
import org.photonvision.jni.LibraryLoader;
import org.photonvision.vision.calibration.CameraCalibrationCoefficients;
import org.photonvision.vision.pipeline.result.CVPipelineResult;
import org.photonvision.vision.target.TrackedTarget;

public class TestUtils {
private static boolean hasMrcalLoaded = false;

public static boolean loadLibraries() {
return LibraryLoader.loadWpiLibraries() && LibraryLoader.loadTargeting();
}

public static boolean loadMrcal() {
if (hasMrcalLoaded) return true;
try {
CombinedRuntimeLoader.loadLibraries(TestUtils.class, "mrcal_jni");
hasMrcalLoaded = true;
} catch (IOException e) {
e.printStackTrace();
hasMrcalLoaded = false;
}
return hasMrcalLoaded;
}

public static boolean isMrcalLoaded() {
return hasMrcalLoaded;
}

@SuppressWarnings("unused")
public enum WPI2019Image {
kCargoAngledDark48in(1.2192),
Expand Down

This file was deleted.

This file was deleted.

Loading
Loading