-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotterTest
49 lines (40 loc) · 1.21 KB
/
plotterTest
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
from RobotArm import*
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from mpl_toolkits.mplot3d.art3d import Poly3DCollection
def tofloat(thetuple): return float(thetuple)
if __name__ == '__main__':
arm = greenRobotArm()
fig = plt.figure()
ax = fig.gca(projection='3d')
angle = 5*pi/180
x=[50,266*cos(angle)]
y=[0,294]
z=[0,294*sin(angle)]
x, y = np.meshgrid(x,y)
surf = ax.plot_surface(x, y, z, rstride=1, cstride=1, linewidth=0)
ax.set_zlim(0, 300)
plt.axis([0,300, 0,300])
ourArm = GreenRobotArm()
plt.show()
while(theindex<20):
d = np.matrix([np.cos(theindex*15*180/np.pi),np.sin(theindex*15*180/np.pi),10)])
raw_input()
time.sleep(2)
ourArm.goToPoint(d)
theMatrix = ourArm.getPlotPoints()
theMatrixReloaded = zip(theMatrix[0],theMatrix[1],theMatrix[2])
thenum = [0,0,0,0,0]
for i in range(5):
thenum[i] = map (tofloat, theMatrixReloaded[i])
#print thenum
for i in range(5):
thenum2 = thenum[i]
ax.scatter(thenum2[0],thenum2[1],thenum2[2], color = (0.3600,0.6000,0.5000,1))
if i < 4:
thenum3 = thenum[i+1]
ax.plot([thenum2[0],thenum3[0]],[thenum2[1],thenum3[1]],[thenum2[2],thenum3[2]])
plt.draw()
plt.show()
theindex+=2