def transfer_to_assembly(self): from assembly_information_model.assembly import Element, Assembly assembly = Assembly() for my_layer in self.timberboards: for my_board in my_layer: # box_update only precaution my_board.box_update() assembly_board = Element.from_box(my_board.box) assembly.add_element(assembly_board) return assembly
def transfer_to_assembly(): from assembly_information_model.assembly import Element, Assembly assembly = Assembly() assembly.__init_subclass__() assembly.something = 5 for my_layer in self.timberboards: for my_board in my_layer: # box_update only precaution my_board.box_update() assembly_board = Element.from_box(my_board.box) assembly_board.something = 5 assembly.add_element(assembly_board, somethinsdg=12) return assembly
element0 = Element.from_data(data['element0']) # picking frame picking_frame = Frame.from_data(data['picking_frame']) # little tolerance to not 'crash' into collision objects tolerance_vector = Vector.from_data(data['tolerance_vector']) safelevel_vector = Vector.from_data(data['safelevel_vector']) # define target frame target_frame = Frame((0.325, 0.400, 0.006), (0.000, 1.000, 0.000), (-1.000, 0.000, 0.000)) target_frame.point += tolerance_vector # create Assembly with element at target_frame assembly = Assembly() T = Transformation.from_frame_to_frame(element0.frame, target_frame) assembly.add_element(element0.transformed(T)) # Bring the element's mesh into the robot's tool0 frame element_tool0 = element0.copy() T = Transformation.from_frame_to_frame(element_tool0._tool_frame, tool.frame) element_tool0.transform(T) # define picking_configuration picking_configuration = Configuration.from_data(data['picking_configuration']) # define picking frame picking_frame = Frame.from_data(data['picking_frame']) picking_frame.point += tolerance_vector # define safelevel frames 'above' the picking- and target frames safelevel_picking_frame = picking_frame.copy()
bricks_in_course = BRICKS_PER_COURSE + (1 if half_brick_ends else 0) for j in range(bricks_in_course): first = j == 0 last = j == bricks_in_course - 1 is_half_brick = (first or last) and half_brick_ends if is_half_brick: if last: T = Translation([dx - width / 2, 0, dy]) else: T = Translation([dx - width / 2 - gap / 2, 0, dy]) e = halfbrick.transformed(T) dx += width + gap / 2 else: T = Translation([dx, 0, dy]) e = brick.transformed(T) dx += length #R = Rotation.from_axis_and_angle([0,0,1], 0.1*j, point=e.gripping_frame.point) #e.transform(R) assembly.add_element(e) dx += gap assembly.transform(Translation([length / 2, 0, 0])) # 6. Save assembly to json assembly.to_json(PATH_TO)
cft = cf.transformed(R * T) # transforms the origin plane if i % 2 == 0: R = Rotation.from_axis_and_angle(cft.zaxis, math.radians(90), point=cft.point) cft = cft.transformed(R) add = math.sin(i / 5) * 0.015 # print(add) o1 = cft.point + cft.yaxis * (0.075 + add) o2 = cft.point - cft.yaxis * (0.075 + add) f1 = Frame(o1, cft.xaxis, cft.yaxis) f2 = Frame(o2, cft.xaxis, cft.yaxis) T1 = Transformation.from_frame_to_frame(Frame.worldXY(), f1) T2 = Transformation.from_frame_to_frame(Frame.worldXY(), f2) # create new instances of the element # returns a deep copy of the initial element at the new location of the frame new_elem_1 = element0.transformed(T1) new_elem_2 = element0.transformed(T2) assembly.add_element(new_elem_1) assembly.add_element(new_elem_2) assembly.to_json(os.path.join(DATA, "assembly.json"), pretty=True)