예제 #1
0
def main(setpoint,ip=None):
    aa=cliente_lib()
    if ip!=None:
       aa.ip=ip
    cliente=aa.cliente_inicio()
    c=gamepad()
    try:
       pipe,msg=c.gamepad_init()
    except:
       aa.Cliente_apaga(cliente)
       exit(1)
    q = Queue() #orden de palanca
    q1 =Queue() #velocidad para el robot
    #anadir info para que tenga datos de trabajo al iniciar
    q.put(1)
    q1.put(-1)
    #comienzo de procesos
    p = Process(target=palanca, args=(c,pipe,msg,q,))
    p1 = Process(target=fuzzy_velocidad, args=(q1,setpoint,aa,cliente,))
    p.start()
    p1.start()
    while 1:
        p1.run()
        #sleep(0.1)
        p.run()
        a=robot_ordenes(q,q1,aa,cliente)
        if a=="r2":
            break
    p1.terminate()
    p.terminate()
    aa.cliente_apaga(cliente)
예제 #2
0
def main(setpoint, ip=None):
    aa = cliente_lib()
    aa.op = 12  #Valores de diccionario de sonares
    if ip != None:
        aa.ip = ip
    cliente = aa.cliente_inicio()
    c = gamepad()
    try:
        pipe, msg = c.gamepad_init()

    except:
        exit()
    fuzzy_vel = [setpoint, ip, aa, cliente]
    palanca = (c, pipe, msg)
    bande = 'ab'
    #p=Process(target=robot_ordenes, args=(palanca,fuzzy_vel,aa,cliente,))
    #p.start()

    while bande != 'r2':
        try:
            #p.run()
            bande = robot_ordenes(palanca, fuzzy_vel, aa, cliente)
            #print bande
        except:
            #bande='r2'
            print "error"
            pass
예제 #3
0
파일: control.py 프로젝트: badanni/cthulhu
def main(setpoint,ip=None):
    aa=cliente_lib()
    aa.op=12 #Valores de diccionario de sonares
    if ip!=None:
        aa.ip=ip
    cliente=aa.cliente_inicio()
    c=gamepad()
    try:
       pipe,msg=c.gamepad_init()
       
    except:
       exit()
    fuzzy_vel=[setpoint,ip,aa,cliente]
    palanca=(c,pipe,msg)
    bande='ab'
    #p=Process(target=robot_ordenes, args=(palanca,fuzzy_vel,aa,cliente,))
    #p.start()
    
    while bande!='r2':
      try:
        #p.run()
        bande=robot_ordenes(palanca,fuzzy_vel,aa,cliente)
        #print bande
      except:
        #bande='r2'
        print "error"
        pass
예제 #4
0
파일: jsTest.py 프로젝트: tbertinojr/pibot
def connect(): # asyncronus read-out of events
        xbox_path = None
        remote_control = None
        devices = [InputDevice(path) for path in list_devices()]
        print('Connecting to xbox controller...')
        for device in devices:
            if str.lower(device.name) == 'xbox wireless controller':
                xbox_path = str(device.path)
                remote_control = gamepad.gamepad(file = xbox_path)
                remote_control.rumble_effect = 2
                return remote_control
        return None
예제 #5
0
def connect():
	xbox_path = None
	remote_control = None
	devices = [InputDevice(path) for path in list_devices()]
	print("[Besse] Connecting to Xbox controller...")
	for device in devices:
		if str.lower(device.name) == "xbox wireless controller":
			xbox_path = str(device.path)
			remote_control = gamepad.gamepad(file = xbox_path)
			remote_control.rumble_effect = 2
			print("[Besse] Connection successful")
			return remote_control
	return None
예제 #6
0
def main(setpoint, ip=None):
    aa = cliente_lib()
    if ip != None:
        aa.ip = ip
    cliente = aa.cliente_inicio()
    c = gamepad()
    try:
        pipe, msg = c.gamepad_init()
    except:
        aa.Cliente_apaga(cliente)
        exit(1)
    q = Queue()  #orden de palanca
    q1 = Queue()  #velocidad para el robot
    #anadir info para que tenga datos de trabajo al iniciar
    q.put(1)
    q1.put(-1)
    #comienzo de procesos
    p = Process(target=palanca, args=(
        c,
        pipe,
        msg,
        q,
    ))
    p1 = Process(target=fuzzy_velocidad, args=(
        q1,
        setpoint,
        aa,
        cliente,
    ))
    p.start()
    p1.start()
    while 1:
        p1.run()
        #sleep(0.1)
        p.run()
        a = robot_ordenes(q, q1, aa, cliente)
        if a == "r2":
            break
    p1.terminate()
    p.terminate()
    aa.cliente_apaga(cliente)
예제 #7
0
import gamepad

from time import sleep
gamepad.init()

fart = gamepad.gamepad()
if fart.button_x == True:
    print('its connected')
    sleep(2)
else:
    print('standby, farting')
    sleep(5)