Skip to content

Fix bin_packing.py and Refactor with Wrapper APIs#5839

Merged
kellyguo11 merged 11 commits into
isaac-sim:developfrom
YizeWang:yizew/fix-demo-scripts
Jun 1, 2026
Merged

Fix bin_packing.py and Refactor with Wrapper APIs#5839
kellyguo11 merged 11 commits into
isaac-sim:developfrom
YizeWang:yizew/fix-demo-scripts

Conversation

@YizeWang
Copy link
Copy Markdown

@YizeWang YizeWang commented May 28, 2026

Description

This PR updates the scripts/demos/bin_packing.py demo to use the current RigidObjectCollection body pose and velocity APIs instead of manipulating flat PhysX root-view tensors directly.

The demo now keeps body poses and body velocities in separate env-major buffers, avoiding the deprecated combined state pattern. It also switches mass updates to the collection-level set_masses_index() API and uses body_link_pos_w, body_link_pose_w, and body_com_vel_w data accessors for out-of-bounds recovery.

No new dependencies are required.

Fixes bin_packing.py.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Documentation update

Screenshots

bin_packing_10s

Testing

  • ./isaaclab.sh -p scripts/demos/bin_packing.py --num_envs 32
  • ./isaaclab.sh -f

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with ./isaaclab.sh -f
  • My changes generate no new warnings
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the changelog and the corresponding version in the extension's config/extension.toml file
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

@YizeWang YizeWang requested a review from ooctipus as a code owner May 28, 2026 15:18
@github-actions github-actions Bot added bug Something isn't working isaac-lab Related to Isaac Lab team labels May 28, 2026
Copy link
Copy Markdown

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Choose a reason for hiding this comment

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

Code Review Summary

Thank you for fixing these demo scripts! The changes address API compatibility issues with the underlying Warp library and RSL-RL configuration handling.

Analysis

Overall Assessment: ✅ The changes look correct and are necessary to maintain demo script functionality.

1. quadcopter.py

  • Change: Wrapping get_masses() result with wp.to_torch() conversion
  • Verdict: ✅ Correct fix for API change where get_masses() now returns a Warp array

2. h1_locomotion.py

  • Change: Adding handle_deprecated_rsl_rl_cfg() to handle RSL-RL config compatibility
  • Verdict: ✅ Good practice for maintaining backward compatibility with RSL-RL library updates

3. bin_packing.py

  • Changes:
    • num_objectsnum_bodies (API rename)
    • object_pos_wbody_link_pos_w.torch
    • Added reshape_data_to_view_3d() helper for Warp conversion
    • Multiple torch-to-warp conversions for set_transforms, set_velocities, set_masses, set_disable_gravities
  • Observations:
    • The helper function pattern is clean and improves readability
    • The .contiguous() calls are necessary for Warp interop

Minor Suggestions (non-blocking)

  1. Consider type hints in the new reshape_data_to_view_3d() function - the function signature has type annotations, which is great!

  2. Docstring clarity: The docstring mentions "body-major view order" - this is clear to those familiar with the codebase, but a brief example of the shape transformation could help future readers.

Checklist Reminder

The PR checklist shows several unchecked items. Please verify:

  • Pre-commit checks run (./isaaclab.sh --format)
  • No new warnings generated
  • Changelog updated if required

Verdict: The technical changes are sound. Once the checklist items are verified, this looks good to merge. 👍


Update (ab06fd7)

Reviewed incremental changes from d974c6b6ab06fd77:

bin_packing.py

  • Change: Fixed groceries_mask_helper tensor shape to match root_view ordering (body_0/env_0..env_N pattern)
  • Before: torch.arange(...) % num_objects with view(num_envs, -1)
  • After: torch.arange(num_objects).view(num_objects, 1) with proper broadcasting
  • Verdict: ✅ Correct fix - aligns mask construction with the actual data layout

