-
Notifications
You must be signed in to change notification settings - Fork 13
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
Use workflows for model spawning #238
Open
luca-della-vedova
wants to merge
21
commits into
main
Choose a base branch
from
luca/model_workflows
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
Signed-off-by: Luca Della Vedova <lucadellavr@gmail.com>
Signed-off-by: Luca Della Vedova <lucadellavr@gmail.com>
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
ad502f0 contains an example of removing the marker component, it will mean that users have to rely on a less obvious component to keep track of which model failed loading but saves some code, I'm happy with both options. |
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
1 task
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New feature implementation
Implemented feature
This PR brings model loading from a fairly complex state machine involving several marker components and implicit system ordering to workflow. This unlocks the following:
ModelTrashCan
that we introduced before to avoid panics, we can now just do a normaldespawn_recursive()
Implementation description
High level
A new workflow for model loading with a command implementation has been added, its inputs are the entity that the model should be spawned in, as well as its asset source.
Workflow details
spawn_model
takes aModelLoadingRequest
as an input, which can be default initialized from a(Entity, AssetSource)
, but also uses a builder pattern so users can provide aCallback<Entity, ()>
that will be called on the model if it spawned correctly. This is currently used for workcell editor mode, where we want to do a custom action on the model (for example post-process its hierarchy).rmf_site/rmf_site_editor/src/interaction/select/place_object_3d.rs
Lines 477 to 478 in 9bde074
The workflow itself propagates its request throughout and returns a
ModelLoadingResult
:rmf_site/rmf_site_editor/src/site/model.rs
Line 63 in 9bde074
The result will contain :
Ok(the original request)
if successful.Err(None)
if the workflow was aborted but without an error. Currently this happens only if the model was not spawned because it already contains a scene with the requestedAssetSource
, this could happen if a user calledspawn_model
several times on the same entity with the same source and avoids unnecessary work.Marker components for state
Marker components are not fully gone, when a model spawning is requested a component with its
Promise
will be added to the entity.rmf_site/rmf_site_editor/src/site/model.rs
Lines 318 to 320 in 9bde074
This component can be used in queries to know whether any models are still pending spawning, it is currently used in the SDF exporter to trigger saving when all models either finished or failed loading. When the following query is empty we know that no models are currently being loaded. This could potentially be removed if we made site loading a workflow which itself will only complete when all its models finished loading, however I left this out of this PR to avoid blowing up the size of this refactor.
rmf_site/rmf_site_editor/src/site/sdf_exporter.rs
Line 49 in 9bde074
Furthermore, a marker component could be added (I just removed it, check #238 (comment)) when the workflow fails to load a model:
rmf_site/rmf_site_editor/src/site/model.rs
Lines 322 to 324 in 9bde074
This component is currently only used to detect which models failed loading and should be retried when a new Gazebo app API key is set:
rmf_site/rmf_site_editor/src/site/fuel_cache.rs
Lines 127 to 131 in 9bde074
But it could also be used, for example, to generate an export log when a site is exported to SDF (for example, reporting to the user that a certain set of models couldn't be loaded and hence might be missing from the world).