Skip to content

Commit 2372681

Browse files
Merge dev
* 'dev' of github.com:Autodesk/synthesis: fix: make returns consistent fix: make the test match id not overlap with unit tests feat: update assetpack feat: load match mode configs from manifest file instead
2 parents 747ba2d + 27a46c2 commit 2372681

File tree

9 files changed

+71
-106
lines changed

9 files changed

+71
-106
lines changed

fission/public/assetpack.zip

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:23bfaf7899d84b00331c12bf1ada20d27d3c50856b14bb5733821b44848812ba
3-
size 193147860
2+
oid sha256:ea7be96ce500ebef474d55314ad0e547dac7015763664574978417016d64a6f6
3+
size 193148563

fission/src/main.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ import "./index.css"
44
import APS from "./aps/APS"
55

66
window.convertAuthToken = code => APS.convertAuthToken(code)
7-
87
ReactDOM.createRoot(document.getElementById("root")!).render(<Synthesis />)
Lines changed: 34 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,44 @@
11
import type { MatchModeConfig } from "@/ui/panels/configuring/MatchModeConfigPanel"
2-
import { convertFeetToMeters } from "@/util/UnitConversions"
2+
import { API_URL } from "@/util/Consts.ts"
3+
4+
type ManifestMatchModeConfig = Omit<MatchModeConfig, "id"> & { id: string }
5+
interface MatchConfigManifest {
6+
private: Record<string, ManifestMatchModeConfig>
7+
public: Record<string, ManifestMatchModeConfig>
8+
}
39

