-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMrun.py
More file actions
68 lines (59 loc) · 1.59 KB
/
Copy pathMrun.py
File metadata and controls
68 lines (59 loc) · 1.59 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
61
62
63
64
65
66
67
68
import time
import robot
import threading
import Tcpnetworks
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
server = Tcpnetworks.Tcpnetworks()
server.Serve('0.0.0.0', 8080)
go = robot.Master()
sender = threading.Thread(target=server.Send_th, args=(server.connection,))
#try :
fout2 = open('ahrs.txt', 'w')
send_message = 'start'
server.SendStr(send_message) #syncronize with slave pi when slave pi receive "start"message start recording AHRS & camera
sender.start()
command=""
while True:
AHRS_data = server.ReceiveStr2() # receive AHRS_data
AHRS_data=str(AHRS_data)
fout2.write(AHRS_data)
print(AHRS_data)
go.gyro.gyro_out()
go.gyro.filewrite()
command = AHRS_data[0] # clinet to server command
if command == 'w' :
for i in range(1,300):
go.move(5)
time.sleep(0.01)
elif command == 's':
for i in range(1,300):
go.move(-5)
time.sleep(0.01)
elif command == 'a':
print("turn Left")
elif command=="d":
print("turn Right")
elif command == 'show':
for i in range(1,1000):
go.move(5)
time.sleep(0.01)
go.move(0)
for i in range(1,1000):
go.move(-5)
time.sleep(0.01)
go.move(0)
send_command = 'd'
sever.SendStr(send_command)
time.sleep(3000)
send_command = 'a'
sever.SendStr(send_command)
time.sleep(3000)
elif command=="p"
print("Camera Recording pause")
else :
print ("wrong command")
#except:
go.stop()
GPIO.cleanup()