Skip to content
Snippets Groups Projects
Commit eb613dfe authored by Jingyan Ling's avatar Jingyan Ling
Browse files

parallel trace finally working

parent 3f12b65d
Branches
No related merge requests found
...@@ -13,6 +13,13 @@ ...@@ -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` - 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. - 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.
- ![](journal_media/parallel_trace.png)
- TODO:
- Connect traces to isolation box
- Merge pre-processing code
- Clean up script
- Read trace width from Net Class
### 08/09/2019 ### 08/09/2019
- Potential problem: - Potential problem:
......
journal_media/parallel_trace.png

8.98 KiB

No preview for this file type
File added
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
(via_costs 50) (via_costs 50)
(plane_via_costs 5) (plane_via_costs 5)
(start_ripup_costs 100) (start_ripup_costs 100)
(start_pass_no 91) (start_pass_no 104)
(layer_rule F.Cu (layer_rule F.Cu
(active on) (active on)
(preferred_direction vertical) (preferred_direction vertical)
......
...@@ -39,7 +39,7 @@ class post_process(): ...@@ -39,7 +39,7 @@ class post_process():
# self.draw_wires() # self.draw_wires()
self.parallel_trace(1) self.parallel_trace(1)
self.dwg.saveas('route_text.dxf') self.dwg.saveas('route_test.dxf')
def convert_unitfrom_ses(self): def convert_unitfrom_ses(self):
for path in self._wiring: for path in self._wiring:
...@@ -54,66 +54,64 @@ class post_process(): ...@@ -54,66 +54,64 @@ class post_process():
'linetype':'DASHDOT'}) 'linetype':'DASHDOT'})
def parallel_trace(self,width): def parallel_trace(self,width):
halfw=width/2
for path in self.wiring: for path in self.wiring:
for i in range(len(path)-1): for i in range(len(path)-1):
start_x,start_y=path[i][0],path[i][1] pt1=path[i][0],path[i][1]
end_x,end_y=path[i+1][0],path[i+1][1] pt2=path[i+1][0],path[i+1][1]
theta=self.find_lind_eq(path[i],path[i+1])[3] l1=find_line_eq(pt1,pt2)
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
if i<len(path)-2: if i<len(path)-2:
next_x,next_y=path[i+2][0],path[i+2][1] pt3=path[i+2][0],path[i+2][1]
theta2=self.find_lind_eq(path[i+1],path[i+2])[3] l2=find_line_eq(pt2,pt3)
sinw2=np.sin(theta2)*halfw
cosw2=np.cos(theta2)*halfw #filter bi-sector
_bi=find_angle_bisector(l1,l2)
s2i=[end_x-sinw2,end_y+cosw2] for sector in _bi:
s2o=[end_x+sinw2,end_y-cosw2] if if_two_pt_on_diff_side(sector,pt1,pt3):
e2i=[next_x-sinw2,next_y+cosw2] bi=sector
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]])
e1=np.linalg.solve(Ainteri,binteri) if i==0:
e2=np.linalg.solve(Aintero,bintero) offl1_in,offl1_out=find_offset(l1,width)
if l1[2]==0:
else: s1=[pt1[0]-width/2,pt1[1]]
#from last end point to this end s2=[pt1[0]+width/2,pt1[1]]
e1=[end_x-sinw,end_y+cosw] else:
e2=[end_x+sinw,end_y-cosw] 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', 'layer':'Circuit',
'linetype':'DASHDOT'}) 'linetype':'DASHDOT'})
self.msp.add_line(s1o,e1o,dxfattribs={ self.msp.add_line(s2,e2,dxfattribs={
'layer':'Circuit', '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): def find_line_eq(pt1,pt2):
""" """
input: two points on a line input: two points on a line
...@@ -129,7 +127,7 @@ def find_line_eq(pt1,pt2): ...@@ -129,7 +127,7 @@ def find_line_eq(pt1,pt2):
x2,y2=pt1[0],pt1[1] x2,y2=pt1[0],pt1[1]
if x1==x2: if x1==x2:
theta=-np.pi/2 theta=np.pi/2
#x= number #x= number
a=1 a=1
b=-x1 b=-x1
...@@ -143,11 +141,80 @@ def find_line_eq(pt1,pt2): ...@@ -143,11 +141,80 @@ def find_line_eq(pt1,pt2):
c=1 c=1
return a,b,c,theta 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): 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() line_equation follows same pattern as find_line_eq()
eq=[a,b,c,theta] eq=[a,b,c,theta]
which refers to cy=ax+b which refers to cy=ax+b
""" """
theta1=line_eq1[3]
\ No newline at end of file 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
...@@ -9,7 +9,7 @@ AC1015 ...@@ -9,7 +9,7 @@ AC1015
9 9
$HANDSEED $HANDSEED
5 5
1002A 10021
9 9
$MEASUREMENT $MEASUREMENT
70 70
...@@ -17,7 +17,7 @@ $MEASUREMENT ...@@ -17,7 +17,7 @@ $MEASUREMENT
9 9
$TDUPDATE $TDUPDATE
40 40
2458705.571111111 2458708.7196412035
9 9
$DWGCODEPAGE $DWGCODEPAGE
3 3
...@@ -25,7 +25,7 @@ ANSI_1252 ...@@ -25,7 +25,7 @@ ANSI_1252
9 9
$VERSIONGUID $VERSIONGUID
2 2
315F5506-BAE6-11E9-978A-7470FDECECE4 91E2BB18-BD5F-11E9-978A-7470FDECECE4
0 0
ENDSEC ENDSEC
0 0
...@@ -5643,13 +5643,13 @@ DASHDOT ...@@ -5643,13 +5643,13 @@ DASHDOT
100 100
AcDbLine AcDbLine
10 10
113.16 112.66
20 20
81.65 81.65
11 11
113.16 112.66
21 21
69.4273 69.63440678118653
0 0
LINE LINE
5 5
...@@ -5667,13 +5667,13 @@ DASHDOT ...@@ -5667,13 +5667,13 @@ DASHDOT
100 100
AcDbLine AcDbLine
10 10
113.16 113.66
20 20
69.4273 81.65
11 11
106.6334 113.66
21 21
62.9007 69.22019321881344
0 0
LINE LINE
5 5
...@@ -5691,13 +5691,13 @@ DASHDOT ...@@ -5691,13 +5691,13 @@ DASHDOT
100 100
AcDbLine AcDbLine
10 10
106.6334 112.66
20 20
62.9007 69.63440678118654
11 11
91.8657 106.42629321881347
21 21
62.9007 63.400699999999986
0 0
LINE LINE
5 5
...@@ -5715,13 +5715,13 @@ DASHDOT ...@@ -5715,13 +5715,13 @@ DASHDOT
100 100
AcDbLine AcDbLine
10 10
91.8657 113.65999999999998
20 20
62.9007 69.22019321881344
11 11
89.03 106.84050678118656
21 21
60.065 62.40069999999999
0 0
LINE LINE
5 5
...@@ -5739,13 +5739,13 @@ DASHDOT ...@@ -5739,13 +5739,13 @@ DASHDOT
100 100
AcDbLine AcDbLine
10 10
86.49 106.42629321881344
20 20
60.065 63.40070000000001
11 11
91.4245 91.65859321881345
21 21
64.9995 63.4007
0 0
LINE LINE
5 5
...@@ -5763,13 +5763,13 @@ DASHDOT ...@@ -5763,13 +5763,13 @@ DASHDOT
100 100
AcDbLine AcDbLine
10 10
91.4245 106.84050678118653
20 20
64.9995 62.40070000000001
11 11
107.035 92.07280678118654
21 21
64.9995 62.4007
0 0
LINE LINE
5 5
...@@ -5787,13 +5787,13 @@ DASHDOT ...@@ -5787,13 +5787,13 @@ DASHDOT
100 100
AcDbLine AcDbLine
10 10
107.035 91.65859321881345
20 20
64.9995 63.4007
11 11
108.6128 89.03
21 21
66.5773 60.77210678118655
0 0
LINE LINE
5 5
...@@ -5811,13 +5811,13 @@ DASHDOT ...@@ -5811,13 +5811,13 @@ DASHDOT
100 100
AcDbLine AcDbLine
10 10
108.6128 92.07280678118654
20 20
66.5773 62.4007
11 11
108.6128 89.03
21 21
76.0372 59.35789321881346
0 0
LINE LINE
5 5
...@@ -5835,13 +5835,13 @@ DASHDOT ...@@ -5835,13 +5835,13 @@ DASHDOT
100 100
AcDbLine AcDbLine
10 10
108.6128 86.49
20 20
76.0372 60.77210678118655
11 11
103.0 91.21739321881344
21 21
81.65 65.4995
0 0
LINE LINE
5 5
...@@ -5859,13 +5859,13 @@ DASHDOT ...@@ -5859,13 +5859,13 @@ DASHDOT
100 100
AcDbLine AcDbLine
10 10
113.02541434201778 86.49
20 20
82.13154615631889 59.35789321881346
11 11
113.02541434201778 91.63160678118653
21 21
69.90884615631889 64.4995
0 0
LINE LINE
5 5
...@@ -5883,13 +5883,13 @@ DASHDOT ...@@ -5883,13 +5883,13 @@ DASHDOT
100 100
AcDbLine AcDbLine
10 10
113.29458565798221 91.21739321881344
20 20
81.16845384368112 65.4995
11 11
113.29458565798221 106.82789321881346
21 21
68.94575384368112 65.4995
0 0
LINE LINE
5 5
...@@ -5907,13 +5907,13 @@ DASHDOT ...@@ -5907,13 +5907,13 @@ DASHDOT
100 100
AcDbLine AcDbLine
10 10
113.095611354279 91.63160678118653
20 20
69.92313676981667 64.4995
11 11
106.569011354279 107.24210678118655
21 21
63.396536769816656 64.4995
0 0
LINE LINE
5 5
...@@ -5931,13 +5931,13 @@ DASHDOT ...@@ -5931,13 +5931,13 @@ DASHDOT
100 100
AcDbLine AcDbLine
10 10
113.22438864572099 106.82789321881346
20 20
68.93146323018334 65.4995
11 11
106.69778864572099 108.1128
21 21
62.404863230183345 66.78440678118655
0 0
LINE LINE
5 5
...@@ -5955,13 +5955,13 @@ DASHDOT ...@@ -5955,13 +5955,13 @@ DASHDOT
100 100
AcDbLine AcDbLine
10 10
106.6334 107.24210678118655
20 20
63.4007 64.4995
11 11
91.8657 109.11279999999998
21 21
63.4007 66.37019321881344
0 0
LINE LINE
5 5
...@@ -5979,13 +5979,13 @@ DASHDOT ...@@ -5979,13 +5979,13 @@ DASHDOT
100 100
AcDbLine AcDbLine
10 10
106.6334 108.1128
20 20
62.4007 66.78440678118653
11 11
91.8657 108.1128
21 21
62.4007 75.83009321881346
0 0
LINE LINE
5 5
...@@ -6003,13 +6003,13 @@ DASHDOT ...@@ -6003,13 +6003,13 @@ DASHDOT
100 100
AcDbLine AcDbLine
10 10
91.82129071333289 109.1128
20 20
63.39872391032733 66.37019321881345
11 11
88.98559071333288 109.1128
21 21
60.563023910327324 76.24430678118655
0 0
LINE LINE
5 5
...@@ -6027,13 +6027,13 @@ DASHDOT ...@@ -6027,13 +6027,13 @@ DASHDOT
100 100
AcDbLine AcDbLine
10 10
91.91010928666712 109.11279999999998
20 20
62.402676089672674 76.24430678118655
11 11
89.07440928666712 103.0
21 21
59.56697608967267 82.35710678118656
0 0
LINE LINE
5 5
...@@ -6051,229 +6051,13 @@ DASHDOT ...@@ -6051,229 +6051,13 @@ DASHDOT
100 100
AcDbLine AcDbLine
10 10
86.60189476110153 108.11279999999998
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
20 20
66.09713662720912 75.83009321881346
11 11
108.4733613560375 103.0
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
21 21
81.16049366529894 80.94289321881345
0 0
ENDSEC ENDSEC
0 0
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment