Skip to content

Commit

Permalink
Add package:// sdf files support
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
  • Loading branch information
luca-della-vedova committed Nov 20, 2023
1 parent 4667803 commit 2680725
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
16 changes: 10 additions & 6 deletions rmf_site_editor/src/site/sdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn compute_model_source(path: &str, uri: &str) -> AssetSource {
"".into()
};
}
AssetSource::Local(ref mut p) => {
AssetSource::Local(ref mut p) | AssetSource::Package(ref mut p) => {
let binding = p.clone();
*p = if let Some(stripped) = uri.strip_prefix("model://") {
// Search for a model with the requested name in the same folder as the sdf file
Expand All @@ -93,7 +93,7 @@ fn compute_model_source(path: &str, uri: &str) -> AssetSource {
"".into()
};
}
AssetSource::Bundled(_) | AssetSource::Package(_) | AssetSource::OSMTile { .. } => {
AssetSource::Bundled(_) | AssetSource::OSMTile { .. } => {
warn!("Requested asset source {:?} type not supported for SDFs, might behave unexpectedly", asset_source);
}
}
Expand Down Expand Up @@ -214,8 +214,10 @@ pub fn handle_new_sdf_roots(mut commands: Commands, new_sdfs: Query<(Entity, &Sd
);
match id {
Some(id) => {
commands.entity(id).insert(VisualMeshMarker);
commands.entity(link_id).add_child(id);
commands
.entity(id)
.insert(VisualMeshMarker)
.set_parent(link_id);
}
None => warn!("Found unhandled geometry type {:?}", &visual.geometry),
}
Expand All @@ -231,8 +233,10 @@ pub fn handle_new_sdf_roots(mut commands: Commands, new_sdfs: Query<(Entity, &Sd
);
match id {
Some(id) => {
commands.entity(id).insert(CollisionMeshMarker);
commands.entity(link_id).add_child(id);
commands
.entity(id)
.insert(CollisionMeshMarker)
.set_parent(link_id);
}
None => warn!("Found unhandled geometry type {:?}", &collision.geometry),
}
Expand Down
5 changes: 4 additions & 1 deletion rmf_site_editor/src/workcell/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ impl Plugin for WorkcellEditorPlugin {
update_model_scenes,
update_model_scales,
handle_new_primitive_shapes,
flatten_loaded_models_hierarchy,
update_model_tentative_formats,
replace_name_in_site_components,
handle_create_joint_events,
Expand Down Expand Up @@ -113,6 +112,10 @@ impl Plugin for WorkcellEditorPlugin {
update_transforms_for_changed_poses,
)
.run_if(in_state(AppState::WorkcellEditor)),
)
.add_systems(
PostUpdate,
(flatten_loaded_models_hierarchy,).run_if(in_state(AppState::WorkcellEditor)),
);
}
}

0 comments on commit 2680725

Please sign in to comment.