-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrawing_pallet_jack.py
164 lines (134 loc) · 4.99 KB
/
drawing_pallet_jack.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import matplotlib.pyplot as plt
import numpy as np
import math
def wrapToPi(theta):
return math.atan2(math.sin(theta),math.cos(theta))
def dpj(x,y,theta,steer):
# plotting the center point
wd = 1.5
plt.plot(x,y,'co')
plt.arrow(x,y,math.cos(theta),math.sin(theta),width=0.01,color='orange')
plt.arrow(x,y,math.cos(wrapToPi(theta+steer)),math.sin(wrapToPi(theta+steer)),width=0.01,color='g')
#wheel cordinates
A = np.array([-0.3,0.1,1]).T
B = np.array([0.3,0.1,1]).T
C = np.array([-0.3,-0.1,1]).T
D = np.array([0.3,-0.1,1]).T
#tranform the wheel
T_wheel = np.array([[math.cos(wrapToPi(theta + steer)),-math.sin(wrapToPi(theta + steer)),x],
[math.sin(wrapToPi(theta + steer)),math.cos(wrapToPi(theta + steer)),y],
[0,0,1]])
A = np.matmul(T_wheel,A)
B = np.matmul(T_wheel,B)
C = np.matmul(T_wheel,C)
D = np.matmul(T_wheel,D)
#front cordinates
a = np.array([0.5,-0.5,1]).T
b = np.array([0.5,0.5,1]).T
c = np.array([0,1,1]).T
d = np.array([0,-1,1]).T
e = np.array([-0.5,1,1]).T
f = np.array([-0.5,-1,1]).T
#dotted front
X = np.array([-0.5,0.75,1]).T
Y = np.array([0,0.75,1]).T
Z = np.array([0.25,0.5,1]).T
W = np.array([0.25,-0.5,1]).T
U = np.array([0,-0.75,1]).T
V = np.array([-0.5,-0.75,1]).T
#back support
g = np.array([-1.5,1,1]).T
h = np.array([-1.5,-1,1]).T
i = np.array([-1.5,0.75,1]).T
j = np.array([-1.5,0.25,1]).T
k = np.array([-1.5,-0.25,1]).T
l = np.array([-1.5,-0.75,1]).T
#drawing the pallet_first_ends
m = np.array([-4,0.75,1]).T
n = np.array([-4,0.25,1]).T
o = np.array([-4,-0.25,1]).T
p = np.array([-4,-0.75,1]).T
#drawing the lasts
q = np.array([-4.5,0.75-0.2,1]).T
r = np.array([-4.5,0.25+0.2,1]).T
s = np.array([-4.5,-0.25-0.2,1]).T
t = np.array([-4.5,-0.75+0.2,1]).T
# Tranformations
T = np.array([[math.cos(wrapToPi(theta)),-math.sin(wrapToPi(theta)),x],
[math.sin(wrapToPi(theta)),math.cos(wrapToPi(theta)),y],
[0,0,1]])
#front cordinates
a = np.matmul(T,a)
b = np.matmul(T,b)
c = np.matmul(T,c)
d = np.matmul(T,d)
e = np.matmul(T,e)
f = np.matmul(T,f)
#dotted front
X = np.matmul(T,X)
Y = np.matmul(T,Y)
Z = np.matmul(T,Z)
W = np.matmul(T,W)
U = np.matmul(T,U)
V = np.matmul(T,V)
#back support
g = np.matmul(T,g)
h = np.matmul(T,h)
i = np.matmul(T,i)
j = np.matmul(T,j)
k = np.matmul(T,k)
l = np.matmul(T,l)
#drawing the pallet_first_ends
m = np.matmul(T,m)
n = np.matmul(T,n)
o = np.matmul(T,o)
p = np.matmul(T,p)
#drawing the lasts
q = np.matmul(T,q)
r = np.matmul(T,r)
s = np.matmul(T,s)
t = np.matmul(T,t)
back_center = [(n[0]+o[0])/2,(n[1]+o[1])/2]
#plotting color
plt.fill([r[0],q[0],m[0],i[0],j[0],n[0],r[0]],[r[1],q[1],m[1],i[1],j[1],n[1],r[1]],color='grey')
plt.fill([s[0],o[0],k[0],l[0],p[0],t[0],s[0]],[s[1],o[1],k[1],l[1],p[1],t[1],s[1]],color='grey')
plt.fill([g[0],e[0],f[0],h[0],g[0]],[g[1],e[1],f[1],h[1],g[1]],color='orange')
plt.fill([e[0],c[0],b[0],a[0],d[0],f[0],e[0]],[e[1],c[1],b[1],a[1],d[1],f[1],e[1]],color='orange')
plt.fill([A[0],B[0],D[0],C[0],A[0]],[A[1],B[1],D[1],C[1],A[1]],color='blue')
plt.plot([a[0],b[0]],[a[1],b[1]],'k',linewidth=wd)
plt.plot([a[0],d[0]],[a[1],d[1]],'k',linewidth=wd)
plt.plot([c[0],b[0]],[c[1],b[1]],'k',linewidth=wd)
plt.plot([c[0],e[0]],[c[1],e[1]],'k',linewidth=wd)
plt.plot([d[0],f[0]],[d[1],f[1]],'k',linewidth=wd)
plt.plot([e[0],f[0]],[e[1],f[1]],'k',linewidth=wd)
plt.plot([X[0],Y[0]],[X[1],Y[1]],'g--')
plt.plot([Z[0],Y[0]],[Z[1],Y[1]],'g--')
plt.plot([Z[0],W[0]],[Z[1],W[1]],'g--')
plt.plot([U[0],W[0]],[U[1],W[1]],'g--')
plt.plot([U[0],V[0]],[U[1],V[1]],'g--')
plt.plot([g[0],h[0]],[g[1],h[1]],'k',linewidth=wd)
plt.plot([g[0],e[0]],[g[1],e[1]],'k',linewidth=wd)
plt.plot([h[0],f[0]],[h[1],f[1]],'k',linewidth=wd)
plt.plot([i[0],l[0]],[i[1],l[1]],'k',linewidth=wd)
plt.plot([m[0],i[0]],[m[1],i[1]],'k',linewidth=wd)
plt.plot([n[0],j[0]],[n[1],j[1]],'k',linewidth=wd)
plt.plot([o[0],k[0]],[o[1],k[1]],'k',linewidth=wd)
plt.plot([p[0],l[0]],[p[1],l[1]],'k',linewidth=wd)
plt.plot([m[0],q[0]],[m[1],q[1]],'k',linewidth=wd)
plt.plot([q[0],r[0]],[q[1],r[1]],'k',linewidth=wd)
plt.plot([n[0],r[0]],[n[1],r[1]],'k',linewidth=wd)
plt.plot([o[0],s[0]],[o[1],s[1]],'k',linewidth=wd)
plt.plot([s[0],t[0]],[s[1],t[1]],'k',linewidth=wd)
plt.plot([p[0],t[0]],[p[1],t[1]],'k',linewidth=wd)
plt.plot([A[0],B[0]],[A[1],B[1]],'k')
plt.plot([A[0],C[0]],[A[1],C[1]],'k')
plt.plot([D[0],B[0]],[D[1],B[1]],'k')
plt.plot([D[0],C[0]],[D[1],C[1]],'k')
plt.plot([back_center[0],x],[back_center[1],y],'o--',linewidth=wd)
# plt.axes().set_aspect('equal','datalim')
# plt.show()
x = 1
y = 2
theta = math.pi/6
steer = math.pi/3
dpj(x,y,theta,steer)