-
Notifications
You must be signed in to change notification settings - Fork 0
/
receiver.py
78 lines (59 loc) · 1.84 KB
/
receiver.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
import socket
import time
from ucl.common import byte_print, decode_version, decode_sn, getVoltage, pretty_print_obj, lib_version
from ucl.highCmd import highCmd
from ucl.highState import highState
from ucl.lowCmd import lowCmd
from ucl.unitreeConnection import unitreeConnection, HIGH_WIFI_DEFAULTS, HIGH_WIRED_DEFAULTS
from ucl.enums import MotorModeHigh, GaitType
from ucl.complex import motorCmd
from spin_dog import spin_right, spin_left, strafe_right, strafe_left, go_forward, go_backward, turn_around, lie_down, stand_up
# Create a socket object
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# Define the address and port to receive the data
address = 'localhost'
port = 12345
# Bind the socket to the address and port
sock.bind((address, port))
# Listen for incoming connections
sock.listen(1)
# Accept the connection from the sender script
conn, addr = sock.accept()
while True:
# Receive the variable
data = conn.recv(1024).decode()
if not data:
break
# Print the received variable
# print("Received:", data)
if data == "D1va, Spin Right":
print("Poggers")
spin_right()
if data == "D1va, Spin Left":
print("monkaS")
spin_left()
if data == "D1va, Strafe Right":
print("monkaS")
strafe_right()
if data == "D1va, Strafe Left":
print("monkaS")
strafe_left()
if data == "D1va, Go Forward":
print("monkaS")
go_forward()
if data == "D1va, Go Backward":
print("monkaS")
go_backward()
if data == "D1va, Turn Around":
print("monkaS")
turn_around()
if data == "D1va, Lay Down":
print("monkaS")
lie_down()
if data == "D1va, Stand Up":
print("monkaS")
stand_up()
time.sleep(2)
# Close the connection and socket
conn.close()
sock.close()