-
Notifications
You must be signed in to change notification settings - Fork 0
Add Fan Wang's BPP Agent #10
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
Conversation
kaikwan
commented
Jul 13, 2025
- num_envs = 1 only
- Packing Action Cfg to accept obj bottom left origin placement transforms
- Creating voxel grids from meshes for passing geometry to agent
- num_envs = 1 only - Packing Action Cfg to accept obj bottom left origin placement transforms - Creating voxel grids from meshes for passing geometry to agent
…improve performance
- Make BPP a class - Fix typos
…ogic to ensure indefinite runs
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.
Pull Request Overview
This PR integrates Fan Wang's Bin Packing Problem (BPP) agent based on "Stable bin packing of non-convex 3D objects with a robot manipulator", adding support for voxel-based geometry representation and configurable bottom-left placement origins.
- Integration of Fan Wang's BPP agent with heuristic-based search packing
- Configuration for bottom-left origin placement transforms in packing actions
- Voxel grid creation from mesh geometry for passing to the BPP agent
Reviewed Changes
Copilot reviewed 26 out of 27 changed files in this pull request and generated 5 comments.
Show a summary per file
File | Description |
---|---|
tote_statistics.py | Code formatting improvements (quotes, parentheses, whitespace) |
tote_manager.py | Added voxel support, refactored tote ejection logic, updated animation config |
tote_helpers.py | Import reorganization and function signature formatting |
pack_env_cfg.py | Enabled additional YCB objects and updated object counts |
events.py | Added voxelized geometry computation and mesh properties caching |
joint_pos_env_cfg.py | Added bottom-left placement configuration |
wrappers_cfg.py | Import reorganization |
wrappers.py | Import reorganization |
packing_actions.py | Added bottom-left placement logic with bounding box calculations |
actions_cfg.py | Added place_obj_bottomLeft configuration parameter |
fanwang_bpp_agent.py | New BPP agent implementation |
bpp_utils.py | New utility class for BPP functionality |
Multiple script files | Import statement reorganization |
Comments suppressed due to low confidence (2)
source/tote_consolidation/tote_consolidation/tasks/manager_based/pack/utils/tote_manager.py:61
- The variable name '_tote_assets_state' is inconsistent with Python naming conventions. Consider using 'tote_assets_state' (without leading underscore) since it appears to be accessed from other classes.
self._tote_assets_state = torch.stack([tote.get_world_poses()[0] for tote in self.tote_assets], dim=0)
source/tote_consolidation/tote_consolidation/tasks/manager_based/pack/mdp/events.py:97
- The compute_voxelized_geometry function lacks proper docstring documentation. While it has parameter descriptions, it should include a proper docstring format with Args and Returns sections for consistency with other functions.
points_attr = mesh.GetPointsAttr()
# Check if all objects in each tote are zero | ||
empty_totes = torch.all(self.tote_to_obj[env_ids] == 0, dim=2) | ||
|
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 comment and the following lines (197-211) appear to be duplicated code from earlier in the function. The logic for checking empty totes and creating destination tote masks is repeated unnecessarily.
# Check if all objects in each tote are zero | |
empty_totes = torch.all(self.tote_to_obj[env_ids] == 0, dim=2) |
Copilot uses AI. Check for mistakes.
for point in points_local: | ||
# Ensure indices are rounded properly (floor for point-to-voxel mapping) | ||
voxel_index = torch.floor(point / voxel_size).long() | ||
# Set voxel to 1 if within bounds | ||
if (0 <= voxel_index).all() and (voxel_index < grid_size).all(): | ||
voxel_grid[tuple(voxel_index.tolist())] = 1.0 |
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 loop iterating through all points to set voxel values is inefficient. Consider using vectorized operations with torch operations like torch.floor and boolean indexing to set multiple voxels at once.
for point in points_local: | |
# Ensure indices are rounded properly (floor for point-to-voxel mapping) | |
voxel_index = torch.floor(point / voxel_size).long() | |
# Set voxel to 1 if within bounds | |
if (0 <= voxel_index).all() and (voxel_index < grid_size).all(): | |
voxel_grid[tuple(voxel_index.tolist())] = 1.0 | |
# Compute voxel indices for all points | |
voxel_indices = torch.floor(points_local / voxel_size).long() | |
# Filter points within bounds | |
valid_mask = (voxel_indices >= 0).all(dim=1) & (voxel_indices < grid_size).all(dim=1) | |
valid_indices = voxel_indices[valid_mask] | |
# Update voxel grid for valid points | |
voxel_grid[valid_indices[:, 0], valid_indices[:, 1], valid_indices[:, 2]] = 1.0 |
Copilot uses AI. Check for mistakes.
scripts/fanwang_bpp/bpp_utils.py
Outdated
return self.get_action(env, new_packable_objects, tote_ids) | ||
|
||
t = time.time() | ||
obj_idx = obj_indicies[torch.randint(0, len(obj_indicies), (1,))][0] |
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.
Variable name 'obj_indicies' should be 'obj_indices' (correct spelling of 'indices').
obj_idx = obj_indicies[torch.randint(0, len(obj_indicies), (1,))][0] | |
obj_idx = obj_indices[torch.randint(0, len(obj_indices), (1,))][0] |
Copilot uses AI. Check for mistakes.
scripts/fanwang_bpp/bpp_utils.py
Outdated
def get_action(self, env, obj_indicies, tote_ids): | ||
""" | ||
Get the action for the current step in the packing problem. | ||
|
||
Args: | ||
obj_indicies: Indices of objects to consider |
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.
Parameter name 'obj_indicies' should be 'obj_indices' (correct spelling of 'indices').
def get_action(self, env, obj_indicies, tote_ids): | |
""" | |
Get the action for the current step in the packing problem. | |
Args: | |
obj_indicies: Indices of objects to consider | |
def get_action(self, env, obj_indices, tote_ids): | |
""" | |
Get the action for the current step in the packing problem. | |
Args: | |
obj_indices: Indices of objects to consider |
Copilot uses AI. Check for mistakes.
scripts/fanwang_bpp/bpp_utils.py
Outdated
obj_indicies[env_idx] = [idx for idx in obj_indicies[env_idx] if idx != obj_idx] | ||
|
||
return self.get_action(env, obj_indicies, tote_ids) |
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.
Variable name 'obj_indicies' should be 'obj_indices' (correct spelling of 'indices').
obj_indicies[env_idx] = [idx for idx in obj_indicies[env_idx] if idx != obj_idx] | |
return self.get_action(env, obj_indicies, tote_ids) | |
obj_indices[env_idx] = [idx for idx in obj_indices[env_idx] if idx != obj_idx] | |
return self.get_action(env, obj_indices, tote_ids) |
Copilot uses AI. Check for mistakes.
…hs and filtering based on object IDs
…ckable objects keep getting retried
- Improved `ToteStatistics` to support incremental saving of statistics to a JSON file, including recent ejection data and operation counts.
…on to use filled voxel representations
…nes and improve stats saving logic
…/GCULab into henri/baselines