Exemple #1
0
execfile('maps.py')

pygame.init()

time = pygame.time.Clock()
running = 1
stats = ''
naos = []

sockets = [] #RCSS controls agents on a per-socket basis, so let's create a pool of them.

try:
	for i in range(pygame.joystick.get_count()):
		joy = pygame.joystick.Joystick(i)
		if joy.get_name() in maps:
			sockets.append(net.rcSocket(host,port,type=conntype))
			naos.append(Nao(joy,i+1,'Left',sockets[i]))
			print 'Enabled Joystick',joy.get_name(),'For Nao',i+1
		else:
			print 'Joystick',joy.get_name(),'has no map'
except pygame.error:
	print 'No Joysticks found.',pygame.get_error()
	quit()

if conntype == 'tcp':
	recv = net.rcDiscarder(sockets) #rcReceiver reads data from a LIST of sockets.
	recv.start() #it's also a thread, so start it. This is just to keep RCSS
	#accepting our own commands. We don't do anything with the data.

class mainloop(threading.Thread):
	def __init__(self):
Exemple #2
0
#!/usr/bin/python -OO

import net
from pygame import time

# psyco.full()

# r = net.rcReceiver('192.168.212.201')
s = [net.rcSocket()]
r = net.rcReceiver(s)
c = time.Clock()

r.start()
# s.send(net.defaults.initStr+'(he1 -1 0)')

he1 = -2

running = True
# while running == True:
# 	print r.buffer
# 	try:
# 		if he1 < 0:
# 			he1 = 2
# 		else:
# 			he1 = -2
# 		s.send('(he1 '+str(he1)+' 0)')
# 	except KeyboardInterrupt:
# 		r.stop()
# 		r.join()
# 		running = False
# 	c.tick(1)