Skip to content

Conversation

kaikwan
Copy link
Collaborator

@kaikwan 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
@Copilot Copilot AI review requested due to automatic review settings July 13, 2025 20:54
Copilot

This comment was marked as outdated.

@kaikwan kaikwan requested a review from Copilot July 15, 2025 21:35
Copy link
Contributor

@Copilot Copilot AI left a 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()

Comment on lines +197 to +199
# Check if all objects in each tote are zero
empty_totes = torch.all(self.tote_to_obj[env_ids] == 0, dim=2)

Copy link
Preview

Copilot AI Jul 15, 2025

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.

Suggested change
# 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.

Comment on lines 122 to 127
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
Copy link
Preview

Copilot AI Jul 15, 2025

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.

Suggested change
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.

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]
Copy link
Preview

Copilot AI Jul 15, 2025

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').

Suggested change
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.

Comment on lines 149 to 154
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
Copy link
Preview

Copilot AI Jul 15, 2025

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').

Suggested change
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.

Comment on lines 231 to 233
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)
Copy link
Preview

Copilot AI Jul 15, 2025

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').

Suggested change
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.

@kaikwan kaikwan merged commit 71933b8 into main Jul 22, 2025
@kaikwan kaikwan deleted the henri/baselines branch July 22, 2025 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant