def exitCallback():
    global gb, do_exit
    do_exit = True
    if gb != None:
        time.sleep(0.5)
        for address in gnbot_list.keys():
            endRobot(address)
        gb.halt()
        gb = None


atexit.register(exitCallback)

gb = GNBot(gnbot_received_callback, '/dev/ttyUSB0', 9600)

print("Waiting for packets...")

plt.ion()
fig = plt.figure(figsize=(8.0, 8.0))
ax = fig.add_subplot(122)
colors = ['r', 'g', 'b', 'c', 'y']

ax2 = fig.add_subplot(121)

cap = cv2.VideoCapture(0)

width = 1280  #leave None for auto-detection
height = 720  #leave None for auto-detection
cap.set(cv.CV_CAP_PROP_FRAME_WIDTH, width)
示例#2
0
        print("NEW GNBOT ADDED! Address: " + repr(address))
        gnbot_addresses.append(address)
    try:
        IRdistanceCM = mapVals(received_data['IRdistanceCM'], 0.,65535., 0.,150.)
        IMUyaw = mapVals(received_data['IMUyaw'], 0.,65535., -np.pi,np.pi)
        print IMUyaw, IRdistanceCM
        scan_data.append((IMUyaw, IRdistanceCM))
        time_last = time.time()
    except:
        if len(received_data.keys()) > 0:
            print(received_data)
    if len(scan_data) > 0:
        if time.time()-time_last > 2:
            done = True

gb = GNBot(gnbot_received_callback, '/dev/ttyUSB0', 9600)

print("Waiting for packets...")



distance_increment = 20

multi_scans = []

while 1:
    fail = False
    direction = raw_input()
    angle = 0
    if direction == 'l':
        angle = -90
#!/usr/bin/python

import time
from GNBot.GNBot import GNBot

gnbot_addresses = []

def gnbot_received_callback(address, received_data):
	global gb, gnbot_addresses
	if not address in gnbot_addresses:
		print("NEW GNBOT ADDED! Address: " + repr(address))
		gnbot_addresses.append(address)
	else:
		print("Received packet from: " + repr(address))
	print(received_data)

gb = GNBot(gnbot_received_callback, '/dev/ttyUSB0', 9600)

print("Waiting for packets...")

while 1:
	for address in gnbot_addresses:
		values = gb.createValue("motorL", 10)
		values += gb.createValue("motorR", 10)
		values += gb.createValue("delay", 2000)
		values += gb.createValue("motorL", 0)
		values += gb.createValue("motorR", 0)
		gb.sendPUTcommand(address, values)
	time.sleep(5)

import time
from GNBot.GNBot import GNBot

gnbot_addresses = []


def gnbot_received_callback(address, received_data):
    global gb, gnbot_addresses
    if not address in gnbot_addresses:
        print("NEW GNBOT ADDED! Address: " + repr(address))
        gnbot_addresses.append(address)
    else:
        print("Received packet from: " + repr(address))
    print(received_data)


gb = GNBot(gnbot_received_callback, '/dev/ttyUSB0', 9600)

print("Waiting for packets...")

while 1:
    for address in gnbot_addresses:
        values = gb.createValue("motorL", 10)
        values += gb.createValue("motorR", 10)
        values += gb.createValue("delay", 2000)
        values += gb.createValue("motorL", 0)
        values += gb.createValue("motorR", 0)
        gb.sendPUTcommand(address, values)
    time.sleep(5)