-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththrow_up.py
More file actions
60 lines (44 loc) · 1.1 KB
/
throw_up.py
File metadata and controls
60 lines (44 loc) · 1.1 KB
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
import socket
import numpy as np
import matplotlib.pyplot as plt
import time
plt.grid()
msg = "5,0,0 " # Move to X=3, Y=2, Z=1
item0 = "Cube"
def MoveTo(item,x,y,z):
msg = str(item) + "," + str(x) + "," + str(y) + "," + str(z)
Send(msg)
def Send(msg):
client = socket.socket()
client.connect(('localhost', 5600))
print("Socket connected")
client.send(msg.encode())
print("Sent msg: ", msg)
client.close()
if __name__ == "__main__":
x0 = 0
y0 = 0
z0 = 0
v = 10
dt = 0.1 # s when the value increases the smoothness increase
a = -1 # constant
tStart = 0
tStop = 30
xaxis = []
yaxis = []
print(int(1 + ((tStop - tStart)/dt)))
t = np.linspace(tStart, tStop, int(1 + ((tStop - tStart)/dt)))
# t = range(0,10)
z = []
z.append(z0)
for ti in t[1:]:
v += a*dt
dx = v * dt
zi = z[-1] + dx
MoveTo(item0,x0, y0, zi)
xaxis.append(ti)
yaxis.append(zi)
plt.plot(xaxis, yaxis)
plt.pause(dt)
z.append(zi)
#time.sleep(dt)