Skip to content

Create Load Default Option for Field and Robot with Gizmo and Assembl… #1189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from

Conversation

RoushilS
Copy link

@RoushilS RoushilS commented Jul 1, 2025

AARD-1972

Description

Added a third button to initial Welcome Modal named Load Default that does the following

  1. Loads in the field in cache with field.id equals "1750390764392" (FTC Field 2018 v13).

  2. Loads in the robot in cache with robot.id equals "1750914383413" with Gizmo and Assembly Panel (Dozer v9).

Other button functionality remains the same.

New Welcome Modal:

Screenshot 2025-06-26 160756

Upon Clicking Load Default

image

@RoushilS RoushilS requested review from a team as code owners July 1, 2025 23:13
@BrandonPacewic BrandonPacewic added the ui/ux Relating to user interface, or in general, user experience label Jul 1, 2025
ryanzhangofficial

This comment was marked as outdated.

Copy link
Member

@AlexD717 AlexD717 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach only works if the user has previously cached the robot and field files. On a user's first visit to the website, GetCacheInfo() returns an empty array, so nothing is spawned.

Additionally, each time an object is downloaded from the server, it is assigned a new ID. As a result, the id field cannot be reliably used to identify which field or robot should be spawned.

Copy link
Member

@ryanzhangofficial ryanzhangofficial left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see that issue too now. I would look at the manifest in ImportMirabufPanel.tsx for a cleaner solution.

@RoushilS
Copy link
Author

RoushilS commented Jul 3, 2025

Ok, thanks for letting me know, @AlexD717 @ryanzhangofficial
My understanding is that the default robot and field data get loaded from the manifest, then get sent to the User's cache. They can be retrieved from the cache and spawned. However, the problem I'm finding is that the manifest object is located within ImportMirabufPanel, and there's currently only functionality for the User to cache the default fields and robots.
I am looking for a different method.

For the identification issue, is searching by name valid? This is from /api/mira/manifest.json
Screenshot 2025-07-03 134451

@AlexD717
Copy link
Member

AlexD717 commented Jul 3, 2025

I would start by looking at the CacheRemote function in MirabufLoader.ts, I think that fetches the data from the remote. As for filtering by name, that should work.

RoushilS added 3 commits July 3, 2025 15:08
Initially, was only checking cache. Added step to load from manifest beforehand, then retrieve and spawn.
Copy link
Member

@AlexD717 AlexD717 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you spawn the 2023 field instead of the 2018 field? Currently the robot gets spawned inside the center structure and is stuck there, while the 2023 field has no center object there.

Uses 2023 field instead of 2018 field to avoid getting stuck within the center structure
Comment on lines 41 to 55
MirabufCachingService.CacheRemote(
"/api/mira/fields/FRC Field 2023_v7.mira",
MiraType.FIELD
).then(cacheInfoField => {
if (cacheInfoField) {
SpawnCachedMira(cacheInfoField, MiraType.FIELD)
}
})
MirabufCachingService.CacheRemote("/api/mira/robots/Dozer_v9.mira", MiraType.ROBOT).then(
cacheInfoRobot => {
if (cacheInfoRobot) {
SpawnCachedMira(cacheInfoRobot, MiraType.ROBOT)
}
}
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way these promises are set up means that the order isn't guaranteed and if the robot is spawned first, you have to configure/position it without seeing the field. I think it makes more sense to make sure the field spawns first. You can use Promise.all(...) here to do this and still let you download them both simultaneously

Add Promise.All([]) which allows for promises to individually complete and callback and then run sequentially.
Copy link
Member

@AlexD717 AlexD717 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

Comment on lines +41 to +57
Promise.all([
MirabufCachingService.CacheRemote(
"/api/mira/fields/FRC Field 2023_v7.mira",
MiraType.FIELD
).then(cacheInfoField => {
if (cacheInfoField) {
SpawnCachedMira(cacheInfoField, MiraType.FIELD)
}
}),
MirabufCachingService.CacheRemote("/api/mira/robots/Dozer_v9.mira", MiraType.ROBOT).then(
cacheInfoRobot => {
if (cacheInfoRobot) {
SpawnCachedMira(cacheInfoRobot, MiraType.ROBOT)
}
}
),
])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still doesn't guarantee order, because you're still spawning the files immediately after their respective promises resolve, rather than spawning synchronously after both cache requests resolve

MDN Promise.all()

Comment on lines +38 to +57
onClick={() => {
closeModal()
startSingleplayerCallback()
Promise.all([
MirabufCachingService.CacheRemote(
"/api/mira/fields/FRC Field 2023_v7.mira",
MiraType.FIELD
).then(cacheInfoField => {
if (cacheInfoField) {
SpawnCachedMira(cacheInfoField, MiraType.FIELD)
}
}),
MirabufCachingService.CacheRemote("/api/mira/robots/Dozer_v9.mira", MiraType.ROBOT).then(
cacheInfoRobot => {
if (cacheInfoRobot) {
SpawnCachedMira(cacheInfoRobot, MiraType.ROBOT)
}
}
),
])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
onClick={() => {
closeModal()
startSingleplayerCallback()
Promise.all([
MirabufCachingService.CacheRemote(
"/api/mira/fields/FRC Field 2023_v7.mira",
MiraType.FIELD
).then(cacheInfoField => {
if (cacheInfoField) {
SpawnCachedMira(cacheInfoField, MiraType.FIELD)
}
}),
MirabufCachingService.CacheRemote("/api/mira/robots/Dozer_v9.mira", MiraType.ROBOT).then(
cacheInfoRobot => {
if (cacheInfoRobot) {
SpawnCachedMira(cacheInfoRobot, MiraType.ROBOT)
}
}
),
])
onClick={() => {
closeModal()
startSingleplayerCallback()
let cachedField: MirabufCacheInfo | undefined
let cachedRobot: MirabufCacheInfo | undefined
Promise.all([
MirabufCachingService.CacheRemote(
"/api/mira/fields/FRC Field 2023_v7.mira",
MiraType.FIELD
).then(cacheInfoField => {
if (cacheInfoField) { cachedField = cacheInfoField }
}),
MirabufCachingService.CacheRemote("/api/mira/robots/Dozer_v9.mira", MiraType.ROBOT).then(
cacheInfoRobot => { if (cacheInfoRobot) { cachedRobot = cacheInfoRobot } }
),
]).then(() => {
if (cachedField && cachedRobot) {
SpawnCachedMira(cachedField, MiraType.FIELD)
SpawnCachedMira(cachedRobot, MiraType.ROBOT)
}
})
}}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a solution you could look into for resolving zach's comment

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the promise.all Promise returns the individual promise results as an array, you don't need to have cachedField and cachedRobot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ui/ux Relating to user interface, or in general, user experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants