mirror of
https://github.com/PotentiaRobotics/control-system.git
synced 2025-04-09 22:50:17 -04:00
Add files via upload
This commit is contained in:
parent
4bc2bb1ebf
commit
bb9b2f8874
BIN
Control System/Propioception.pyc
Normal file
BIN
Control System/Propioception.pyc
Normal file
Binary file not shown.
BIN
Control System/__pycache__/Propioception.cpython-37.pyc
Normal file
BIN
Control System/__pycache__/Propioception.cpython-37.pyc
Normal file
Binary file not shown.
BIN
Control System/__pycache__/bootup.cpython-37.pyc
Normal file
BIN
Control System/__pycache__/bootup.cpython-37.pyc
Normal file
Binary file not shown.
BIN
Control System/__pycache__/commands.cpython-37.pyc
Normal file
BIN
Control System/__pycache__/commands.cpython-37.pyc
Normal file
Binary file not shown.
|
@ -6,11 +6,13 @@
|
|||
# 1 for executing the first action in the priority queue
|
||||
|
||||
from Propioception import *
|
||||
from commands import *
|
||||
|
||||
import threading
|
||||
import socket
|
||||
import heapq
|
||||
import time
|
||||
import serial
|
||||
|
||||
class Receiver:
|
||||
def __init__(self, host, port):
|
||||
|
@ -42,31 +44,46 @@ class Receiver:
|
|||
if "Password" in action:
|
||||
heapq.heappush(self.actions,action)
|
||||
print(self.actions)
|
||||
conn.send(action.encode()+bytes(" works",'utf-8'))
|
||||
else:
|
||||
print("Incorrect Command")
|
||||
conn.send(bytes("Incorrect Commandc",'utf-8'))
|
||||
|
||||
# Sending reply
|
||||
conn.send(action.encode()+bytes(" works",'utf-8'))
|
||||
|
||||
|
||||
def execute(self):
|
||||
while len(self.actions) > 0:
|
||||
if self.timer == 0:
|
||||
print("Executed: ", heapq.heappop(self.actions))
|
||||
command = heapq.heappop(self.actions)
|
||||
if command == "Password A_on_LED":
|
||||
if onAndOfffLed():
|
||||
print("Executed: ", command)
|
||||
else:
|
||||
print("Did not execute correctly ", command)
|
||||
|
||||
time.sleep(5)
|
||||
heapq.heappush(self.actions, "Password Balancing")
|
||||
if "Password Balancing" not in self.actions:
|
||||
heapq.heappush(self.actions, "Password Balancing")
|
||||
print("Inside execute",self.actions)
|
||||
|
||||
def sensorData(self):
|
||||
# Test
|
||||
# Read from Arduinos to know what motors and sensors there are
|
||||
print("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)
|
||||
|
||||
def runSimul(self):
|
||||
threading.Thread(target=self.priorityQueue).start()
|
||||
threading.Thread(target=self.execute()).start()
|
||||
threading.Thread(target=self.sensorData()).start()
|
||||
threading.Thread(target=self.execute).start()
|
||||
threading.Thread(target=self.sensorData).start()
|
||||
|
||||
def startBoot():
|
||||
simulation = Receiver('10.235.1.127',12345)
|
||||
simulation = Receiver('10.235.1.148',12345)
|
||||
simulation.runSimul()
|
||||
|
|
BIN
Control System/bootup.pyc
Normal file
BIN
Control System/bootup.pyc
Normal file
Binary file not shown.
24
Control System/commands.py
Normal file
24
Control System/commands.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
# Commands for arduino
|
||||
|
||||
import serial
|
||||
import time
|
||||
|
||||
ser = serial.Serial('/dev/ttyACM0', 9600, timeout=1) # fix
|
||||
ser.reset_input_buffer()
|
||||
|
||||
def onAndOfffLed():
|
||||
ser.write("ON\n".encode('utf-8'))
|
||||
line = ser.readline().decode('utf-8').rstrip()
|
||||
print(line)
|
||||
|
||||
time.sleep(4)
|
||||
|
||||
ser.write("OFF\n".encode('utf-8'))
|
||||
line = ser.readline().decode('utf-8').rstrip()
|
||||
print(line)
|
||||
time.sleep(4)
|
||||
|
||||
if line == "You sent me: OFF":
|
||||
return 1
|
||||
else:
|
||||
return 0
|
|
@ -1,6 +1,6 @@
|
|||
import sys
|
||||
from bootup import *
|
||||
|
||||
|
||||
def main():
|
||||
startBoot() # when Olympian is booted up for first time
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user