Skip to content

Commit

Permalink
Merge branch 'master' into undistort-pitch-yaw
Browse files Browse the repository at this point in the history
  • Loading branch information
amquake authored Apr 5, 2024
2 parents 8d5febf + 0106880 commit 77d571c
Show file tree
Hide file tree
Showing 55 changed files with 857 additions and 220 deletions.
81 changes: 79 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,83 @@ jobs:
with:
name: jar-${{ matrix.artifact-name }}
path: photon-server/build/libs

run-smoketest-native:
needs: [build-package]

strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
artifact-name: jar-Linux
extraOpts: -Djdk.lang.Process.launchMechanism=vfork
- os: windows-latest
artifact-name: jar-Win64
extraOpts: ""
- os: macos-latest
artifact-name: jar-macOS
architecture: x64

runs-on: ${{ matrix.os }}

steps:
- name: Install Java 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
- uses: actions/download-artifact@v4
with:
name: ${{ matrix.artifact-name }}
# On linux, install mrcal packages
- run: |
sudo apt-get update
sudo apt-get install --yes libcholmod3 liblapack3 libsuitesparseconfig5
if: ${{ (matrix.os) == 'ubuntu-latest' }}
# and actually run the jar
- run: java -jar ${{ matrix.extraOpts }} *.jar --smoketest
if: ${{ (matrix.os) != 'windows-latest' }}
- run: ls *.jar | %{ Write-Host "Running $($_.Name)"; Start-Process "java" -ArgumentList "-jar `"$($_.FullName)`" --smoketest" -NoNewWindow -Wait; break }
if: ${{ (matrix.os) == 'windows-latest' }}

run-smoketest-chroot:
needs: [build-package]

strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
artifact-name: LinuxArm64
image_suffix: RaspberryPi
image_url: https://github.com/PhotonVision/photon-image-modifier/releases/download/v2024.0.4/photonvision_raspi.img.xz
cpu: cortex-a7
image_additional_mb: 0
extraOpts: -Djdk.lang.Process.launchMechanism=vfork

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

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

- uses: pguyot/arm-runner-action@v2
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
# our image better have java installed already
commands: |
java -jar ${{ matrix.extraOpts }} *.jar --smoketest
build-image:
needs: [build-package]

Expand Down Expand Up @@ -290,13 +367,13 @@ jobs:
- os: ubuntu-latest
artifact-name: LinuxArm64
image_suffix: orangepi5
image_url: https://github.com/PhotonVision/photon-image-modifier/releases/download/v2024.0.9/photonvision_opi5.img.xz
image_url: https://github.com/PhotonVision/photon-image-modifier/releases/download/v2024.0.10/photonvision_opi5.img.xz
cpu: cortex-a8
image_additional_mb: 4096
- os: ubuntu-latest
artifact-name: LinuxArm64
image_suffix: orangepi5plus
image_url: https://github.com/PhotonVision/photon-image-modifier/releases/download/v2024.0.9/photonvision_opi5plus.img.xz
image_url: https://github.com/PhotonVision/photon-image-modifier/releases/download/v2024.0.10/photonvision_opi5plus.img.xz
cpu: cortex-a8
image_additional_mb: 4096

Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
id "com.diffplug.spotless" version "6.24.0"
id "edu.wpi.first.NativeUtils" version "2024.6.1" apply false
id "edu.wpi.first.wpilib.repositories.WPILibRepositoriesPlugin" version "2020.2"
id "edu.wpi.first.GradleRIO" version "2024.3.1"
id "edu.wpi.first.GradleRIO" version "2024.3.2"
id 'edu.wpi.first.WpilibTools' version '1.3.0'
id 'com.google.protobuf' version '0.9.4' apply false
}
Expand All @@ -24,15 +24,15 @@ allprojects {
apply from: "versioningHelper.gradle"

ext {
wpilibVersion = "2024.3.1"
wpilibVersion = "2024.3.2"
wpimathVersion = wpilibVersion
openCVversion = "4.8.0-2"
joglVersion = "2.4.0-rc-20200307"
javalinVersion = "5.6.2"
photonGlDriverLibVersion = "dev-v2023.1.0-9-g75fc678"
rknnVersion = "dev-v2024.0.0-64-gc0836a6"
frcYear = "2024"
mrcalVersion = "dev-v2024.0.0-7-gc976aaa";
mrcalVersion = "dev-v2024.0.0-18-gb903a09";


pubVersion = versionString
Expand Down
6 changes: 3 additions & 3 deletions devTools/calibrationUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ def pose_to_rt(pose: Pose3d):
"indices_point_camintrinsics_camextrinsics": None,
"lensmodel": model,
"imagersizes": np.array([imagersize], dtype=np.int32),
"calobject_warp": np.array(cal.calobjectWarp)
if len(cal.calobjectWarp) > 0
else None,
"calobject_warp": (
np.array(cal.calobjectWarp) if len(cal.calobjectWarp) > 0 else None
),
# We always do all the things
"do_optimize_intrinsics_core": True,
"do_optimize_intrinsics_distortions": True,
Expand Down
10 changes: 8 additions & 2 deletions photon-client/src/components/app/photon-camera-stream.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { computed, inject } from "vue";
import { computed, inject, ref, onBeforeUnmount } from "vue";
import { useCameraSettingsStore } from "@/stores/settings/CameraSettingsStore";
import { useStateStore } from "@/stores/StateStore";
import loadingImage from "@/assets/images/loading.svg";
Expand Down Expand Up @@ -53,11 +53,17 @@ const handleFullscreenRequest = () => {
if (!stream) return;
stream.requestFullscreen();
};
const mjpgStream: any = ref(null);
onBeforeUnmount(() => {
if (!mjpgStream.value) return;
mjpgStream.value["src"] = null;
});
</script>

<template>
<div class="stream-container">
<img :id="id" crossorigin="anonymous" :src="streamSrc" :alt="streamDesc" :style="streamStyle" />
<img :id="id" crossorigin="anonymous" :src="streamSrc" :alt="streamDesc" :style="streamStyle" ref="mjpgStream" />
<div class="stream-overlay" :style="overlayStyle">
<pv-icon
icon-name="mdi-camera-image"
Expand Down
6 changes: 6 additions & 0 deletions photon-client/src/components/cameras/CamerasView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ th {
justify-content: center;
}

@media only screen and (min-width: 960px) {
#camera-settings-camera-view-card {
position: sticky;
top: 12px;
}
}
@media only screen and (min-width: 512px) and (max-width: 960px) {
.stream-container {
flex-wrap: nowrap;
Expand Down
6 changes: 1 addition & 5 deletions photon-client/src/components/dashboard/CamerasCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ defineProps<{
const driverMode = computed<boolean>({
get: () => useCameraSettingsStore().isDriverMode,
set: (v) =>
useCameraSettingsStore().changeCurrentPipelineIndex(
v ? -1 : useCameraSettingsStore().currentCameraSettings.lastPipelineIndex || 0,
true
)
set: (v) => useCameraSettingsStore().setDriverMode(v)
});
const fpsTooLow = computed<boolean>(() => {
Expand Down
22 changes: 21 additions & 1 deletion photon-client/src/components/dashboard/tabs/InputTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,32 @@ const interactiveCols = computed(() =>
tooltip="Controls blue automatic white balance gain, which affects how the camera captures colors in different conditions"
@input="(args) => useCameraSettingsStore().changeCurrentPipelineSetting({ cameraBlueGain: args }, false)"
/>
<!-- Disable camera orientation as stop gap for Issue 1084 until calibration data gets rotated. https://github.com/PhotonVision/photonvision/issues/1084 -->
<v-banner
v-show="
useCameraSettingsStore().isCurrentVideoFormatCalibrated &&
useCameraSettingsStore().currentPipelineSettings.inputImageRotationMode != 0
"
rounded
dark
color="red"
text-color="white"
class="mt-3"
icon="mdi-alert-circle-outline"
>
Warning! A known bug affects rotation of calibrated camera. Turn off rotation here and rotate using
cameraToRobotTransform in your robot code.
</v-banner>
<pv-select
v-model="useCameraSettingsStore().currentPipelineSettings.inputImageRotationMode"
label="Orientation"
tooltip="Rotates the camera stream"
tooltip="Rotates the camera stream. Rotation not available when camera has been calibrated."
:items="cameraRotations"
:select-cols="interactiveCols"
:disabled="
useCameraSettingsStore().isCurrentVideoFormatCalibrated &&
useCameraSettingsStore().currentPipelineSettings.inputImageRotationMode == 0
"
@input="(args) => useCameraSettingsStore().changeCurrentPipelineSetting({ inputImageRotationMode: args }, false)"
/>
<pv-select
Expand Down
2 changes: 1 addition & 1 deletion photon-client/src/components/dashboard/tabs/TargetsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const calculateStdDev = (values: number[]): number => {
};
const resetCurrentBuffer = () => {
// Need to clear the array in place
while (useStateStore().currentMultitagBuffer?.length != 0) useStateStore().currentMultitagBuffer?.pop();
if (useStateStore().currentMultitagBuffer) useStateStore().currentMultitagBuffer!.length = 0;
};
</script>

Expand Down
3 changes: 2 additions & 1 deletion photon-client/src/stores/StateStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ export const useStateStore = defineStore("state", {
return this.backendResults[this.currentCameraIndex.toString()];
},
currentMultitagBuffer(): MultitagResult[] | undefined {
return this.multitagResultBuffer[this.currentCameraIndex.toString()];
if (!this.multitagResultBuffer[this.currentCameraIndex]) this.multitagResultBuffer[this.currentCameraIndex] = [];
return this.multitagResultBuffer[this.currentCameraIndex];
}
},
actions: {
Expand Down
7 changes: 7 additions & 0 deletions photon-client/src/stores/settings/CameraSettingsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,13 @@ export const useCameraSettingsStore = defineStore("cameraSettings", {
}
useStateStore().websocket?.send(payload, true);
},
setDriverMode(isDriverMode: boolean, cameraIndex: number = useStateStore().currentCameraIndex) {
const payload = {
driverMode: isDriverMode,
cameraIndex: cameraIndex
};
useStateStore().websocket?.send(payload, true);
},
/**
* Change the currently selected pipeline of the provided camera.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ public enum LogGroup {
VisionModule,
Data,
General,
Config
Config,
CSCore,
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public static String format(
levelMap.put(LogGroup.Data, LogLevel.INFO);
levelMap.put(LogGroup.VisionModule, LogLevel.INFO);
levelMap.put(LogGroup.Config, LogLevel.INFO);
levelMap.put(LogGroup.CSCore, LogLevel.TRACE);
}

static {
Expand Down Expand Up @@ -194,7 +195,7 @@ public boolean shouldLog(LogLevel logLevel) {
return logLevel.code <= levelMap.get(group).code;
}

private void log(String message, LogLevel level) {
void log(String message, LogLevel level) {
if (shouldLog(level)) {
log(message, level, group, className);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* 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.logging;

import edu.wpi.first.cscore.CameraServerJNI;
import java.nio.file.Path;

/** Redirect cscore logs to our logger */
public class PvCSCoreLogger {
private static PvCSCoreLogger INSTANCE;

public static PvCSCoreLogger getInstance() {
if (INSTANCE == null) {
INSTANCE = new PvCSCoreLogger();
}
return INSTANCE;
}

private Logger logger;

private PvCSCoreLogger() {
CameraServerJNI.setLogger(this::logMsg, 7);
this.logger = new Logger(getClass(), LogGroup.CSCore);
}

private void logMsg(int level, String file, int line, String msg) {
if (level == 20) {
logger.info(msg);
return;
}

file = Path.of(file).getFileName().toString();

String levelmsg;
LogLevel pvlevel;
if (level >= 50) {
levelmsg = "CRITICAL";
pvlevel = LogLevel.ERROR;
} else if (level >= 40) {
levelmsg = "ERROR";
pvlevel = LogLevel.ERROR;
} else if (level >= 30) {
levelmsg = "WARNING";
pvlevel = LogLevel.WARN;
} else if (level >= 20) {
levelmsg = "INFO";
pvlevel = LogLevel.INFO;
} else {
levelmsg = "DEBUG";
pvlevel = LogLevel.DEBUG;
}
logger.log(
"CS: " + levelmsg + " " + level + ": " + msg + " (" + file + ":" + line + ")", pvlevel);
}
}
Loading

0 comments on commit 77d571c

Please sign in to comment.