quadcopter.py

  • Change: Replaced wp.to_torch(robot.root_view.get_masses()) with robot.data.body_mass.torch
  • Also: Removed unused import warp as wp
  • Verdict: ✅ Cleaner approach - uses the existing .torch property accessor instead of manual conversion, and removes now-unused import

Summary: Good incremental improvements! The bin_packing fix properly aligns the mask tensor dimensions with the root_view ordering, and the quadcopter change is a cleaner API usage pattern. Both changes are correct. 👍


Update (e4b6b73)

Reviewed incremental changes from ab06fd77e4b6b734:

bin_packing.py

  • Removed redundant .contiguous() calls on already-sliced Warp arrays in set_transforms and set_velocities
  • Added explicit .to(torch.uint8) cast before Warp conversion in set_disable_gravities

Verdict: ✅ Minor cleanup - the explicit dtype cast ensures proper type compatibility with the Warp API. LGTM. 👍


Update (8250949)

Reviewed incremental changes from e4b6b7348250949a:

bin_packing.py — Major API Migration

The script now migrates away from the root_view API entirely:

  • reshape_data_to_view → New reshape_data_to_view_3d() helper wrapping Warp conversion. ✅
  • root_view.set_transforms/set_velocitieswrite_body_link_pose_to_sim_index / write_body_com_velocity_to_sim_index. ✅
  • root_view.set_massesset_masses_index with shape (num_instances, num_objects). ✅
  • root_view.set_disable_gravities → Removed entirely. ✅
  • object_pos_wbody_link_pos_w.torch. ✅
  • Out-of-bounds reset now reads current state before patching stray objects back. ✅

Previous Concerns Status

All previous inline issues (.contiguous() on Warp arrays, uint8 casting for set_disable_gravities) are now moot — those root_view code paths have been completely replaced with new higher-level APIs.

New Issues

None identified. The Warp interop in reshape_data_to_view_3d correctly calls .contiguous() on the torch tensor before wp.from_torch() (not on a Warp array). The new API usage is consistent with the RigidObjectCollection interface.

Verdict: LGTM 👍


Update (ca616ab): No substantive changes to bin_packing.py since last review (8250949a). The new HEAD incorporates a base-branch merge (Cartpole preset consolidation) but the PR's own file is byte-identical. Previous assessment stands: LGTM 👍

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 28, 2026

Greptile Summary

This PR updates three demo scripts to adapt to a breaking API change in Isaac Lab where PhysX view methods now accept and return Warp arrays instead of PyTorch tensors. The H1 locomotion script also adds a compatibility shim for a newer version of rsl-rl.

  • bin_packing.py: Replaces deprecated reshape_data_to_view, num_objects, and object_pos_w with their current equivalents, and converts torch tensors to warp arrays before calling root_view methods. Two runtime bugs are introduced: view_states_wp[:, :7].contiguous() will raise AttributeError (warp arrays have no .contiguous()), and passing a torch.bool tensor to wp.from_torch(dtype=wp.uint8) will raise a dtype mismatch error.
  • quadcopter.py: Wraps get_masses() output with wp.to_torch()[0].sum() to handle the new warp-array return type.
  • h1_locomotion.py: Calls handle_deprecated_rsl_rl_cfg with the installed rsl-rl-lib version to maintain forward compatibility.

Confidence Score: 3/5

The bin_packing demo will crash on every reset cycle due to two incorrect warp interop calls; the quadcopter and H1 locomotion changes are functionally correct.

The bin_packing.py changes introduce two bugs that trigger on the first physics reset: calling .contiguous() on a warp array slice (no such method exists) and feeding a torch.bool tensor into wp.from_torch with dtype=wp.uint8 (dtype mismatch). Both are on the hot path inside reset_object_collections, which is called every 250 steps and on every out-of-bounds object. The quadcopter mass-sum fix and the rsl-rl compatibility shim in h1_locomotion are straightforward and appear correct.

