From 24f9edf0e0bcc0b232ff3bf79f0e67945946fdb5 Mon Sep 17 00:00:00 2001 From: Ram Reddy <69733662+ramnreddy15@users.noreply.github.com> Date: Sun, 6 Mar 2022 16:50:48 -0500 Subject: [PATCH] Done for today --- .../__pycache__/Propioception.cpython-38.pyc | Bin 0 -> 3358 bytes .../__pycache__/bootup.cpython-38.pyc | Bin 2088 -> 3593 bytes .../__pycache__/commands.cpython-38.pyc | Bin 0 -> 648 bytes Control System/bootup.py | 82 ++++++++++-------- client1.py | 26 ++++-- 5 files changed, 66 insertions(+), 42 deletions(-) create mode 100644 Control System/__pycache__/Propioception.cpython-38.pyc create mode 100644 Control System/__pycache__/commands.cpython-38.pyc diff --git a/Control System/__pycache__/Propioception.cpython-38.pyc b/Control System/__pycache__/Propioception.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..441d93579cae75d589a848d070d23d3031b9777c GIT binary patch literal 3358 zcmds4TW{Mo6s9g#95?COAPdl<0|*pb>me?>^2**23mbMhM~v+_mf8V(+6d@aBoEJxA3w@ZS63SZTI<@UyT7ax z@+)@EHU~P}@Td(CjC9C%gjvjfO_+UbcP!?#Nz*<2x$&eQDH9Buei{9QWnH&WNRZ~(VN!eTsRjf7|q;c}W z=?brAZHZqQ?e(jZnawWRoy}F6t<1-)txo9de3j?Ql#1<9eKAZJm(}H*YAiaKw@{K^ zp}><}aZqaCggGq#VdyX56MBS0_KPSed@~|k>6>E`o z!JvkUwA4s}z3v0krESxlqqSSvD6ji|1T5tHElj5lf>@s8IhU-%jd|sXVu;*2X~_Oq zj0fN6j z2y@#6WUURi36#tWK7&1&?q;!V6RM@d3~C8?18y9P3i=J?$ZRl@E-*DbTHR0CGc2K^ zK-90G&QZEYTdjM*zM8^?(o003Pl18!9!UwKp&hSK^ ze7yVkB4gjv&+KF4=L>wrFF^zoJY_r7S}6~?X|2#QtsUB?bwbCqZs>l^ge{!!m~dWO zp(kA7eaAvySlg`Szr}p4#Y=vDD<*dKvGDT+zM>5x85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2m==QZ!%t@W1%zR3v^8rzXwznggkIyeD;3Mf@|F;9SZ)NcvB@cQ0QrR&Lu& zH`NSG;zktC;ZUsJ&yrkW$252H!642=5i|jm16}wdvwQh^Ypo2lwJECHzT3OszSE7C zIuCcg?{&J5@7(^O^oJ_V0FtLLRFQ#-Qdas>sa!=tKLs+fD2S6p4k3oCo|l1;NiJmR z@5^|2ScWtWM|xiovrA&d9e^GT1qo*)X4f*;toQz z#p!IQ(vf8tn5)zr{Wy{%c@8Z783x8zc<4HO9dpB}0giPZdNod8$Q!)wgl@5Z2F^E> zyn#?cEBS2^+67@4G7n4&e&DG`pz-Vv9JLJ;IL4b0KKYara!fF(oTAU0gv1x#3_HR~ zk<1~A5|x>@eYi#K&TldqA;mYEY6+JWYx7(-x8r`CB|t>cxS#1%$flghwyLGumzj;O z0x+1OXQ);%locEMd{}x^21;M|r5vhNY`x+(W^q)YcX+0~4z~X<9*9HT!t50?4}2IpCt#g5Li$+{*Ri1V zp_)3!K>UPL5N&Yq!>M1rvT^P6FE*}jT)p;X`W3*^a;!o{X0&)z)8ujdz6V>iLEFa9 z;}&E!0hR$>>JnzufhHzJ_F4d|kBK4|?EZpp)>T^p!f$3_x=AHu?j;_1=rp$e1C5Q> AIsgCw diff --git a/Control System/__pycache__/commands.cpython-38.pyc b/Control System/__pycache__/commands.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b8d4ef661be460ca9e0eb6db9e6f8e3b2da0a5a5 GIT binary patch literal 648 zcmb7BJ8u&~5T3o4FDFNs6jT&$Qn)aopg<8qiHuT#U05lwPKunHIdSA(+T9EC$w)}h z@*nO>{?fKo{tM7BYlD=Qk>(qH^ZNF2eS91N+w|$_?Qa3_(~^hgGr3?_FBlL|8g&Cs?@T|r)r}#74hsq$IAmvs-jqzsGijuGpx$X5*KNj zz9l^3o$3h#h>9xyDg$yA}j@bVInHiti literal 0 HcmV?d00001 diff --git a/Control System/bootup.py b/Control System/bootup.py index 8ba7ae5..3bbfb51 100644 --- a/Control System/bootup.py +++ b/Control System/bootup.py @@ -6,20 +6,20 @@ # 1 for executing the first action in the priority queue from Propioception import * -from commands import * +# from commands import * import re import threading import socket import heapq import time -import serial +#import serial class Receiver: def __init__(self, host, port): - self.commands = [""] - self.execute = [""] - self.transmit = [""] + self.commands = [] + self.executions = [] + self.transmit = [] self.timer = 0 self.HOST = host self.PORT = port @@ -46,6 +46,7 @@ class Receiver: action = self.conn.recv(1024).decode('UTF-8') if len(action) > 0: heapq.heappush(self.commands,action) + print("Received|"+action) heapq.heappush(self.transmit,"Received|"+action) """Method checks commands from queue and adds to execution queue""" @@ -57,35 +58,43 @@ class Receiver: #in command statement pattern = "^[0-5]\|.*\|[0-9]{2}:[0-9]{2}\|" #everything but the checksum value checksum = "\w+$" #checksum value - popped = heapq.heapop(self.commands) #gets smallest value command + popped = heapq.heappop(self.commands) #gets smallest value command com = re.findall(pattern, popped) numval = re.findall(checksum, popped) + numval = numval[0] numval = int(numval,16) #converts hex to int + print(com[0]) + print(sum([ord(i) for i in com[0]])) if numval == sum([ord(i) for i in com[0]]): + print("working") heapq.heappush(self.transmit, "Correct|"+popped) - heapq.heappush(self.execute, popped) + heapq.heappush(self.executions, popped) + print(self.transmit) + print(self.executions) else: - heappq.heappush(self.transmit, "Incorrect|"+popped) + heapq.heappush(self.transmit, "Incorrect|"+popped) def telemetryTransmit(self): while True: if len(self.transmit) > 0: - self.conn.send((heapq.heappop(self.transmit)).encode()) + print("Transmit queue", self.transmit) + self.conn.send(bytes(heapq.heappop(self.transmit),'utf-8')) def execute(self): - while len(self.actions) > 0: - if self.timer == 0: - command = heapq.heappop(self.actions) - if command == "Password A_on_LED": - if onAndOfffLed(): - print("Executed: ", command) - else: - print("Did not execute correctly ", command) - + while True: + if len(self.executions) > 0: + command = heapq.heappop(self.executions) + print(command) + heapq.heappush(self.transmit, "Executed|"+command) + # if command == "Password A_on_LED": + # if onAndOfffLed(): + # print("Executed: ", command) + # else: + # print("Did not execute correctly ", command) + print("Inside execute",self.executions) time.sleep(5) - if "Password Balancing" not in self.actions: - heapq.heappush(self.actions, "Password Balancing") - print("Inside execute",self.actions) + if "Balancing" not in self.executions: + heapq.heappush(self.executions, "Balancing") def balance(self): print("Nothing") @@ -97,16 +106,17 @@ class Receiver: print("Nothing") def sensorData(self): + var = "" # Test - print("Inside") - ser = serial.Serial('/dev/ttyACM0', 115200, timeout=1) - ser.reset_input_buffer() - while True: - print("Inside data") - # Read from Arduinos to know what motors and sensors there are - ser.write("Send ****s plz\n".encode('utf-8')) - line = ser.readline().decode('utf-8').rstrip() - print(line) + # print("Inside") + # ser = serial.Serial('/dev/ttyACM0', 115200, timeout=1) + # ser.reset_input_buffer() + # while True: + # print("Inside data") + ## # Read from Arduinos to know what motors and sensors there are + # ser.write("Send ****s plz\n".encode('utf-8')) + # line = ser.readline().decode('utf-8').rstrip() + # print(line) def runSimul(self): threading.Thread(target=self.telemetryReceive).start() @@ -114,12 +124,12 @@ class Receiver: threading.Thread(target=self.telemetryTransmit).start() threading.Thread(target=self.execute).start() - threading.Thread(target=self.sensorData).start() - - threading.Thread(target=self.balance).start() - threading.Thread(target=self.gaitGen).start() - threading.Thread(target=self.comuterVision).start() + # threading.Thread(target=self.sensorData).start() + + # threading.Thread(target=self.balance).start() + # threading.Thread(target=self.gaitGen).start() + # threading.Thread(target=self.comuterVision).start() def startBoot(): - simulation = Receiver('10.235.1.148',12345) + simulation = Receiver('10.235.1.145',12345) simulation.runSimul() diff --git a/client1.py b/client1.py index 2d2d0f2..dd4a3a5 100644 --- a/client1.py +++ b/client1.py @@ -1,13 +1,27 @@ import socket +import threading -HOST = '10.235.1.127' # Enter IP or Hostname of your server +HOST = '10.235.1.145' # Enter IP or Hostname of your server PORT = 12345 # Pick an open Port (1000+ recommended), must match the server port s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((HOST,PORT)) #Lets loop awaiting for your input -while True: - command = input('Enter your command: ') - s.send(bytes(command, 'utf-8')) - reply = s.recv(1024) - print(reply) \ No newline at end of file + +def telemetryReceive(): + while True: + reply = s.recv(1024) + if reply != None: + print(reply) + +def telemetrySend(): + while True: + command = input('Enter your command: ') + if command != None: + s.send(bytes(command, 'utf-8')) + +def main(): + threading.Thread(target=telemetryReceive).start() + threading.Thread(target=telemetrySend).start() + +main() \ No newline at end of file