-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
40 lines (31 loc) · 966 Bytes
/
main.py
File metadata and controls
40 lines (31 loc) · 966 Bytes
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
import socket
import json
import os
import sys
from Motion.Movement import Movement
def main(ip, port):
m = Movement()
# Create a socket object
s = socket.socket()
# connect to the server on local computer
s.connect((ip, port))
# receive data from the server
try:
while True:
# os.system('clear')
data =s.recv(256).strip()
data_dict = json.loads(data.decode('utf-8'))
# 1 -> forward 3 -> turn
print('\nRECV:')
f_thrust = - data_dict['1']
r_thrust = data_dict['3']
print(f_thrust, r_thrust)
m.custom_thrust(f_thrust , r_thrust )
s.send('ACK'.encode('utf-8'))
except Exception as e:
print(e)
print("Closing Client")
s.close()
m.cleanup()
if __name__ == '__main__':
main(sys.argv[1], int(sys.argv[2]))