scripts/demos/bin_packing.py — the warp interop changes around set_transforms/set_velocities and set_disable_gravities need the two fixes before this script will run.

Important Files Changed

Filename Overview
scripts/demos/bin_packing.py Adapts to updated Isaac Lab / PhysX warp-based API: replaces deprecated reshape_data_to_view, num_objects, and object_pos_w usages. Introduces two runtime bugs: .contiguous() called on warp array slices (AttributeError) and a torch.bool to wp.uint8 dtype mismatch in wp.from_torch.
scripts/demos/h1_locomotion.py Adds handle_deprecated_rsl_rl_cfg compatibility shim for newer rsl-rl versions. Hard-coded package name in metadata.version('rsl-rl-lib') may fail if the package is installed under a different name.
scripts/demos/quadcopter.py Adapts get_masses() call to the new warp-returning API by wrapping with wp.to_torch()[0].sum(); correct for single-robot demo use case.
CONTRIBUTORS.md Adds author Yize Wang in alphabetical order. No issues.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[torch.Tensor] -->|wp.from_torch| B[wp.array]
    B -->|slice view| C[wp.array view]
    C -->|".contiguous() CRASH"| D[AttributeError]
    C -->|pass directly| E[root_view.set_transforms OK]
    F[torch.bool tensor] -->|"wp.from_torch uint8 ERROR"| G[dtype mismatch]
    F -->|".to uint8 first"| H[wp.from_torch dtype=wp.uint8]
    H --> I[root_view.set_disable_gravities OK]
    J[get_masses returns wp.array] -->|wp.to_torch| K[torch.Tensor 2D]
    K -->|index 0 and sum| L[scalar robot_mass]
Loading

Reviews (1): Last reviewed commit: "Fix bin_packing.py" | Re-trigger Greptile

Comment thread scripts/demos/bin_packing.py Outdated
Comment thread scripts/demos/bin_packing.py Outdated
Comment thread scripts/demos/h1_locomotion.py
Comment thread scripts/demos/bin_packing.py Outdated
active_spawn_poses = groceries.reshape_data_to_view(active_spawn_poses)
cached_spawn_poses = groceries.reshape_data_to_view(cached_spawn_poses)
spawn_w = groceries.reshape_data_to_view(default_state_w).clone()
active_spawn_poses = reshape_data_to_view_3d(groceries, active_spawn_poses, 7, device)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

reshape_data_to_view_3d - is this an API that would still make sense as part of RigidObjectCollection? the previous reshape_data_to_view seems to be part of the collection class. +@AntoineRichard

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I agree it should work

Comment thread scripts/demos/bin_packing.py Outdated
random_masses = torch.rand(groceries.num_instances * num_objects, device=device) * 0.2 + 0.2
groceries.root_view.set_masses(random_masses.cpu(), view_indices.cpu())
groceries.root_view.set_disable_gravities((~groceries_mask).cpu(), indices=view_indices.cpu())
random_masses_wp = wp.from_torch(random_masses.cpu().contiguous(), dtype=wp.float32)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

are all the .contiguous() calls necessary? do we know if they impact performance?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

They should not be needed anymore

Comment thread scripts/demos/bin_packing.py Outdated
view_states_wp = wp.from_torch(view_states.contiguous(), dtype=wp.float32)
view_ids_wp = wp.from_torch(view_ids.contiguous().to(dtype=torch.int32), dtype=wp.int32)

rigid_object_collection.root_view.set_transforms(view_states_wp[:, :7], indices=view_ids_wp)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if we switch from using the root_view directly to using APIs from RigidObjectCollection to set transforms like write_body_link_pose_to_sim_index(), would we be able to avoid a lot of the torch/warp interop?

Comment thread scripts/demos/bin_packing.py Outdated
Comment on lines +145 to +151
def reshape_data_to_view_3d(
rigid_object_collection: RigidObjectCollection, data: torch.Tensor, data_dim: int, device: str
) -> torch.Tensor:
"""Reshape env-major ``(num_envs, num_bodies, data_dim)`` data to body-major view order."""