410
/** The purpose of this class is to store any defaults related to match mode configurations. */
511
class DefaultMatchModeConfigs {
6-
static frcReefscape2025 = (): MatchModeConfig => {
7-
return {
8-
id: "FRC-Reefscape-2025",
9-
name: "FRC Reefscape 2025",
10-
isDefault: true,
11-
autonomousTime: 15,
12-
teleopTime: 135,
13-
endgameTime: 20,
14-
ignoreRotation: true,
15-
maxHeight: Number.MAX_SAFE_INTEGER,
16-
heightLimitPenalty: 0,
17-
sideMaxExtension: convertFeetToMeters(1.5),
18-
sideExtensionPenalty: 0,
19-
}
20-
}
12+
private static readonly MANIFEST_LOCATION = `${API_URL}/match_configs/manifest.json`
13+
private static _configs: MatchModeConfig[] = []
2114

22-
static frcCrescendo2024 = (): MatchModeConfig => {
23-
return {
24-
id: "FRC-Crescendo-2024",
25-
name: "FRC Crescendo 2024",
26-
isDefault: true,
27-
autonomousTime: 15,
28-
teleopTime: 135,
29-
endgameTime: 20,
30-
ignoreRotation: true,
31-
maxHeight: convertFeetToMeters(4),
32-
heightLimitPenalty: 2,
33-
sideMaxExtension: convertFeetToMeters(1),
34-
sideExtensionPenalty: 2,
35-
}
15+
static {
16+
setTimeout(() => this.reload())
3617
}
37-
38-
static frcPowerUp2023 = (): MatchModeConfig => {
39-
return {
40-
id: "FRC-Power-Up-2023",
41-
name: "FRC Power Up 2023",
42-
isDefault: true,
43-
autonomousTime: 15,
44-
teleopTime: 135,
45-
endgameTime: 30,
46-
ignoreRotation: true,
47-
maxHeight: convertFeetToMeters(6.5),
48-
heightLimitPenalty: 5,
49-
sideMaxExtension: convertFeetToMeters(4),
50-
sideExtensionPenalty: 5,
18+
static async reload() {
19+
const manifest = await fetch(this.MANIFEST_LOCATION)
20+
const json: MatchConfigManifest | undefined = await manifest.json().catch(e => {
21+
console.error(e)
22+
return undefined
23+
})
24+
if (json == null) {
25+
console.error("Could not load match mode manifest")
26+
return undefined
27+
}
28+
const keys: (keyof MatchConfigManifest)[] = import.meta.env.DEV
29+
? (["public", "private"] as const)
30+
: (["public"] as const)
31+
for (const key of keys) {
32+
const configs = json[key as keyof MatchConfigManifest]
33+
Object.entries(configs).forEach(([key, value]) => {
34+
value.id = key
35+
this._configs.push(value)
36+
})
5137
}
5238
}
5339

54-
static matchTest = (): MatchModeConfig => {
55-
return {
56-
id: "Match-Test",
57-
name: "Match Test",
58-
isDefault: true,
59-
autonomousTime: 5,
60-
teleopTime: 15,
61-
endgameTime: 5,
62-
ignoreRotation: true,
63-
maxHeight: Number.MAX_SAFE_INTEGER,
64-
heightLimitPenalty: 0,
65-
sideMaxExtension: Number.MAX_SAFE_INTEGER,
66-
sideExtensionPenalty: 0,
67-
}
40+
public static get configs(): MatchModeConfig[] {
41+
return this._configs
6842
}
6943

7044
static fallbackValues = (): MatchModeConfig => {
@@ -76,22 +50,12 @@ class DefaultMatchModeConfigs {
7650
teleopTime: 135,
7751
endgameTime: 20,
7852
ignoreRotation: true,
79-
maxHeight: Number.MAX_SAFE_INTEGER,
53+
maxHeight: -1,
8054
heightLimitPenalty: 2,
81-
sideMaxExtension: Number.MAX_SAFE_INTEGER,
55+
sideMaxExtension: -1,
8256
sideExtensionPenalty: 2,
8357
}
8458
}
85-
86-
/** @returns {MatchModeConfig[]} New copies of the default match mode configs without reference to any others. */
87-
public static get defaultMatchModeConfigCopies(): MatchModeConfig[] {
88-
return [
89-
DefaultMatchModeConfigs.frcReefscape2025(),
90-
DefaultMatchModeConfigs.frcCrescendo2024(),
91-
DefaultMatchModeConfigs.frcPowerUp2023(),
92-
DefaultMatchModeConfigs.matchTest(),
93-
]
94-
}
9559
}
9660

9761
export default DefaultMatchModeConfigs

fission/src/systems/match_mode/RobotDimensionTracker.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class RobotDimensionTracker {
3434
World.sceneRenderer.mirabufSceneObjects.getRobots().forEach(robot => {
3535
const dimensions = this._ignoreRotation ? robot.getDimensionsWithoutRotation() : robot.getDimensions()
3636

37-
if (dimensions.height > this._maxHeight + BUFFER_HEIGHT) {
37+
if (this._maxHeight !== -1 && dimensions.height > this._maxHeight + BUFFER_HEIGHT) {
3838
if (!(this._robotLastFramePenalty.get(robot.id) ?? false)) {
3939
SimulationSystem.robotPenalty(robot, this._heightLimitPenalty, "Height Expansion Limit")
4040
}
@@ -44,8 +44,9 @@ class RobotDimensionTracker {
4444

4545
const startingRobotSize = this._robotSize.get(robot.id) ?? { width: Infinity, depth: Infinity }
4646
if (
47-
dimensions.width > startingRobotSize.width + this._sideMaxExtension + SIDE_BUFFER ||
48-
dimensions.depth > startingRobotSize.depth + this._sideMaxExtension + SIDE_BUFFER
47+
this._sideMaxExtension !== -1 &&
48+
(dimensions.width > startingRobotSize.width + this._sideMaxExtension + SIDE_BUFFER ||
49+
dimensions.depth > startingRobotSize.depth + this._sideMaxExtension + SIDE_BUFFER)
4950
) {
5051
if (!(this._robotLastFramePenalty.get(robot.id) ?? false)) {
5152
SimulationSystem.robotPenalty(robot, this._sideExtensionPenalty, "Side Expansion Limit")

fission/src/ui/panels/configuring/CreateNewMatchModeConfigPanel.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ const FIELD_CONFIGS: Record<string, FieldConfig> = {
9191
type: "checkbox",
9292
},
9393
maxHeight: {
94-
defaultValue: fallbackConfig.maxHeight === Number.MAX_SAFE_INTEGER ? 1.2 : fallbackConfig.maxHeight,
94+
defaultValue: fallbackConfig.maxHeight === -1 ? 1.2 : fallbackConfig.maxHeight,
9595
rules: [VALIDATION_RULES.nonNegativeNumber("Max height must be a non-negative number")],
9696
type: "decimal",
9797
},
@@ -106,8 +106,7 @@ const FIELD_CONFIGS: Record<string, FieldConfig> = {
106106
type: "checkbox",
107107
},
108108
sideMaxExtension: {
109-
defaultValue:
110-
fallbackConfig.sideMaxExtension === Number.MAX_SAFE_INTEGER ? 0.5 : fallbackConfig.sideMaxExtension,
109+
defaultValue: fallbackConfig.sideMaxExtension === -1 ? 0.5 : fallbackConfig.sideMaxExtension,
111110
rules: [VALIDATION_RULES.nonNegativeNumber("Side max extension must be a non-negative number")],
112111
type: "decimal",
113112
},
@@ -260,15 +259,13 @@ const CreateNewMatchModeConfigPanel: React.FC<PanelImplProps<void, void>> = ({ p
260259
teleopTime: parseInt(formState.teleopTime.value as string, 10),
261260
endgameTime: parseInt(formState.endgameTime.value as string, 10),
262261
ignoreRotation: formState.ignoreRotation.value as boolean,
263-
maxHeight: formState.enableHeightPenalty.value
264-
? parseFloat(formState.maxHeight.value as string)
265-
: Number.MAX_SAFE_INTEGER,
262+
maxHeight: formState.enableHeightPenalty.value ? parseFloat(formState.maxHeight.value as string) : -1,
266263
heightLimitPenalty: formState.enableHeightPenalty.value
267264
? parseFloat(formState.heightLimitPenalty.value as string)
268265
: 0,
269266
sideMaxExtension: formState.enableSideExtensionPenalty.value
270267
? parseFloat(formState.sideMaxExtension.value as string)
271-
: Number.MAX_SAFE_INTEGER,
268+
: -1,
272269
sideExtensionPenalty: formState.enableSideExtensionPenalty.value
273270
? parseFloat(formState.sideExtensionPenalty.value as string)
274271
: 0,

fission/src/ui/panels/configuring/MatchModeConfigPanel.tsx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,54 +22,54 @@ import CreateNewMatchModeConfigPanel from "./CreateNewMatchModeConfigPanel"
2222
*/
2323
export interface MatchModeConfig {
2424
/** Unique identifier for this match mode configuration */
25-
id: string
25+
readonly id: string
2626

2727
/** Human-readable name for this match mode configuration */
28-
name: string
28+
readonly name: string
2929

3030
/** Whether this is a built-in default configuration (cannot be deleted) */
31-
isDefault: boolean
31+
readonly isDefault: boolean
3232

3333
/** Duration of autonomous period in seconds (default: 15) */
34-
autonomousTime: number
34+
readonly autonomousTime: number
3535

3636
/** Duration of teleoperated period in seconds (default: 135) */
37-
teleopTime: number
37+
readonly teleopTime: number
3838

3939
/** Duration of endgame period in seconds (default: 20) */
40-
endgameTime: number
40+
readonly endgameTime: number
4141

4242
/**
4343
* Whether to ignore robot rotation when calculating height violations.
4444
* If true, the height limit will be calculated relative to the base of the robot, rather than the base of the field
4545
* (default: true)
4646
*/
47-
ignoreRotation: boolean
47+
readonly ignoreRotation: boolean
4848

4949
/**
5050
* Maximum allowed robot height in meters (stored internally).
5151
* Set to Infinity for no height limit. (default: Infinity)
5252
*/
53-
maxHeight: number
53+
readonly maxHeight: number
5454

5555
/**
5656
* Points to penalize for height limit violations (default: 2).
5757
* Applied each time a robot exceeds maxHeight after cooldown period.
5858
*/
59-
heightLimitPenalty: number
59+
readonly heightLimitPenalty: number
6060

6161
/**
6262
* Maximum allowed robot side extension in meters
6363
* User input is in feet but converted to meters during config processing.
6464
* Set to Infinity for no side extension limit. (default: Infinity)
6565
*/
66-
sideMaxExtension: number
66+
readonly sideMaxExtension: number
6767

6868
/**
6969
* Points to penalize for side extension violations (default: 2).
7070
* Applied each time a robot exceeds sideMaxExtension after cooldown period.
7171
*/
72-
sideExtensionPenalty: number
72+
readonly sideExtensionPenalty: number
7373
}
7474

7575
const props: Readonly<{ id: keyof MatchModeConfig; expectedType: string; required: boolean }>[] = [
@@ -179,7 +179,8 @@ const MatchModeConfigPanel: React.FC<PanelImplProps<void, void>> = ({ panel }) =
179179
useEffect(() => {
180180
const loadConfigs = () => {
181181
try {
182-
const defaultConfigs = DefaultMatchModeConfigs.defaultMatchModeConfigCopies
182+
const defaultConfigs = DefaultMatchModeConfigs.configs
183+
console.log(defaultConfigs)
183184
const localConfigs = JSON.parse(window.localStorage.getItem("match-mode-configs") || "[]")
184185

185186
const combinedConfigs = [...defaultConfigs, ...localConfigs]

fission/src/ui/panels/mirabuf/ImportMirabufPanel.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
import { useStateContext } from "@/ui/helpers/StateProviderHelpers"
3939
import { CloseType, useUIContext } from "@/ui/helpers/UIProviderHelpers"
4040
import ImportLocalMirabufModal from "@/ui/modals/mirabuf/ImportLocalMirabufModal"
41+
import { API_URL } from "@/util/Consts.ts"
4142
import type TaskStatus from "@/util/TaskStatus"
4243
import type { ConfigurationType } from "../configuring/assembly-config/ConfigTypes"
4344
import InitialConfigPanel from "../configuring/initial-config/InitialConfigPanel"
@@ -192,18 +193,14 @@ const ImportMirabufPanel: React.FC<PanelImplProps<void, ImportMirabufPanelCustom
192193
useEffect(() => {
193194
// To remove the prettier warning
194195
const x = async () => {
195-
// Detect if we're running in electron and use direct remote URL
196-
const isElectron = window.electronAPI != null
197-
const baseUrl = isElectron ? "https://synthesis.autodesk.com" : ""
198-
199-
fetch(`${baseUrl}/api/mira/manifest.json`)
196+
fetch(`${API_URL}/mira/manifest.json`)
200197
.then(x => x.json())
201198
.then(x => {
202199
const map = MirabufCachingService.getCacheMap(MiraType.ROBOT)
203200
const robots: MirabufRemoteInfo[] = []
204201
for (const src of x["robots"]) {
205202
if (typeof src == "string") {
206-
const str = `${baseUrl}/api/mira/robots/${src}`
203+
const str = `${API_URL}/mira/robots/${src}`
207204
if (!map[str]) robots.push({ displayName: src, src: str })
208205
} else {
209206
if (!map[src.src]) robots.push({ displayName: src.displayName, src: src.src })
@@ -212,7 +209,7 @@ const ImportMirabufPanel: React.FC<PanelImplProps<void, ImportMirabufPanelCustom
212209
const fields: MirabufRemoteInfo[] = []
213210
for (const src of x["fields"]) {
214211
if (typeof src == "string") {
215-
const str = `${baseUrl}/api/mira/fields/${src}`
212+
const str = `${API_URL}/mira/fields/${src}`
216213
if (!map[str]) fields.push({ displayName: src, src: str })
217214
} else {
218215
if (!map[src.src]) fields.push({ displayName: src.displayName, src: src.src })

fission/src/util/Consts.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const isElectron = window.electronAPI != null
2+
const baseUrl = isElectron ? "https://synthesis.autodesk.com" : ""
3+
export const API_URL = `${baseUrl}/api`

fission/vite.config.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import fs from "node:fs/promises"
22
import basicSsl from "@vitejs/plugin-basic-ssl"
33
import react from "@vitejs/plugin-react-swc"
44
import * as path from "path"
5-
import { loadEnv, type ProxyOptions } from "vite"
5+
import {loadEnv, type ProxyOptions} from "vite"
66
import glsl from "vite-plugin-glsl"
7-
import { defineConfig } from "vitest/config"
7+
import {defineConfig} from "vitest/config"
88

99
const basePath = "/fission/"
1010
const serverPort = 3000
@@ -58,14 +58,15 @@ export default defineConfig(async ({ mode }) => {
5858
console.log(`Using ${useLocalAssets ? "local" : "remote"} mirabuf assets`)
5959

6060
const proxies: Record<string, ProxyOptions> = {}
61-
proxies["/api/mira"] = useLocalAssets
61+
const assetProxy:ProxyOptions = useLocalAssets
6262
? {
6363
target: `http://localhost:${mode === "test" ? 3001 : serverPort}`,
6464
changeOrigin: true,
6565
secure: false,
6666
rewrite: path =>
6767
path
68-
.replace(/^\/api\/mira/, "/Downloadables/Mira")
68+
.replace(/^\/api/, "/Downloadables")
69+
.replace("mira", "Mira")
6970
.replace("robots", "Robots")
7071
.replace("fields", "Fields"),
7172
}
@@ -74,6 +75,8 @@ export default defineConfig(async ({ mode }) => {
7475
changeOrigin: true,
7576
secure: true,
7677
}
78+
proxies["/api/mira"] = assetProxy
79+
proxies["/api/match_configs"] = assetProxy
7780
proxies["/api/aps"] = useLocalAPS
7881
? {
7982
target: `http://localhost:${dockerServerPort}/`,

0 commit comments

Comments
 (0)