-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
49 lines (39 loc) · 1.52 KB
/
main.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
import math
import time
import socket
import json
from scipy import arange
from Speaker import *
import commands
from config import *
from PulseDetection import getTimesList
from micController import getAndRecordAudio
def main():
# s = socket.socket()
# s.bind((host, port))
# s.listen(5)
# c, addr = s.accept()
SpeakersList = [SpeakerA, SpeakerB, SpeakerC, SpeakerD]
while(True):
import os
#getAndRecordAudio()
timesList = getTimesList()
if len(timesList) != 4:
continue
print timesList
timeA = timesList[0]/1000
timeB = timesList[1]/1000
timeC = timesList[2]/1000
timeD = timesList[3]/1000
cppRawOutput = commands.getstatusoutput("./cppCalculations %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s"
% (speedOfSound, SpeakerA.x, SpeakerA.y, SpeakerA.z, SpeakerB.x, SpeakerB.y, SpeakerB.z, SpeakerC.x, SpeakerC.y, SpeakerC.z, SpeakerD.x, SpeakerD.y, SpeakerD.z, timeA, timeB, timeC, timeD, iStart, iStop, jStart, jStop, kStart, kStop ))
print(cppRawOutput)
finalCoordinates = [ float(numberString) for numberString in cppRawOutput[1].split() ]
finalPointOut = Object3D(finalCoordinates[0], finalCoordinates[1], finalCoordinates[2])
print finalPointOut
sendFinal = [finalPointOut.x, finalPointOut.y, finalPointOut.z]
break
# c.send(json.dumps(sendFinal))
# c.close()
if __name__ == '__main__':
main()