data_wp = wp.from_torch(data.contiguous(), dtype=wp.float32)
return wp.to_torch(rigid_object_collection.reshape_data_to_view_3d(data_wp, data_dim, device=device))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This should not be needed

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

reshape_data_to_view_3d requires data to be wp.array, which is actually torch.Tensor at the call locations.

Comment thread scripts/demos/bin_packing.py Outdated
Comment on lines +199 to +203
view_states[view_ids, :7] = torch.concat((positions, orientations), dim=-1)
view_states[view_ids, 7:] = new_velocities

rigid_object_collection.root_view.set_transforms(view_states[:, :7], indices=view_ids)
rigid_object_collection.root_view.set_velocities(view_states[:, 7:], indices=view_ids)
view_states_wp = wp.from_torch(view_states.contiguous(), dtype=wp.float32)
view_ids_wp = wp.from_torch(view_ids.contiguous().to(dtype=torch.int32), dtype=wp.int32)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do not rely on states, this is outdated

Comment thread scripts/demos/bin_packing.py Outdated
active_spawn_poses = groceries.reshape_data_to_view(active_spawn_poses)
cached_spawn_poses = groceries.reshape_data_to_view(cached_spawn_poses)
spawn_w = groceries.reshape_data_to_view(default_state_w).clone()
active_spawn_poses = reshape_data_to_view_3d(groceries, active_spawn_poses, 7, device)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I agree it should work

Comment thread scripts/demos/bin_packing.py Outdated
random_masses = torch.rand(groceries.num_instances * num_objects, device=device) * 0.2 + 0.2
groceries.root_view.set_masses(random_masses.cpu(), view_indices.cpu())
groceries.root_view.set_disable_gravities((~groceries_mask).cpu(), indices=view_indices.cpu())
random_masses_wp = wp.from_torch(random_masses.cpu().contiguous(), dtype=wp.float32)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

They should not be needed anymore

Comment thread scripts/demos/bin_packing.py Outdated
random_masses = torch.rand(groceries.num_instances * num_objects, device=device) * 0.2 + 0.2
groceries.root_view.set_masses(random_masses.cpu(), view_indices.cpu())
groceries.root_view.set_disable_gravities((~groceries_mask).cpu(), indices=view_indices.cpu())
random_masses_wp = wp.from_torch(random_masses.cpu().contiguous(), dtype=wp.float32)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You shouldn't need to convert to warp

Copy link
Copy Markdown
Author

@YizeWang YizeWang May 29, 2026

Choose a reason for hiding this comment

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

Yes, I found set_masses_index() instead, which takes in torch.Tensor.

Comment thread scripts/demos/bin_packing.py Outdated
Comment on lines +322 to +323
view_indices_cpu_wp = wp.from_torch(view_indices.cpu().contiguous().to(torch.int32), dtype=wp.int32)
groceries.root_view.set_masses(random_masses_wp, view_indices_cpu_wp)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We have a built in method to set the mass

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, I found set_masses_index() instead. However, I did not find a built-in method for set_disable_gravities. Is there one?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No there is none, we don't provide wrappers for everything.

Comment thread scripts/demos/bin_packing.py Outdated
Comment on lines +317 to +335
xy = groceries.reshape_data_to_view(groceries.data.object_pos_w - scene.env_origins.unsqueeze(1))[:, :2]
body_pos_b = groceries.data.body_link_pos_w.torch - scene.env_origins.unsqueeze(1)
xy = reshape_data_to_view_3d(groceries, body_pos_b, 3, device)[:, :2]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Consider using the built on method

@isaaclab-review-bot
Copy link
Copy Markdown

🤖 Update Review (121478a)

Reviewed new commit 121478a41f39d7a47f45f70a8b12695fc813e79a.

Changes in scripts/demos/bin_packing.py

