diff --git a/README.md b/README.md index c2a5605baea2050b54ca5c36170c28bc122c622c..3de2dd4c3582b8056446699bf826ba84baf05c1a 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,13 @@ - Separate file `paperbot_draw` to a general useful file `roco_ee_dwg_processing.py` and operations specifically for paperbot `paperbot_draw.py` - functions and classes in `roco_ee_dwg_processing.py` will be useful for future foldable robot project. +- Finally complete the parallel trace drawing. Now any path exported from auto-router will draw parallel trace with desired width to make sure the copper type surface can conduct well. +-  +- TODO: + - Connect traces to isolation box + - Merge pre-processing code + - Clean up script + - Read trace width from Net Class ### 08/09/2019 - Potential problem: diff --git a/journal_media/parallel_trace.png b/journal_media/parallel_trace.png new file mode 100644 index 0000000000000000000000000000000000000000..102cde24b9ca013374f3bd198ee8afb91e51245a Binary files /dev/null and b/journal_media/parallel_trace.png differ diff --git a/paperbot_ee_autoroute/__pycache__/paperbot_draw.cpython-36.pyc b/paperbot_ee_autoroute/__pycache__/paperbot_draw.cpython-36.pyc index 5a079a0f65bd77fc2378e2165cb2526a0871b0f2..bfa348449bc31fafe894486d878812d5d5aa81e7 100644 Binary files a/paperbot_ee_autoroute/__pycache__/paperbot_draw.cpython-36.pyc and b/paperbot_ee_autoroute/__pycache__/paperbot_draw.cpython-36.pyc differ diff --git a/paperbot_ee_autoroute/__pycache__/roco_ee_dwg_processing.cpython-36.pyc b/paperbot_ee_autoroute/__pycache__/roco_ee_dwg_processing.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6e77f41cea3b2714868c31b246860c9e0bf5ccdf Binary files /dev/null and b/paperbot_ee_autoroute/__pycache__/roco_ee_dwg_processing.cpython-36.pyc differ diff --git a/paperbot_ee_autoroute/paperbot_ee.rules b/paperbot_ee_autoroute/paperbot_ee.rules index aa2210917e69ba418b1b8b0fbd904d2e0ee0efc3..8454b7c5dfaf3f9727d6b4991c74c883dffa7504 100644 --- a/paperbot_ee_autoroute/paperbot_ee.rules +++ b/paperbot_ee_autoroute/paperbot_ee.rules @@ -11,7 +11,7 @@ (via_costs 50) (plane_via_costs 5) (start_ripup_costs 100) - (start_pass_no 91) + (start_pass_no 104) (layer_rule F.Cu (active on) (preferred_direction vertical) diff --git a/paperbot_ee_autoroute/roco_ee_dwg_processing.py b/paperbot_ee_autoroute/roco_ee_dwg_processing.py index 761b58d9a7a578655be1f1fa1e28776da91528d2..a3c3841981e85d55a2f9c2fee0c2946060ad0262 100644 --- a/paperbot_ee_autoroute/roco_ee_dwg_processing.py +++ b/paperbot_ee_autoroute/roco_ee_dwg_processing.py @@ -39,7 +39,7 @@ class post_process(): # self.draw_wires() self.parallel_trace(1) - self.dwg.saveas('route_text.dxf') + self.dwg.saveas('route_test.dxf') def convert_unitfrom_ses(self): for path in self._wiring: @@ -54,66 +54,64 @@ class post_process(): 'linetype':'DASHDOT'}) def parallel_trace(self,width): - halfw=width/2 for path in self.wiring: for i in range(len(path)-1): - start_x,start_y=path[i][0],path[i][1] - end_x,end_y=path[i+1][0],path[i+1][1] + pt1=path[i][0],path[i][1] + pt2=path[i+1][0],path[i+1][1] - theta=self.find_lind_eq(path[i],path[i+1])[3] - sinw=np.sin(theta)*halfw - cosw=np.cos(theta)*halfw - s1i=[start_x-sinw,start_y+cosw] - s1o=[start_x+sinw,start_y-cosw] - e1i=[end_x-sinw,end_y+cosw] - e1o=[end_x+sinw,end_y-cosw] - - line1i=self.find_lind_eq(s1i,e1i) - line1o=self.find_lind_eq(s1o,e1o) - - if i==0: - s1=s1i - s2=s1o - else: - s1=e1 - s2=e2 + l1=find_line_eq(pt1,pt2) if i<len(path)-2: - next_x,next_y=path[i+2][0],path[i+2][1] - theta2=self.find_lind_eq(path[i+1],path[i+2])[3] - - sinw2=np.sin(theta2)*halfw - cosw2=np.cos(theta2)*halfw - - s2i=[end_x-sinw2,end_y+cosw2] - s2o=[end_x+sinw2,end_y-cosw2] - e2i=[next_x-sinw2,next_y+cosw2] - e2o=[next_x+sinw2,next_y-cosw2] - - line2i=find_lind_eq(s2i,e2i) - line2o=find_lind_eq(s2o,e2o) - - Ainteri=np.array([[line1i[0],-line1i[2]],[line2i[0],-line2i[2]]]) - binteri=np.array([-line1i[1],-line2i[1]]) - Aintero=np.array([[line1o[0],-line1o[2]],[line2o[0],-line2o[2]]]) - bintero=np.array([-line1o[1],-line2o[1]]) + pt3=path[i+2][0],path[i+2][1] + l2=find_line_eq(pt2,pt3) + + + #filter bi-sector + _bi=find_angle_bisector(l1,l2) + for sector in _bi: + if if_two_pt_on_diff_side(sector,pt1,pt3): + bi=sector - e1=np.linalg.solve(Ainteri,binteri) - e2=np.linalg.solve(Aintero,bintero) - - else: - #from last end point to this end - e1=[end_x-sinw,end_y+cosw] - e2=[end_x+sinw,end_y-cosw] + if i==0: + offl1_in,offl1_out=find_offset(l1,width) + if l1[2]==0: + s1=[pt1[0]-width/2,pt1[1]] + s2=[pt1[0]+width/2,pt1[1]] + else: + s1=[pt1[0],offl1_in[0]*pt1[0]+offl1_in[1]] + s2=[pt1[0],offl1_out[0]*pt1[0]+offl1_out[1]] + + offl2_in,offl2_out=find_offset(l2,width) + e1=find_intersect(offl1_in,bi) + e2=find_intersect(offl1_out,bi) + else: + if l1[2]==0: + e1=[pt2[0]-width/2,pt2[1]] + e2=[pt2[0]+width/2,pt2[1]] + else: + e1=[pt2[0],offl1_in[0]*pt2[0]+offl1_in[1]] + e2=[pt2[0],offl1_out[0]*pt2[0]+offl1_out[1]] - self.msp.add_line(s1i,e1i,dxfattribs={ + + self.msp.add_line(s1,e1,dxfattribs={ 'layer':'Circuit', 'linetype':'DASHDOT'}) - self.msp.add_line(s1o,e1o,dxfattribs={ + self.msp.add_line(s2,e2,dxfattribs={ 'layer':'Circuit', - 'linetype':'DASHDOT'}) + 'linetype':'DASHDOT'}) + + if i<len(path)-2: + if list(e1)==list(find_intersect(offl2_out,bi)): + offl1_out,offl1_in=find_offset(l2,width) + else: + offl1_in,offl1_out=find_offset(l2,width) + s1=find_intersect(offl1_in,bi) + s2=find_intersect(offl1_out,bi) + + + def find_line_eq(pt1,pt2): """ input: two points on a line @@ -129,7 +127,7 @@ def find_line_eq(pt1,pt2): x2,y2=pt1[0],pt1[1] if x1==x2: - theta=-np.pi/2 + theta=np.pi/2 #x= number a=1 b=-x1 @@ -143,11 +141,80 @@ def find_line_eq(pt1,pt2): c=1 return a,b,c,theta +def find_intersect(line_eq1,line_eq2): + """ + line_equation follows same pattern as find_line_eq() + eq=[a,b,c,theta] + which refers to cy=ax+b + """ + a1,b1,c1=line_eq1[0],line_eq1[1],line_eq1[2] + a2,b2,c2=line_eq2[0],line_eq2[1],line_eq2[2] + A=np.array([[a1,-c1],[a2,-c2]]) + k=np.array([-b1,-b2]) + sol=np.linalg.solve(A,k) + return sol def find_angle_bisector(line_eq1,line_eq2): """ + return an array with 2 angle bisector for 2 straight lines line_equation follows same pattern as find_line_eq() eq=[a,b,c,theta] which refers to cy=ax+b """ - \ No newline at end of file + theta1=line_eq1[3] + theta2=line_eq2[3] + inter_pt=find_intersect(line_eq1,line_eq2) + + theta=(theta1+theta2)/2 + theta_=(theta1+theta2)/2 +np.pi/2 + a=np.tan(theta) + a_=np.tan(theta_) + b=inter_pt[1]-(a*inter_pt[0]) + b_=inter_pt[1]-(a_*inter_pt[0]) + #to keep format consisent + c=1 + + bi1=[a,b,c,theta] + bi2=[a_,b_,c,theta_] + bi=[bi1,bi2] + return bi +def find_offset(line_eq,line_width): + """ + return two lines that offset both out and in with width + line_equation follows same pattern as find_line_eq() + eq=[a,b,c,theta] + """ + halfw=line_width/2 + a,b,c,theta=line_eq[0],line_eq[1],line_eq[2],line_eq[3] + if c==0: + scale=1 + else: + scale=np.cos(theta) + offset=halfw/scale + b1=b+offset + b2=b-offset + off_l1=[a,b1,c,theta] + off_l2=[a,b2,c,theta] + return off_l1,off_l2 +def if_two_pt_on_diff_side(line_eq,pt1,pt2): + """ + return: booleen + True if two points are on different side of a line + line_equation follows same pattern as find_line_eq() + eq=[a,b,c,theta] + assume bi-sector (line-eq) is not a vertical line (c!=0) + """ + a,b=line_eq[0],line_eq[1] + x1,y1=pt1[0],pt1[1] + x2,y2=pt2[0],pt2[1] + if x1>x2: + x1,y1=pt2[0],pt2[1] + x2,y2=pt1[0],pt1[1] + _y1=a*x1+b + _y2=a*x2+b + + if np.sign(_y1-y1)!= np.sign(_y2-y2): + return True + else: + return False + diff --git a/paperbot_ee_autoroute/route_text.dxf b/paperbot_ee_autoroute/route_test.dxf similarity index 94% rename from paperbot_ee_autoroute/route_text.dxf rename to paperbot_ee_autoroute/route_test.dxf index eb313c4ba6f984005770f38c292572ab50392d50..4ae4d4796cc9499f937d3689b48bc509412fa8b0 100644 --- a/paperbot_ee_autoroute/route_text.dxf +++ b/paperbot_ee_autoroute/route_test.dxf @@ -9,7 +9,7 @@ AC1015 9 $HANDSEED 5 -1002A +10021 9 $MEASUREMENT 70 @@ -17,7 +17,7 @@ $MEASUREMENT 9 $TDUPDATE 40 -2458705.571111111 +2458708.7196412035 9 $DWGCODEPAGE 3 @@ -25,7 +25,7 @@ ANSI_1252 9 $VERSIONGUID 2 -315F5506-BAE6-11E9-978A-7470FDECECE4 +91E2BB18-BD5F-11E9-978A-7470FDECECE4 0 ENDSEC 0 @@ -5643,13 +5643,13 @@ DASHDOT 100 AcDbLine 10 -113.16 +112.66 20 81.65 11 -113.16 +112.66 21 -69.4273 +69.63440678118653 0 LINE 5 @@ -5667,13 +5667,13 @@ DASHDOT 100 AcDbLine 10 -113.16 +113.66 20 -69.4273 +81.65 11 -106.6334 +113.66 21 -62.9007 +69.22019321881344 0 LINE 5 @@ -5691,13 +5691,13 @@ DASHDOT 100 AcDbLine 10 -106.6334 +112.66 20 -62.9007 +69.63440678118654 11 -91.8657 +106.42629321881347 21 -62.9007 +63.400699999999986 0 LINE 5 @@ -5715,13 +5715,13 @@ DASHDOT 100 AcDbLine 10 -91.8657 +113.65999999999998 20 -62.9007 +69.22019321881344 11 -89.03 +106.84050678118656 21 -60.065 +62.40069999999999 0 LINE 5 @@ -5739,13 +5739,13 @@ DASHDOT 100 AcDbLine 10 -86.49 +106.42629321881344 20 -60.065 +63.40070000000001 11 -91.4245 +91.65859321881345 21 -64.9995 +63.4007 0 LINE 5 @@ -5763,13 +5763,13 @@ DASHDOT 100 AcDbLine 10 -91.4245 +106.84050678118653 20 -64.9995 +62.40070000000001 11 -107.035 +92.07280678118654 21 -64.9995 +62.4007 0 LINE 5 @@ -5787,13 +5787,13 @@ DASHDOT 100 AcDbLine 10 -107.035 +91.65859321881345 20 -64.9995 +63.4007 11 -108.6128 +89.03 21 -66.5773 +60.77210678118655 0 LINE 5 @@ -5811,13 +5811,13 @@ DASHDOT 100 AcDbLine 10 -108.6128 +92.07280678118654 20 -66.5773 +62.4007 11 -108.6128 +89.03 21 -76.0372 +59.35789321881346 0 LINE 5 @@ -5835,13 +5835,13 @@ DASHDOT 100 AcDbLine 10 -108.6128 +86.49 20 -76.0372 +60.77210678118655 11 -103.0 +91.21739321881344 21 -81.65 +65.4995 0 LINE 5 @@ -5859,13 +5859,13 @@ DASHDOT 100 AcDbLine 10 -113.02541434201778 +86.49 20 -82.13154615631889 +59.35789321881346 11 -113.02541434201778 +91.63160678118653 21 -69.90884615631889 +64.4995 0 LINE 5 @@ -5883,13 +5883,13 @@ DASHDOT 100 AcDbLine 10 -113.29458565798221 +91.21739321881344 20 -81.16845384368112 +65.4995 11 -113.29458565798221 +106.82789321881346 21 -68.94575384368112 +65.4995 0 LINE 5 @@ -5907,13 +5907,13 @@ DASHDOT 100 AcDbLine 10 -113.095611354279 +91.63160678118653 20 -69.92313676981667 +64.4995 11 -106.569011354279 +107.24210678118655 21 -63.396536769816656 +64.4995 0 LINE 5 @@ -5931,13 +5931,13 @@ DASHDOT 100 AcDbLine 10 -113.22438864572099 +106.82789321881346 20 -68.93146323018334 +65.4995 11 -106.69778864572099 +108.1128 21 -62.404863230183345 +66.78440678118655 0 LINE 5 @@ -5955,13 +5955,13 @@ DASHDOT 100 AcDbLine 10 -106.6334 +107.24210678118655 20 -63.4007 +64.4995 11 -91.8657 +109.11279999999998 21 -63.4007 +66.37019321881344 0 LINE 5 @@ -5979,13 +5979,13 @@ DASHDOT 100 AcDbLine 10 -106.6334 +108.1128 20 -62.4007 +66.78440678118653 11 -91.8657 +108.1128 21 -62.4007 +75.83009321881346 0 LINE 5 @@ -6003,13 +6003,13 @@ DASHDOT 100 AcDbLine 10 -91.82129071333289 +109.1128 20 -63.39872391032733 +66.37019321881345 11 -88.98559071333288 +109.1128 21 -60.563023910327324 +76.24430678118655 0 LINE 5 @@ -6027,13 +6027,13 @@ DASHDOT 100 AcDbLine 10 -91.91010928666712 +109.11279999999998 20 -62.402676089672674 +76.24430678118655 11 -89.07440928666712 +103.0 21 -59.56697608967267 +82.35710678118656 0 LINE 5 @@ -6051,229 +6051,13 @@ DASHDOT 100 AcDbLine 10 -86.60189476110153 - 20 -60.552318748293175 - 11 -91.53639476110153 - 21 -65.48681874829317 - 0 -LINE - 5 -10021 -330 -1F -100 -AcDbEntity - 8 -Circuit - 6 -DASHDOT - 67 -0 -100 -AcDbLine - 10 -86.37810523889846 - 20 -59.57768125170682 - 11 -91.31260523889846 - 21 -64.51218125170682 - 0 -LINE - 5 -10022 -330 -1F -100 -AcDbEntity - 8 -Circuit - 6 -DASHDOT - 67 -0 -100 -AcDbLine - 10 -91.4245 - 20 -65.4995 - 11 -107.035 - 21 -65.4995 - 0 -LINE - 5 -10023 -330 -1F -100 -AcDbEntity - 8 -Circuit - 6 -DASHDOT - 67 -0 -100 -AcDbLine - 10 -91.4245 - 20 -64.4995 - 11 -107.035 - 21 -64.4995 - 0 -LINE - 5 -10024 -330 -1F -100 -AcDbEntity - 8 -Circuit - 6 -DASHDOT - 67 -0 -100 -AcDbLine - 10 -107.05448456692423 - 20 -65.49912020740936 - 11 -108.63228456692423 - 21 -67.07692020740936 - 0 -LINE - 5 -10025 -330 -1F -100 -AcDbEntity - 8 -Circuit - 6 -DASHDOT - 67 -0 -100 -AcDbLine - 10 -107.01551543307576 - 20 -64.49987979259063 - 11 -108.59331543307576 - 21 -66.07767979259063 - 0 -LINE - 5 -10026 -330 -1F -100 -AcDbEntity - 8 -Circuit - 6 -DASHDOT - 67 -0 -100 -AcDbLine - 10 -108.75223864396249 - 20 -67.05746337279086 - 11 -108.75223864396249 - 21 -76.51736337279087 - 0 -LINE - 5 -10027 -330 -1F -100 -AcDbEntity - 8 -Circuit - 6 -DASHDOT - 67 -0 -100 -AcDbLine - 10 -108.4733613560375 +108.11279999999998 20 -66.09713662720912 +75.83009321881346 11 -108.4733613560375 - 21 -75.55703662720913 - 0 -LINE - 5 -10028 -330 -1F -100 -AcDbEntity - 8 -Circuit - 6 -DASHDOT - 67 -0 -100 -AcDbLine - 10 -108.71469969719057 - 20 -76.52670633470106 - 11 -103.10189969719058 - 21 -82.13950633470107 - 0 -LINE - 5 -10029 -330 -1F -100 -AcDbEntity - 8 -Circuit - 6 -DASHDOT - 67 -0 -100 -AcDbLine - 10 -108.51090030280942 - 20 -75.54769366529894 - 11 -102.89810030280942 +103.0 21 -81.16049366529894 +80.94289321881345 0 ENDSEC 0