-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Fixed usd_replicate() authoring environment grid positions on nested prims (e.g. cameras), overwriting their local transforms.
#6071
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| Fixed | ||
| ^^^^^ | ||
|
|
||
| * Fixed :func:`~isaaclab.cloner.usd.usd_replicate` authoring environment grid | ||
| positions on nested replicated prims (e.g. cameras), overwriting their local | ||
| transforms. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,7 @@ | |
| replicate, | ||
| resolve_clone_plan_source, | ||
| sequential, | ||
| split_clone_template, | ||
| usd_replicate, | ||
| ) | ||
| from isaaclab.sim import build_simulation_context | ||
|
|
@@ -56,6 +57,14 @@ def _drain_replication_queue(): | |
| REPLICATION_QUEUE.clear() | ||
|
|
||
|
|
||
| def test_split_clone_template(): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't robust enough, we could make this more bullet proof by allowing only one d = '/world/env_{}/Camera_{}'
d.partition("{}")
('/world/env_', '{}', '/Camera_{}')
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ooctipus for vis Do we need to consider a clone template like
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wasn't suggesting to support, I was suggesting to reject.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it could probably be an ill-formed template in my opinion, but I'd let Octi comment on this.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think lets reserve {} only for world id,
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I can do this in my second pr. I want to let this pr run thru CI sooner.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a small validation (e.g. destination.count("{}") == 1) in ClonePlan construction or UsdReplicateContext.queue would catch this earlier |
||
| """Split clone destination templates around their clone slot.""" | ||
| assert split_clone_template("/World/envs/env_{}/Robot") == ("/World/envs/env_", "/Robot") | ||
| assert split_clone_template("/World/scenes/{}/") == ("/World/scenes/", "") | ||
| with pytest.raises(ValueError, match="must contain"): | ||
| split_clone_template("/World/envs/env_0/Robot") | ||
|
|
||
|
|
||
| def test_usd_replicate_with_positions_and_mask(sim): | ||
| """Replicate sources to selected envs and author translate ops from positions.""" | ||
| # Prepare sources under /World/template | ||
|
|
@@ -120,6 +129,48 @@ def test_usd_replicate_context_queue_and_replicate(sim): | |
| assert stage.GetPrimAtPath("/World/envs/env_1/A").IsValid() | ||
|
|
||
|
|
||
| def test_usd_replicate_nested_asset_preserves_local_offset_with_positions(sim): | ||
| """Grid positions are authored on env roots but not on nested replicated assets.""" | ||
| camera_offset = (0.57, -0.8, 0.5) | ||
| num_envs = 2 | ||
| env_ids = torch.arange(num_envs, dtype=torch.long) | ||
| positions, _ = grid_transforms(num_envs, 3.0, device=sim.cfg.device) | ||
|
|
||
| sim_utils.create_prim("/World/envs", "Xform") | ||
| sim_utils.create_prim("/World/envs/env_0", "Xform") | ||
| sim_utils.create_prim("/World/envs/env_0/Camera", "Camera", translation=camera_offset) | ||
|
|
||
| stage = sim_utils.get_current_stage() | ||
| usd_replicate( | ||
| stage, | ||
| sources=["/World/envs/env_0"], | ||
| destinations=["/World/envs/env_{}"], | ||
| env_ids=env_ids, | ||
| positions=positions, | ||
| ) | ||
| usd_replicate( | ||
| stage, | ||
| sources=["/World/envs/env_0/Camera"], | ||
| destinations=["/World/envs/env_{}/Camera"], | ||
| env_ids=env_ids, | ||
| positions=positions, | ||
| ) | ||
|
|
||
| for env_idx in range(num_envs): | ||
| env_prim = stage.GetPrimAtPath(f"/World/envs/env_{env_idx}") | ||
| assert env_prim.IsValid() | ||
| env_translate = env_prim.GetAttribute("xformOp:translate").Get() | ||
| assert env_translate is not None | ||
| expected_env_pos = positions[env_idx].tolist() | ||
| assert (env_translate[0], env_translate[1], env_translate[2]) == pytest.approx(expected_env_pos) | ||
|
|
||
| camera_prim = stage.GetPrimAtPath(f"/World/envs/env_{env_idx}/Camera") | ||
| assert camera_prim.IsValid() | ||
| camera_translate = camera_prim.GetAttribute("xformOp:translate").Get() | ||
| assert camera_translate is not None | ||
| assert (camera_translate[0], camera_translate[1], camera_translate[2]) == pytest.approx(camera_offset) | ||
|
|
||
|
|
||
| def test_disabled_fabric_change_notifies_noops_when_usdrt_unavailable(monkeypatch): | ||
| """Fabric notice suspension no-ops when Carbonite bindings exist but ``usdrt`` does not.""" | ||
| import builtins | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.