def __init__(self, handle: Object): super(Human, self).__init__() self.handle = handle handle.value = 0 children = handle.get_objects_in_tree(handle) for child in children: name = child.get_name() if 'Bill_goalPosCylinder' in name: self.dummy_handle = child.get_parent()
def add(self, obj: Object, ignore_collisions: bool = False, min_rotation: tuple = (0.0, 0.0, -3.14), max_rotation: tuple = (0.0, 0.0, 3.14), min_distance: float = 0.01) -> int: """Returns true if can add and adds it rotation_limits: how mush we allow it to rotate from its original position""" # Rotate the bounding box randomly if obj.is_model(): bb = obj.get_model_bounding_box() else: bb = obj.get_bounding_box() obj_bbox = BoundingBox(*bb) rotation = np.random.uniform(list(min_rotation), list(max_rotation)) obj_bbox = obj_bbox.rotate(rotation) if not obj_bbox.within_boundary(self._boundary_bbox, self._is_plane): return -1 new_pos = self._get_position_within_boundary(obj, obj_bbox) obj.set_position(new_pos, self._boundary) obj.rotate(list(rotation)) new_pos = np.array(new_pos) if not ignore_collisions: for contained_obj in self._contained_objects: # Check for collision between each child for cont_ob in contained_obj.get_objects_in_tree( exclude_base=False): for placing_ob in obj.get_objects_in_tree( exclude_base=False): if placing_ob.check_collision(cont_ob): return -2 dist = np.linalg.norm( new_pos - contained_obj.get_position(self._boundary)) if dist < min_distance: return -3 self._contained_objects.append(obj) return 1
def __init__(self, handle: Object): super(Human, self).__init__() self.handle = handle handle.value = 0 children = handle.get_objects_in_tree(handle) for child in children: name = child.get_name() if 'Bill_goalPosCylinder' in name: self.dummy_handle = child.get_parent() # self.dummy_handle._set_property(prop_type: int, value: bool) -> None: pos = self.handle.get_position() self.ss1 = Shape.create(type=PrimitiveShape.CONE, color=[1, 0, 0], size=[0.75, 0.75, 0.0015], position=[pos[0], pos[1], 0], orientation=[3.14, 0, 3.14]) self.ss1.set_color([1, 0, 0]) self.ss1.set_position([pos[0], pos[1], 0]) self.ss1.set_orientation([3.14, 0, 3.14]) self.ss1.set_dynamic(False) self.ss1.set_renderable(False) self.set_model(True)