Compare commits

..

No commits in common. '87449e287ea4e531aff5939f2d5f49fba73de07a' and '071236bc0e72436de659e79cb1e125d6c684b342' have entirely different histories.

@ -2,11 +2,6 @@ import time
import threading
import DobotDllType as dType
import json
import socket, select
import re
from time import sleep
"""
Six actuators:
linear rail
@ -207,7 +202,7 @@ def adjustSpeed(motor, adjustment):
global nowTime, stopTime, currentMotor, speed, motorcfg, movement_time, max_speed, max_movement_time
if currentMotor==motor:
if (adjustment>0 and speed>0) or (adjustment<0 and speed<0):
if (adjustment>0 and speed>0) or (adjustment<0 and speed<0):=
speed += adjustment * 1-(abs(speed)/max_speed)
else:
stopMotorFunctions()
@ -325,110 +320,5 @@ def stop():
#
############################### Chat Parser Section ###############################
with open('/Users/pawel/Documents/Junction2018/twitch_key.json', 'rb') as json_data:
data = json.load(json_data)
primary_stream_key = data["primary_stream_key"]
oauth_key = data["oauth_key"]# bytes('oauth:gcpsl3csq85rf3lk8c1ijzer8deuat', "utf8")
print(primary_stream_key)
print(oauth_key)
HOST = "irc.chat.twitch.tv"
PORT = 6667
PASS = oauth_key
NICK = "TwitchGrabsCandy"
CHAN = "#twitchgrabscandy"
s = socket.socket()
s.connect((HOST, PORT))
s.send("PASS {}\r\n".format(PASS).encode("utf-8"))
s.send("NICK {}\r\n".format(NICK).encode("utf-8"))
s.send("JOIN {}\r\n".format(CHAN).encode("utf-8"))
s.setblocking(0)
queue = []
while True:
response = ""
ready = select.select([s], [], [], 0.1)
if ready[0]:
print("Trying")
response = s.recv(1024).decode("utf-8") # blocking
# print(response)
if re.search("up", response) != None:
queue = queue + ["up"]
if re.search("down", response) != None:
queue = queue + ["down"]
if re.search("go left", response) != None:
queue = queue + ["gleft"]
if re.search("go right", response) != None:
queue = queue + ["gright"]
if re.search("turn left", response) != None:
queue = queue + ["tleft"]
if re.search("turn right", response) != None:
queue = queue + ["tright"]
if re.search("forward", response) != None:
queue = queue + ["forward"]
if re.search("back", response) != None:
queue = queue + ["back"]
if re.search("grasp", response) != None:
queue = queue + ["grasp"]
if re.search("drop", response) != None:
queue = queue + ["drop"]
# checking the motion that is first in the FIFO queue
if len(queue):
if queue[0] == "up":
up()
elif queue[0] == "down":
dn()
elif queue[0] == "gleft":
ll()
elif queue[0] == "gright":
lr()
elif queue[0] == "tleft":
lt()
elif queue[0] == "tright":
rt()
elif queue[0] == "forward":
fw()
elif queue[0] == "back":
bc()
elif queue[0] == "grasp":
grab()
elif queue[0] == "drop":
drop()
else:
print("Something is TERRIBLY wrong!")
print("Location 3")
print(queue)
# removing the first item from queue
queue = queue[1:]
print("Location 4")
print(queue)
sleep(1)

@ -2,11 +2,6 @@ import time
import threading
import DobotDllType as dType
import json
import socket, select
import re
from time import sleep
"""
Six actuators:
linear rail
@ -258,36 +253,27 @@ def updateLoop():
def rt():
adjustSpeed(1, 5)
print("TURNING RIGHT!")
def lt():
adjustSpeed(1, -5)
print("TURNING LEFT!")
def fw():
adjustSpeed(2, 5)
print("GOING FORWARD!")
def bc():
adjustSpeed(2, -5)
print("GOING BACK!")
def up():
adjustSpeed(3, 5)
print("UP!")
def dn():
adjustSpeed(3, -5)
print("DOWN!")
def lr():
adjustSpeed(4, 10)
print("GOING RIGHT!")
def ll():
adjustSpeed(4, -10)
print("GOING LEFT!")
updateLoop()
@ -296,117 +282,13 @@ def stopCmp():
def grab():
candy.gripp()
print("GRASP!")
def drop():
candy.letgo()
print("DROPPING!")
def stop():
candy.panic()
############################### Chat Parser Section ###############################
with open('/Users/pawel/Documents/Junction2018/twitch_key.json', 'rb') as json_data:
data = json.load(json_data)
primary_stream_key = data["primary_stream_key"]
oauth_key = data["oauth_key"]# bytes('oauth:gcpsl3csq85rf3lk8c1ijzer8deuat', "utf8")
print(primary_stream_key)
print(oauth_key)
HOST = "irc.chat.twitch.tv"
PORT = 6667
PASS = oauth_key
NICK = "TwitchGrabsCandy"
CHAN = "#twitchgrabscandy"
s = socket.socket()
s.connect((HOST, PORT))
s.send("PASS {}\r\n".format(PASS).encode("utf-8"))
s.send("NICK {}\r\n".format(NICK).encode("utf-8"))
s.send("JOIN {}\r\n".format(CHAN).encode("utf-8"))
s.setblocking(0)
queue = []
while True:
response = ""
ready = select.select([s], [], [], 0.1)
if ready[0]:
print("Trying")
response = s.recv(1024).decode("utf-8") # blocking
# print(response)
if re.search("up", response) != None:
queue = queue + ["up"]
if re.search("down", response) != None:
queue = queue + ["down"]
if re.search("go left", response) != None:
queue = queue + ["gleft"]
if re.search("go right", response) != None:
queue = queue + ["gright"]
if re.search("turn left", response) != None:
queue = queue + ["tleft"]
if re.search("turn right", response) != None:
queue = queue + ["tright"]
if re.search("forward", response) != None:
queue = queue + ["forward"]
if re.search("back", response) != None:
queue = queue + ["back"]
if re.search("grasp", response) != None:
queue = queue + ["grasp"]
if re.search("drop", response) != None:
queue = queue + ["drop"]
# checking the motion that is first in the FIFO queue
if len(queue):
if queue[0] == "up":
up()
elif queue[0] == "down":
dn()
elif queue[0] == "gleft":
ll()
elif queue[0] == "gright":
lr()
elif queue[0] == "tleft":
lt()
elif queue[0] == "tright":
rt()
elif queue[0] == "forward":
fw()
elif queue[0] == "back":
bc()
elif queue[0] == "grasp":
grab()
elif queue[0] == "drop":
drop()
else:
print("Something is TERRIBLY wrong!")
# removing the first item from queue
queue = queue[1:]
sleep(1)

Loading…
Cancel
Save