Added .contiguous() calls to warp array slices:

rigid_object_collection.root_view.set_transforms(view_states_wp[:, :7].contiguous(), indices=view_ids_wp)
rigid_object_collection.root_view.set_velocities(view_states_wp[:, 7:].contiguous(), indices=view_ids_wp)

Assessment

Good fix. Warp requires contiguous memory layouts for GPU operations, and array slices in PyTorch/numpy may not be contiguous. This prevents potential runtime errors or undefined behavior when passing sliced tensors to warp functions.

LGTM for this update.

@isaaclab-review-bot
Copy link
Copy Markdown

Update (c7665b5): Reviewed incremental changes since 121478a.

Summary of Changes

scripts/demos/bin_packing.py - Significant refactoring for updated RigidObjectCollection API:

  • Added warp import and new reshape_data_to_view_3d() helper function using warp for tensor reshaping
  • Changed from num_objects to num_bodies property
  • Replaced deprecated root_view.set_transforms/set_velocities with write_body_link_pose_to_sim_index/write_body_com_velocity_to_sim_index
  • Updated data access patterns from reshape_data_to_view to new warp-based helper
  • Changed root_view.set_masses and set_disable_gravities to set_masses_index
  • Updated body position/velocity data access to use new body_link_pos_w, body_link_pose_w, body_com_vel_w patterns

scripts/demos/h1_locomotion.py - Compatibility fix for RSL-RL:

  • Added handle_deprecated_rsl_rl_cfg call to handle deprecated RSL-RL config parameters

scripts/demos/quadcopter.py - Simple API migration:

  • Changed robot.root_view.get_masses().sum() to robot.data.body_mass.torch[0].sum()

CONTRIBUTORS.md - Added contributor Yize Wang

Assessment

These changes properly migrate the demo scripts to use the updated RigidObjectCollection and ArticulationView APIs. The refactoring looks correct and maintains the intended functionality while adapting to the new data access patterns.

@YizeWang YizeWang force-pushed the yizew/fix-demo-scripts branch from c7665b5 to 8250949 Compare May 31, 2026 09:32
Copy link
Copy Markdown

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Choose a reason for hiding this comment

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

Re-review After Recent Updates

Thanks for the updates addressing reviewer feedback! The recent commits show good progress:

✅ Improvements Made

  1. set_masses_index() API - Now using the wrapper API instead of root_view.set_masses()
  2. Removed set_disable_gravities() - Simplified the reset logic
  3. Wrapper APIs for state writes - Using write_body_link_pose_to_sim_index() and write_body_com_velocity_to_sim_index() instead of direct root_view manipulation

🔍 Open Discussion Points

Based on @AntoineRichard's feedback, there's still discussion around:

  1. Warp conversions - The reshape_data_to_view_3d helper still uses wp.from_torch() / wp.to_torch(). @YizeWang mentioned this is required because reshape_data_to_view_3d expects wp.array. Could there be a torch-native path through the API?

  2. .contiguous() calls - The helper still calls .contiguous() on the torch tensor before warp conversion. Is this strictly necessary, or can it be avoided if the underlying API handles non-contiguous tensors?

These seem like API design questions worth clarifying with the maintainers to ensure the demo showcases best practices.

📝 Minor Observation

The PR description mentions fixes to quadcopter.py and h1_locomotion.py, but the current diff only shows changes to bin_packing.py. Were those changes moved to a separate PR, or is the description outdated?


Overall the direction looks good - just want to ensure the warp conversion question is resolved before merge.


Update (ca616ab): PR has been rebased to a single commit focusing on bin_packing.py. PR title now correctly reflects this as "Fix bin_packing.py". My earlier observation about missing quadcopter.py/h1_locomotion.py changes is now moot - the scope is clearer. The inline comments on h1_locomotion.py from earlier reviews are no longer applicable since that file is not part of this PR.

The warp conversion discussion points remain open but are API design questions for maintainers, not blockers. The code correctly uses the wrapper APIs as intended. ✅


