You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def can_hold_item_with_rotation(self, item, pivot):
"""Evaluate whether one item can be placed into bin with all optional orientations.
Args:
item: any item in item list.
pivot: an (x, y, z) coordinate, the back-lower-left corner of the item will be placed at the pivot.
Returns:
a list containing all optional orientations. If not, return an empty list.
"""
fit = False
valid_item_position = [0, 0, 0]
item.position = pivot
rotation_type_list = []
for i in range(0, len(RotationType.ALL)):
item.rotation_type = i
dimension = item.get_dimension()
if (
pivot[0] + dimension[0] <= self.length and # x-axis
pivot[1] + dimension[1] <= self.width and # y-axis
pivot[2] + dimension[2] <= self.height # z-axis
):
fit = True
for current_item_in_bin in self.items:
if intersect(current_item_in_bin, item):
fit = False
item.position = [0, 0, 0]
break
if fit:
if self.get_total_weight() + item.weight > self.capacity: # estimate whether bin reaches its capacity
fit = False
item.position = [0, 0, 0]
continue
else:
rotation_type_list.append(item.rotation_type)
else:
continue
return rotation_type_list
There is an error in the above function while it is looping through rotations checking for fitment. If a later rotation is found to not fit, either do to intersection or weight, the items position is 0'ed. This resets the item to the origin instead of it's pivot despite previous rotations that do work for the given pivot location. Simply not setting the position to 0,0,0 preserves the pivot location and the algorithm works correctly. There was some thought given to this given the unused valid_item_position variable I suspect.
The text was updated successfully, but these errors were encountered:
There is an error in the above function while it is looping through rotations checking for fitment. If a later rotation is found to not fit, either do to intersection or weight, the items position is 0'ed. This resets the item to the origin instead of it's pivot despite previous rotations that do work for the given pivot location. Simply not setting the position to 0,0,0 preserves the pivot location and the algorithm works correctly. There was some thought given to this given the unused valid_item_position variable I suspect.
The text was updated successfully, but these errors were encountered: