How to use set_plan method in tappy

Best Python code snippet using tappy_python

main.py

Source:main.py Github

copy

Full Screen

1from multiprocessing.spawn import prepare2import time3import multiprocessing4# from AutocadApi import read_plan,read_beam,write_beam,write_plan,error5from plan_to_beam import read_plan,read_beam,write_beam,write_plan,error, write_result_log6from werkzeug.utils import secure_filename7import os8import plan_to_col9from datetime import datetime10def main_functionV3(beam_filenames,plan_filenames,beam_new_filename,plan_new_filename,big_file ,sml_file,block_layer,task_name,explode):11 start = time.time()12 # task_name = 'task3'13 # 檔案路徑區14 # 跟AutoCAD有關的檔案都要吃絕對路徑15 # plan_filename = "K:/100_Users/EI 202208 Bamboo/BeamQC/task3/XS-PLAN.dwg" # XS-PLAN的路徑16 # beam_filename = "K:/100_Users/EI 202208 Bamboo/BeamQC/task3/XS-BEAM.dwg" # XS-BEAM的路徑17 # plan_new_filename = f"K:/100_Users/EI 202208 Bamboo/BeamQC/task3/{task_name}-XS-PLAN_new.dwg" # XS-PLAN_new的路徑18 # beam_new_filename = f"K:/100_Users/EI 202208 Bamboo/BeamQC/task3/{task_name}-XS-BEAM_new.dwg" # XS-BEAM_new的路徑19 plan_file = './result/beam_plan.txt' # plan.txt的路徑20 beam_file = './result/beam.txt' # beam.txt的路徑21 excel_file = './result/result_log.xlsx' # result_log.xlsx的路徑22 size_layer = 'S-TEXT'23 # big_file = final_filename # 大梁結果24 # sml_file = sb_final_filename # 小梁結果25 date = time.strftime("%Y-%m-%d", time.localtime())26 27 # 在plan裡面自訂圖層28 floor_layer = "S-TITLE" # 樓層字串的圖層29 beam_layer = ["S-TEXTG", "S-TEXTB"] # beam的圖層,因為有兩個以上,所以用list來存30 # block_layer = "DEFPOINTS" # 框框的圖層31 # explode = 0 # 需不需要提前炸圖塊32 # 在beam裡面自訂圖層33 text_layer = "S-RC"34 multiprocessing.freeze_support() 35 pool = multiprocessing.Pool()36 print('Start Reading')37 res_plan =[]38 res_beam = []39 set_plan = set()40 dic_plan = {}41 set_beam = set()42 dic_beam = {}43 for plan_filename in plan_filenames:44 res_plan.append(pool.apply_async(read_plan, (plan_filename,floor_layer, beam_layer, block_layer, size_layer, plan_file, explode)))45 for beam_filename in beam_filenames:46 res_beam.append(pool.apply_async(read_beam, (beam_filename, text_layer, beam_file,0)))47 48 plan_drawing = 049 if len(plan_filenames) == 1:50 plan_drawing = 151 beam_drawing = 052 if len(beam_filenames) == 1:53 beam_drawing = 154 for plan in res_plan:55 plan = plan.get()56 set_plan = set_plan | plan[0]57 if plan_drawing:58 dic_plan = plan[1]59 for beam in res_beam:60 beam = beam.get()61 set_beam = set_beam | beam[0]62 if beam_drawing:63 dic_beam = beam[1]64 print('Start Writing')65 plan_result = write_plan(plan_filename, plan_new_filename, set_plan, set_beam, dic_plan, big_file, sml_file, date,plan_drawing)66 beam_result = write_beam(beam_filename, beam_new_filename, set_plan, set_beam, dic_beam, big_file, sml_file, date,beam_drawing)67 end = time.time()68 write_result_log(excel_file, task_name, plan_result[0], plan_result[1], beam_result[0], beam_result[1], f'{round(end - start, 2)}(s)', time.strftime("%Y-%m-%d %H:%M", time.localtime()), 'none')69 # write_result_log(excel_file,'','','','','','',time.strftime("%Y-%m-%d %H:%M", time.localtime()),'')70def main_col_function(col_filenames,plan_filenames,col_new_filename,plan_new_filename,result_file,block_layer,task_name, explode):71 72 start = time.time()73 # task_name = 'task13'74 # 檔案路徑區75 # 跟AutoCAD有關的檔案都要吃絕對路徑76 # plan_filename = "C:/Users/Vince/Desktop/BeamQC/data/task13/XS-PLAN.dwg" # XS-PLAN的路徑77 # col_filename = "C:/Users/Vince/Desktop/BeamQC/data/task13/XS-COL.dwg" # XS-COL的路徑78 # plan_new_filename = f"C:/Users/Vince/Desktop/BeamQC/data/task13/{task_name}-XS-PLAN_new.dwg" # XS-PLAN_new的路徑79 # col_new_filename = f"C:/Users/Vince/Desktop/BeamQC/data/task13/{task_name}-XS-COL_new.dwg" # XS-COL_new的路徑80 plan_file = './result/col_plan.txt' # plan.txt的路徑81 col_file = './result/col.txt' # col.txt的路徑82 excel_file = './result/result_log_col.xlsx' # result_log.xlsx的路徑83 # result_file = f"C:/Users/Vince/Desktop/BeamQC/data/task13/{task_name}-柱配筋.txt" # 柱配筋結果84 date = time.strftime("%Y-%m-%d", time.localtime())85 86 # 在plan裡面自訂圖層87 floor_layer = "S-TITLE" # 樓層字串的圖層88 col_layer = "S-TEXTC" # col的圖層89 # block_layer = "DwFm" # 圖框的圖層90 # explode = 0 # 需不需要提前炸圖塊91 # 在col裡面自訂圖層92 text_layer = "S-TEXT" # 文字的圖層93 line_layer = "S-STUD" # 線的圖層94 multiprocessing.freeze_support()95 pool = multiprocessing.Pool()96 print('Start Reading')97 res_plan =[]98 res_col = []99 set_plan = set()100 dic_plan = {}101 set_col = set()102 dic_col = {}103 for plan_filename in plan_filenames:104 res_plan.append(pool.apply_async(plan_to_col.read_plan, (plan_filename, floor_layer, col_layer, block_layer, plan_file, explode)))105 for col_filename in col_filenames:106 res_col.append(pool.apply_async(plan_to_col.read_col, (col_filename, text_layer, line_layer, col_file, explode)))107 plan_drawing = 0108 if len(plan_filenames) == 1:109 plan_drawing = 1110 col_drawing = 0111 if len(col_filenames) == 1:112 col_drawing = 1113 for plan in res_plan:114 plan = plan.get()115 set_plan = set_plan | plan[0]116 if plan_drawing:117 dic_plan = plan[1]118 for col in res_col:119 col = col.get()120 set_col = set_col | col[0]121 if col_drawing:122 dic_col = col[1]123 124 plan_result = plan_to_col.write_plan(plan_filename, plan_new_filename, set_plan, set_col, dic_plan, result_file, date, plan_drawing)125 col_result = plan_to_col.write_col(col_filename, col_new_filename, set_plan, set_col, dic_col, result_file, date,col_drawing)126 end = time.time()127 plan_to_col.write_result_log(excel_file,task_name,plan_result,col_result, f'{round(end - start, 2)}(s)', time.strftime("%Y-%m-%d %H:%M", time.localtime()), 'none')128 return 129def storefile(file,file_directory,file_new_directory,project_name):130 filename_beam = secure_filename(file.filename)131 save_file = os.path.join(file_directory, f'{project_name}-{filename_beam}')132 file_new_name = os.path.join(file_new_directory, f'{project_name}_MARKON-{filename_beam}')133 file.save(save_file)134 file_ok = True...