Update (f6dc1d2): All previous open discussion points are now fully resolved. This commit removes Warp entirely from bin_packing.py:

  • Warp conversions removedreshape_data_to_view_3d helper deleted, import warp as wp removed. All reshape logic is now pure PyTorch (.view()).
  • .contiguous() concern moot — no Warp interop means no need for contiguous torch tensors before conversion.
  • Tensor layout simplified — data stays in env-major format (num_envs, num_objects, ...) throughout, with .view(-1, D) for flat indexing where needed.

No new issues found. The torch-native approach is cleaner and eliminates the Warp dependency entirely. LGTM 👍


Update (0c26464): Minor refinements, no new issues.

  • Docstring fixstatesview_states in reset_object_collections docstring to match the actual parameter name.
  • groceries_mask_helper refactored — Now uses arange(num_objects * num_envs) % num_objects with explicit .view(num_envs, -1) instead of implicit broadcasting. Functionally equivalent, slightly more explicit about the per-env structure.

No bugs or regressions introduced. LGTM 👍


Update (5ccd1b2): Minor code cleanup, one small nit.

  • Inlined out_bound_mask — The intermediate variable was merged into the torch.nonzero() call. Slightly more compact, functionally identical.
  • Variable renamecurrent_state_wstates_w. Cleaner naming.
  • 📝 Misplaced comment — The # Increment counter comment ended up on the reset_object_collections line instead of on the count += 1 line. Minor nit, not a blocker.

No bugs or regressions. Still LGTM 👍


Update (d0a0c11): Major refactor separating poses and velocities into distinct tensors. Good design improvement, but introduces a typo bug:

  • 🔴 Bug: Line 202 write_body_com_velocity_to_sim_index(body_velocities=vel) uses vel instead of vels (the parameter name). This will raise NameError at runtime.
  • Previous misplaced comment nit — resolved (comment is now correctly placed above count += 1).
  • Docstrings — properly updated to reflect new poses/vels signature.

The split from a single (N, 13) state tensor to separate (num_envs, num_bodies, 7) poses + (num_envs, num_bodies, 6) vels is cleaner and type-safer. Just needs the typo fix (velvels) to work.


Update (197e2dd): All previous concerns resolved. No new issues.

  • velvels typo fixed — The NameError bug from the previous review is resolved.
  • Naming refactoredview_states split into separate poses and vels parameters with proper docstrings reflecting env-major shapes (num_envs, num_bodies, 7) / (num_envs, num_bodies, 6).
  • Comments cleaned up — Inline comments and docstrings are accurate and consistent.

The code is clean, the wrapper API usage is correct, and the refactoring properly avoids the old env-major → body-major conversion overhead. LGTM 👍

@YizeWang YizeWang force-pushed the yizew/fix-demo-scripts branch from 8250949 to ca616ab Compare June 1, 2026 05:59
@YizeWang YizeWang changed the title Fix Demo Scripts Fix bin_packing.py Jun 1, 2026
# Vary the mass and gravity settings so cached objects stay parked.
random_masses = torch.rand(groceries.num_instances * num_objects, device=device) * 0.2 + 0.2
groceries.root_view.set_masses(random_masses.cpu(), view_indices.cpu())
groceries.root_view.set_disable_gravities((~groceries_mask).cpu(), indices=view_indices.cpu())
Copy link
Copy Markdown
Author

@YizeWang YizeWang Jun 1, 2026

Choose a reason for hiding this comment

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

set_disable_gravities does not have a wrapper API yet. This line can be removed without an end-to-end behavioral impacts because the position and velocity will be reset in the out-of-bounds process. I argue we should avoid this low-level data operation to make the extension to other backends cleanly.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It's ok to keep it this way

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for confirming this!

Comment thread scripts/demos/bin_packing.py Outdated
out_bound = torch.nonzero((~((xy >= bounds_xy[0]) & (xy <= bounds_xy[1])).all(dim=-1)).view(-1)).flatten()
if out_bound.numel():
# Teleport stray objects back into the active stack to keep the bin tidy.
reset_object_collections(scene, "groceries", spawn_w, out_bound)
Copy link
Copy Markdown
Author

@YizeWang YizeWang Jun 1, 2026

Choose a reason for hiding this comment

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

It could be an issue in the original implementation - passing spawn_w into reset_object_collections, because spawn_w is only updated at every other 250 frame, not frame-by-frame. It used to reset a wrong object!

Comment thread scripts/demos/bin_packing.py Outdated
rigid_object_collection.root_view.set_transforms(view_states[:, :7], indices=view_ids)
rigid_object_collection.root_view.set_velocities(view_states[:, 7:], indices=view_ids)
rigid_object_collection.write_body_link_pose_to_sim_index(body_poses=poses)
rigid_object_collection.write_body_com_velocity_to_sim_index(body_velocities=vel)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 Bug (d0a0c11): Typo — vel should be vels (the parameter name). This will raise NameError at runtime.

Suggested change
rigid_object_collection.write_body_com_velocity_to_sim_index(body_velocities=vel)
rigid_object_collection.write_body_com_velocity_to_sim_index(body_velocities=vels)

view_ids: torch.Tensor,
noise: bool = False,
) -> None:
"""Apply states to a subset of a collection, with optional noise.
Copy link
Copy Markdown
Author

@YizeWang YizeWang Jun 1, 2026

Choose a reason for hiding this comment

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

According to @AntoineRichard's suggestion, we should not deprecate states because they are not contiguous anymore in the latest IsaacLab. We want to instruct users to modify positions and velocities separately instead of combining them as states.

Comment thread scripts/demos/bin_packing.py Outdated
rigid_object_collection.root_view.set_transforms(view_states[:, :7], indices=view_ids)
rigid_object_collection.root_view.set_velocities(view_states[:, 7:], indices=view_ids)
rigid_object_collection.write_body_link_pose_to_sim_index(body_poses=poses)
rigid_object_collection.write_body_com_velocity_to_sim_index(body_velocities=vel)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 Typo bug: vel should be vels (the function parameter). This will raise NameError at runtime.

@YizeWang YizeWang changed the title Fix bin_packing.py Fix bin_packing.py and Refactor with Wrapper APIs Jun 1, 2026
Copy link
Copy Markdown
Collaborator

@AntoineRichard AntoineRichard left a comment

Choose a reason for hiding this comment

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

LGTM thanks for the changes. Still would be good to track the issue with reshape_data_to_view only supporting warp.

Yize Wang added 8 commits June 1, 2026 21:00
Signed-off-by: Yize Wang <yizew@nvidia.com>
Signed-off-by: Yize Wang <yizew@nvidia.com>
Signed-off-by: Yize Wang <yizew@nvidia.com>
Signed-off-by: Yize Wang <yizew@nvidia.com>
Signed-off-by: Yize Wang <yizew@nvidia.com>
Signed-off-by: Yize Wang <yizew@nvidia.com>
Signed-off-by: Yize Wang <yizew@nvidia.com>
Signed-off-by: Yize Wang <yizew@nvidia.com>
Yize Wang added 3 commits June 1, 2026 21:00
Signed-off-by: Yize Wang <yizew@nvidia.com>
Signed-off-by: Yize Wang <yizew@nvidia.com>
Signed-off-by: Yize Wang <yizew@nvidia.com>
@YizeWang YizeWang force-pushed the yizew/fix-demo-scripts branch from 45274bd to 197e2dd Compare June 1, 2026 13:00
@kellyguo11 kellyguo11 merged commit eedbc93 into isaac-sim:develop Jun 1, 2026
37 checks passed
@YizeWang YizeWang deleted the yizew/fix-demo-scripts branch June 2, 2026 01:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants