Exemplo n.º 1
0
Arquivo: eotest.py Projeto: cty12/NAO
def test(IP='127.0.0.1', PORT=9559):

	# init a Motion instance
	motion = Motion(IP, PORT)

	# test code
	imgs = motion.lookAround()
	cnt = 0
	for key in imgs:
		print 'left: ', key.left, '; down: ', key.down
		cv2.imwrite('img' + str(cnt) + '.jpg', imgs[key])
		cnt += 1

	motion.turn(0.2)
	imgs = motion.lookAround()
	for key in imgs:
		print 'left: ', key.left, '; down: ', key.down
		cv2.imwrite('img' + str(cnt) + '.jpg', imgs[key])
		cnt += 1

	del motion
Exemplo n.º 2
0
Arquivo: nao.py Projeto: thunao/nao
#现在只是伪代码,基本不能跑

ip = "127.0.0.1"
test = False
if len(sys.argv) >= 2:
	ip = sys.argv[1]
if len(sys.argv) >= 3:
	test = True
wallthreshold = 500
floorthreshold = 50
headheight = 44.7
topcarmeraheight = 6.364
topcarmeadown = 1.2 /180 * pi

motion = Motion(ip = ip)
movedetermine = MoveDetermine()
target = (0, 0)

while True:
	vote = {}
	points = list()
	if test:
		with open('pics.txt', "r") as ff:
			pics = pickle.load(ff)
	else:
		pics = motion.lookAround()
	(x, y, toward) = motion.getPosition()
	(realx, realy) = movedetermine.mymap.maptorobot(x, y)
	myposition = (x, y)
	movedetermine.mymap.moveto(x, y)
Exemplo n.º 3
0
PORT = 9559

def str2array(string, shape):
	assert len(string) == shape[0] * shape[1] * shape[2], len(shape) == 3
	image = numpy.zeros(shape, numpy.uint8)
	for i in range(0, shape[0]):
		p1 = i * shape[1] * shape[2]
		for j in range(0, shape[1]):
			p2 = j * shape[2]
			for c in range(0, shape[2]):
				p3 = shape[2] - c - 1
				image[i, j, c] = ord(string[p1 + p2 + p3])
	return image

# init a Motion instance
motion = Motion(IP, PORT)

# init window
windowName = "Chessboard"
cv2.namedWindow(windowName, 1)
delay = 1000 / motion.fps

# capture images
while cv2.waitKey(delay) < 0:
	imgstr, shape = motion.takePicture()
	image = str2array(imgstr, shape)
	cv2.imshow(windowName, image)

cv2.destroyAllWindows()

del motion
Exemplo n.º 4
0
#现在只是伪代码,基本不能跑

ip = "127.0.0.1"
test = False
if len(sys.argv) >= 2:
    ip = sys.argv[1]
if len(sys.argv) >= 3:
    test = True
wallthreshold = 500
floorthreshold = 50
headheight = 44.7
topcarmeraheight = 6.364
topcarmeadown = 1.2 / 180 * pi

motion = Motion(ip=ip)
movedetermine = MoveDetermine()
target = (0, 0)

while True:
    vote = {}
    points = list()
    if test:
        with open('pics.txt', "r") as ff:
            pics = pickle.load(ff)
    else:
        pics = motion.lookAround()
    (x, y, toward) = motion.getPosition()
    (realx, realy) = movedetermine.mymap.maptorobot(x, y)
    myposition = (x, y)
    movedetermine.mymap.moveto(x, y)