-
Notifications
You must be signed in to change notification settings - Fork 62
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
base: dev
Are you sure you want to change the base?
Conversation
…y Panel attatched
There was a problem hiding this 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.
There was a problem hiding this 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.
Ok, thanks for letting me know, @AlexD717 @ryanzhangofficial For the identification issue, is searching by name valid? This is from |
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. |
Initially, was only checking cache. Added step to load from manifest beforehand, then retrieve and spawn.
There was a problem hiding this 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
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) | ||
} | ||
} | ||
) |
There was a problem hiding this comment.
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.
There was a problem hiding this 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
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) | ||
} | ||
} | ||
), | ||
]) |
There was a problem hiding this comment.
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
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) | ||
} | ||
} | ||
), | ||
]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) | |
} | |
}) | |
}} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
AARD-1972
Description
Added a third button to initial Welcome Modal named Load Default that does the following
Loads in the field in cache with field.id equals "1750390764392" (FTC Field 2018 v13).
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:
Upon Clicking Load Default