Skip to content

Commit

Permalink
Fix merge conflicts & run lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mcm001 committed Sep 1, 2023
1 parent e9dacb7 commit 4bd8583
Show file tree
Hide file tree
Showing 9 changed files with 151 additions and 211 deletions.
5 changes: 1 addition & 4 deletions photon-client/src/components/app/photon-log-view.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@ document.addEventListener("keydown", (e) => {
{{ getLogLevelFromIndex(level) }}
</v-btn>
</v-btn-toggle>
<v-card-text
v-if="logs.length === 0"
style="font-size: 18px; font-weight: 600"
>
<v-card-text v-if="logs.length === 0" style="font-size: 18px; font-weight: 600">
There are no logs to show
</v-card-text>
<v-virtual-scroll v-else :items="logs" item-height="50" height="600">
Expand Down
15 changes: 12 additions & 3 deletions photon-client/src/components/dashboard/tabs/OutputTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ const offsetPoints = computed<MetricItem[]>(() => {
const currentPipelineSettings = useCameraSettingsStore().currentPipelineSettings;
const interactiveCols = computed(() => (getCurrentInstance()?.proxy.$vuetify.breakpoint.mdAndDown || false) && (!useStateStore().sidebarFolded || useCameraSettingsStore().isDriverMode)) ? 9 : 8;
const interactiveCols = computed(
() =>
(getCurrentInstance()?.proxy.$vuetify.breakpoint.mdAndDown || false) &&
(!useStateStore().sidebarFolded || useCameraSettingsStore().isDriverMode)
)
? 9
: 8;
</script>

<template>
Expand Down Expand Up @@ -79,11 +85,14 @@ const interactiveCols = computed(() => (getCurrentInstance()?.proxy.$vuetify.bre
"
/>
<cv-switch
v-if="currentPipelineSettings.pipelineType === PipelineType.AprilTag && useCameraSettingsStore().isCurrentVideoFormatCalibrated"
v-if="
currentPipelineSettings.pipelineType === PipelineType.AprilTag &&
useCameraSettingsStore().isCurrentVideoFormatCalibrated
"
v-model="currentPipelineSettings.doMultiTarget"
label="Multitag"
:switch-cols="interactiveCols"
@input="value => useCameraSettingsStore().changeCurrentPipelineSetting({doMultiTarget: value}, false)"
@input="(value) => useCameraSettingsStore().changeCurrentPipelineSetting({ doMultiTarget: value }, false)"
/>
<v-divider />
<table
Expand Down
8 changes: 7 additions & 1 deletion photon-client/src/components/settings/DeviceControlCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,13 @@ const handleSettingsImport = () => {
v-model="importType"
label="Type"
tooltip="Select the type of settings file you are trying to upload"
:items="['All Settings', 'Hardware Config', 'Hardware Settings', 'Network Config', 'Apriltag Layout']"
:items="[
'All Settings',
'Hardware Config',
'Hardware Settings',
'Network Config',
'Apriltag Layout'
]"
:select-cols="10"
/>
</v-row>
Expand Down
36 changes: 18 additions & 18 deletions photon-client/src/components/settings/MetricsCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,24 @@ const platformMetrics = computed<MetricItem[]>(() => [
const metricsLastFetched = ref("Never");
const fetchMetrics = () => {
useSettingsStore()
.requestMetricsUpdate()
.catch(error => {
if(error.request) {
useStateStore().showSnackbarMessage({
color: "error",
message: "Unable to fetch metrics! The backend didn't respond."
});
} else {
useStateStore().showSnackbarMessage({
color: "error",
message: "An error occurred while trying to fetch metrics."
});
}
})
.finally(() => {
const pad = (num: number): string => {
return String(num).padStart(2, "0");
};
.requestMetricsUpdate()
.catch((error) => {
if (error.request) {
useStateStore().showSnackbarMessage({
color: "error",
message: "Unable to fetch metrics! The backend didn't respond."
});
} else {
useStateStore().showSnackbarMessage({
color: "error",
message: "An error occurred while trying to fetch metrics."
});
}
})
.finally(() => {
const pad = (num: number): string => {
return String(num).padStart(2, "0");
};
const date = new Date();
metricsLastFetched.value = `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
Expand Down
128 changes: 26 additions & 102 deletions photon-client/src/stores/settings/GeneralSettingsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,111 +13,33 @@ import type { WebsocketSettingsUpdate } from "@/types/WebsocketDataTypes";
import type { AprilTagFieldLayout } from "@/types/PhotonTrackingTypes";

interface GeneralSettingsStore {
general: GeneralSettings,
network: NetworkSettings,
lighting: LightingSettings,
metrics: MetricData,
currentFieldLayout?: AprilTagFieldLayout
general: GeneralSettings;
network: NetworkSettings;
lighting: LightingSettings;
metrics: MetricData;
currentFieldLayout?: AprilTagFieldLayout;
}

export const useSettingsStore = defineStore("settings", {
state: (): GeneralSettingsStore => ({
general: {
version: undefined,
gpuAcceleration: undefined,
hardwareModel: undefined,
hardwarePlatform: undefined
},
network: {
ntServerAddress: "",
shouldManage: true,
canManage: true,
connectionType: NetworkConnectionType.DHCP,
staticIp: "",
hostname: "photonvision",
runNTServer: false,
networkInterfaceNames: [
{
connName: "Example Wired Connection",
devName: "eth0"
}
]
},
lighting: {
supported: true,
brightness: 0
},
metrics: {
cpuTemp: undefined,
cpuUtil: undefined,
cpuMem: undefined,
gpuMem: undefined,
ramUtil: undefined,
gpuMemUtil: undefined,
cpuThr: undefined,
cpuUptime: undefined,
diskUtilPct: undefined
},
currentFieldLayout: undefined
}),
getters: {
gpuAccelerationEnabled(): boolean {
return this.general.gpuAcceleration !== undefined;
}
state: (): GeneralSettingsStore => ({
general: {
version: undefined,
gpuAcceleration: undefined,
hardwareModel: undefined,
hardwarePlatform: undefined
},
actions: {
requestMetricsUpdate() {
return axios.post("/utils/publishMetrics");
},
updateMetricsFromWebsocket(data: Required<MetricData>) {
this.metrics = {
cpuTemp: data.cpuTemp || undefined,
cpuUtil: data.cpuUtil || undefined,
cpuMem: data.cpuMem || undefined,
gpuMem: data.gpuMem || undefined,
ramUtil: data.ramUtil || undefined,
gpuMemUtil: data.gpuMemUtil || undefined,
cpuThr: data.cpuThr || undefined,
cpuUptime: data.cpuUptime || undefined,
diskUtilPct: data.diskUtilPct || undefined
};
},
updateGeneralSettingsFromWebsocket(data: WebsocketSettingsUpdate) {
this.general = {
version: data.general.version || undefined,
hardwareModel: data.general.hardwareModel || undefined,
hardwarePlatform: data.general.hardwarePlatform || undefined,
gpuAcceleration: data.general.gpuAcceleration || undefined
};
this.lighting = data.lighting;
this.network = data.networkSettings;
this.currentFieldLayout = data.atfl;
},
saveGeneralSettings() {
const payload: Required<NetworkSettings> = {
connectionType: this.network.connectionType,
hostname: this.network.hostname,
networkManagerIface: this.network.networkManagerIface || "",
ntServerAddress: this.network.ntServerAddress,
physicalInterface: this.network.physicalInterface || "",
runNTServer: this.network.runNTServer,
setDHCPcommand: this.network.setDHCPcommand || "",
setStaticCommand: this.network.setStaticCommand || "",
shouldManage: this.network.shouldManage,
staticIp: this.network.staticIp
};
return axios.post("/settings/general", payload);
},
/**
* Modify the brightness of the LEDs.
*
* @param brightness brightness to set [0, 100]
*/
changeLEDBrightness(brightness: number) {
const payload = {
enabledLEDPercentage: brightness
};
useStateStore().websocket?.send(payload, true);
network: {
ntServerAddress: "",
shouldManage: true,
canManage: true,
connectionType: NetworkConnectionType.DHCP,
staticIp: "",
hostname: "photonvision",
runNTServer: false,
networkInterfaceNames: [
{
connName: "Example Wired Connection",
devName: "eth0"
}
]
},
Expand All @@ -135,7 +57,8 @@ export const useSettingsStore = defineStore("settings", {
cpuThr: undefined,
cpuUptime: undefined,
diskUtilPct: undefined
}
},
currentFieldLayout: undefined
}),
getters: {
gpuAccelerationEnabled(): boolean {
Expand Down Expand Up @@ -171,6 +94,7 @@ export const useSettingsStore = defineStore("settings", {
};
this.lighting = data.lighting;
this.network = data.networkSettings;
this.currentFieldLayout = data.atfl;
},
saveGeneralSettings() {
const payload: Required<ConfigurableNetworkSettings> = {
Expand Down
96 changes: 48 additions & 48 deletions photon-client/src/types/PhotonTrackingTypes.ts
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
export interface Transform3d {
x: number,
y: number,
z: number,
qw: number,
qx: number,
qy: number,
qz: number,
angle_z: number
x: number;
y: number;
z: number;
qw: number;
qx: number;
qy: number;
qz: number;
angle_z: number;
}

export interface AprilTagFieldLayout {
field: {
length: number,
width: number
},
tags: {
ID: number,
pose: {
translation: {
x: number,
y: number,
z: number
},
rotation: {
quaternion: {
X: number,
Y: number,
Z: number,
W: number
}
}
}
}[]
field: {
length: number;
width: number;
};
tags: {
ID: number;
pose: {
translation: {
x: number;
y: number;
z: number;
};
rotation: {
quaternion: {
X: number;
Y: number;
Z: number;
W: number;
};
};
};
}[];
}

export interface PhotonTarget {
yaw: number,
pitch: number,
skew: number,
area: number,
// -1 if not set
ambiguity: number,
// -1 if not set
fiducialId: number,
// undefined if 3d isn't enabled
pose?: Transform3d
yaw: number;
pitch: number;
skew: number;
area: number;
// -1 if not set
ambiguity: number;
// -1 if not set
fiducialId: number;
// undefined if 3d isn't enabled
pose?: Transform3d;
}

export interface MultitagResult {
bestTransform: Transform3d,
bestReprojectionError: number
fiducialIDsUsed: number[]
bestTransform: Transform3d;
bestReprojectionError: number;
fiducialIDsUsed: number[];
}

export interface PipelineResult {
fps: number,
latency: number,
targets: PhotonTarget[],
// undefined if multitag failed or non-tag pipeline
multitagResult?: MultitagResult
fps: number;
latency: number;
targets: PhotonTarget[];
// undefined if multitag failed or non-tag pipeline
multitagResult?: MultitagResult;
}
22 changes: 11 additions & 11 deletions photon-client/src/types/PipelineTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,17 +204,17 @@ export const DefaultColoredShapePipelineSettings: ColoredShapePipelineSettings =
};

export interface AprilTagPipelineSettings extends PipelineSettings {
pipelineType: PipelineType.AprilTag
hammingDist: number
numIterations: number
decimate: number
blur: number
decisionMargin: number
refineEdges: boolean
debug: boolean
threads: number
tagFamily: AprilTagFamily,
doMultiTarget: boolean
pipelineType: PipelineType.AprilTag;
hammingDist: number;
numIterations: number;
decimate: number;
blur: number;
decisionMargin: number;
refineEdges: boolean;
debug: boolean;
threads: number;
tagFamily: AprilTagFamily;
doMultiTarget: boolean;
}
export type ConfigurableAprilTagPipelineSettings = Partial<
Omit<AprilTagPipelineSettings, "pipelineType" | "hammingDist" | "debug">
Expand Down
Loading

0 comments on commit 4bd8583

Please sign in to comment.