Full Screen

Full Screen

test_ai_simulator_adapter.py

Source:test_ai_simulator_adapter.py Github

copy

Full Screen

...12 path_input = os.path.join(13 os.path.dirname(__file__),14 "data/test_ai_simulator_adapter.json")15 plan = json.load(open(path_input, 'r'))16 assert adapter.set_plan(plan) is True17 # Test plan_adapter function18 adapted_plan = adapter.get_plan()19 # Need to make sure the input/dependency and successor_ids are coherent20 for node in adapted_plan:21 for check_node in adapted_plan:22 if check_node["index"] in node['input_ids'] \23 or check_node['index'] in node['dependency_ids']:24 assert node['index'] in check_node['successor_ids']25 elif check_node["index"] in node['successor_ids']:26 assert node['index'] in check_node['input_ids'] \27 or node['index'] in check_node['dependency_ids']28 # Check adapted_plan, excluding the output_tensors29 adapted_plan_without_output_tensors = copy.deepcopy(adapted_plan)30 for node in adapted_plan_without_output_tensors:31 node['output_tensors'] = []32 path_output = os.path.join(33 os.path.dirname(__file__),34 "data/test_ai_simulator_adapter_output.json")35 adapted_plan_without_output_tensors_ref = json.load(open(path_output, 'r'))36 assert(adapted_plan_without_output_tensors ==37 adapted_plan_without_output_tensors_ref)38 # Test wrong input39 assert adapter.set_plan(None) is False40 assert adapter.get_plan() is None41 # No 'device' in node42 wrong_input_node = {43 "name": "test_Send_0",44 "op": "Send",45 "output_shapes": [[1, 100]],46 "tensor_name": "test",47 "tensor_type": "DT_FLOAT",48 "offset": 0,49 "size": 50,50 "reduction": "",51 "target": "/server/hostname1/GPU/1/",52 "related_op": "test_Recv_1",53 "parent": "test",54 "input": [],55 "route_index": 0,56 "route_type": "PCIE"57 }58 assert adapter.set_plan([wrong_input_node]) is False59 assert adapter.get_plan() is None60 # Wrong 'device' type (should be str)61 wrong_input_node = {62 "device": 1024,63 "name": "test_Send_0",64 "op": "Send",65 "output_shapes": [[1, 100]],66 "tensor_name": "test",67 "tensor_type": "DT_FLOAT",68 "offset": 0,69 "size": 50,70 "reduction": "",71 "target": "/server/hostname1/GPU/1/",72 "related_op": "test_Recv_1",73 "parent": "test",74 "input": [],75 "route_index": 0,76 "route_type": "PCIE"77 }78 assert adapter.set_plan([wrong_input_node]) is False79 assert adapter.get_plan() is None80 # No (test_Send_0, /server/hostname1/GPU/1/) in node list81 wrong_input_node = {82 "device": "/server/hostname1/GPU/0/",83 "name": "test_Recv_1",84 "op": "Recv",85 "output_shapes": [[1, 100]],86 "tensor_name": "test",87 "tensor_type": "DT_FLOAT",88 "offset": 50,89 "size": 50,90 "reduction": "sum",91 "target": "/server/hostname1/GPU/1/",92 "related_op": "test_Send_0",93 "parent": "test",94 "input": ["test_Send_0"],95 "route_index": 0,96 "route_type": "PCIE"97 }98 assert adapter.set_plan([wrong_input_node]) is False99 assert adapter.get_plan() is None100 # 'parent' attr is not the same101 wrong_input_nodes = [102 {103 "device": "/server/hostname1/GPU/0/",104 "name": "test_Send_0",105 "op": "Send",106 "output_shapes": [[1, 100]],107 "tensor_name": "test",108 "tensor_type": "DT_FLOAT",109 "offset": 0,110 "size": 50,111 "reduction": "",112 "target": "/server/hostname1/GPU/1/",113 "related_op": "test_Recv_1",114 "parent": "NOT_SAME_PARENT",115 "input": [],116 "route_index": 0,117 "route_type": "PCIE"118 },119 {120 "device": "/server/hostname1/GPU/1/",121 "name": "test_Recv_1",122 "op": "Recv",123 "output_shapes": [[1, 100]],124 "tensor_name": "test",125 "tensor_type": "DT_FLOAT",126 "offset": 0,127 "size": 50,128 "reduction": "sum",129 "target": "/server/hostname1/GPU/0/",130 "related_op": "test_Send_0",131 "parent": "test",132 "input": ["test_Send_0"],133 "route_index": 0,134 "route_type": "PCIE"135 }136 ]137 assert adapter.set_plan(wrong_input_nodes) is False138 assert adapter.get_plan() is None139 # (related_op, target) not in node list140 wrong_input_nodes = [141 {142 "device": "/server/hostname1/GPU/0/",143 "name": "test_Send_0",144 "op": "Send",145 "output_shapes": [[1, 100]],146 "tensor_name": "test",147 "tensor_type": "DT_FLOAT",148 "offset": 0,149 "size": 50,150 "reduction": "",151 "target": "NO_THIS_TARGET",152 "related_op": "test_Recv_1",153 "parent": "test",154 "input": [],155 "route_index": 0,156 "route_type": "PCIE"157 },158 {159 "device": "/server/hostname1/GPU/1/",160 "name": "test_Recv_1",161 "op": "Recv",162 "output_shapes": [[1, 100]],163 "tensor_name": "test",164 "tensor_type": "DT_FLOAT",165 "offset": 0,166 "size": 50,167 "reduction": "sum",168 "target": "/server/hostname1/GPU/0/",169 "related_op": "test_Send_0",170 "parent": "test",171 "input": ["test_Send_0"],172 "route_index": 0,173 "route_type": "PCIE"174 }175 ]176 assert adapter.set_plan(wrong_input_nodes) is False...

Full Screen

Full Screen

planner.py

Source:planner.py Github

copy

Full Screen

...48 y = data.angular.z49 50 robot_ready = True51 52def set_plan(linX,linY,linZ,roll,pitch,yaw,plan,mode):53 point = Twist()54 point_mode = UInt8()55 56 point.linear.x = linX57 point.linear.y = linY58 point.linear.z = linZ59 point.angular.x = roll60 point.angular.y = pitch61 point.angular.z = yaw62 point_mode.data = mode63 64 plan.points.append(point)65 plan.modes.append(point_mode)66 67if __name__ == '__main__':68 # initialize the node69 rospy.init_node('planner', anonymous = True)70 # add a publisher for sending joint position commands71 plan_pub = rospy.Publisher('/plan', Plan, queue_size = 10)72 tfBuffer = tf2_ros.Buffer()73 listener = tf2_ros.TransformListener(tfBuffer)74 img_sub = rospy.Subscriber("/sphere_params", SphereParams, get_sphere) 75 motion_sub = rospy.Subscriber("/motion", Bool, initiate_motion)76 pos_sub = rospy.Subscriber("/ur5e/toolpose",Twist,get_pos)77 # set a 10Hz frequency for this loop78 loop_rate = rospy.Rate(10)79 q_rot = Quaternion() 80 # define a plan variable81 plan = Plan()82 plan_generated = False83 84 while not rospy.is_shutdown():85 if robot_ready and ball_ready and not plan_generated: 86 87 # define coorinates in camera frame88 pt_in_camera = tf2_geometry_msgs.PointStamped()89 pt_in_camera.header.frame_id = 'camera_color_optical_frame'90 pt_in_camera.header.stamp = rospy.get_rostime()91 92 pt_in_camera.point.x= xc93 pt_in_camera.point.y= yc94 pt_in_camera.point.z= zc95 96 97 98 # convert the 3D point to the base frame coordinates99 pt_in_base = tfBuffer.transform(pt_in_camera,'base', rospy.Duration(1.0))100 print('Points in the camera frame: x= ', format(pt_in_camera.point.x, '.3f'), '(m), y= ', format(pt_in_camera.point.y, '.3f'), '(m), z= ', format(pt_in_camera.point.z, '.3f'),'(m)')101 print('Transformed points in the BASE frame: x= ', format(pt_in_base.point.x, '.3f'), '(m), y= ', format(pt_in_base.point.y, '.3f'), '(m), z= ', format(pt_in_base.point.z, '.3f'),'(m)')102 print('-------------------------------------------------')103 104 #roll, pitch, yaw = 3.12614, 0.0166, 1.5308105 # 0=leave 1=open 2=close106 y_offset = -0.01107 z_offset = 0.015108 set_plan(posX,posY,posZ,r,p,y,plan,0)109 set_plan(pt_in_base.point.x,pt_in_base.point.y+y_offset,pt_in_base.point.z + 0.1,r,p,y,plan,0)110 set_plan(pt_in_base.point.x,pt_in_base.point.y+y_offset,pt_in_base.point.z + z_offset,r,p,y,plan,0)111 set_plan(pt_in_base.point.x,pt_in_base.point.y+y_offset,pt_in_base.point.z + z_offset,r,p,y,plan,2)112 set_plan(pt_in_base.point.x,pt_in_base.point.y,pt_in_base.point.z + 0.1,r,p,y,plan,0)113 set_plan(pt_in_base.point.x + 0.3,pt_in_base.point.y + 0.1,pt_in_base.point.z + 0.2,r,p,y,plan,0)114 set_plan(pt_in_base.point.x + 0.3,pt_in_base.point.y + 0.1,pt_in_base.point.z + z_offset,r,p,y,plan,0)115 set_plan(pt_in_base.point.x + 0.3,pt_in_base.point.y + 0.1,pt_in_base.point.z + z_offset,r,p,y,plan,1)116 set_plan(pt_in_base.point.x + 0.3,pt_in_base.point.y + 0.1,pt_in_base.point.z + 0.2,r,p,y,plan,0)117 #set_plan(pt_in_base.point.x,pt_in_base.point.y,pt_in_base.point.z + 0.1,r,p,y,plan,0)118 #set_plan(posX,posY,posZ,r,p,y,plan,0)119 120 plan_generated = True121 122 123 # publish the plan if movemnt true124 if motion == True:125 plan_pub.publish(plan)126 # wait for 0.1 seconds until the next loop and repeat...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tappy automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful