@asyncio.coroutine def main(r): task = asyncio.ensure_future(find_cubes(r)) try: yield From(asyncio.wait_for(task, SILO_TIME)) except asyncio.TimeoutError: pass yield From(clean_up(r)) if __name__ == "__main__": with TAMProxy() as tamproxy: r = Robot(tamproxy) m = Mapper(r.drive.odometer, map=Arena.load('sw/mapping/red_map.txt')) cam = Camera(geom=constants.camera_geometry, id=CAMERA_ID) v = Vision(cam) c = ControlPanel(r) w = Window(500, [m, CameraPanel(v), c]) while not c.started: pass log.debug("started") loop = asyncio.get_event_loop() loop.set_debug(True) loop.run_until_complete(main(r)) loop.close()
from sw.mapping import Mapper from sw.mapping.arena import Arena from sw.vision import Vision, CameraPanel, Camera from sw.gui import window, ControlPanel from sw.hal import * from sw import constants import pygame import time from tamproxy import TAMProxy if __name__ == "__main__": cam = Camera(geom=constants.camera_geometry, id=1) v = Vision(cam) with TAMProxy() as tamproxy: r = Robot(tamproxy) m = Mapper(r.drive.odometer, map=Arena.load('../sw/mapping/red_map.txt')) w = window.Window( 500, [m, CameraPanel(v), ControlPanel(r) ]) #[Mapper(drive.odometer), CameraPanel(500, v)]) while True: v.update() m.update_cubes_from(v) time.sleep(0.05) pass
import cv2 from tamproxy import TAMProxy from tamproxy.devices import LongIR if __name__ == "__main__": with TAMProxy() as tamproxy: drive = Drive(tamproxy) leftIR = LongIR(tamproxy, pins.l_ir_long) rightIR = LongIR(tamproxy, pins.r_ir_long) left_pid = sw.util.PID(0.1, setpoint=20) right_pid = sw.util.PID(0.1, setpoint=20) m = Mapper(drive.odometer) cam = Camera(geom=sw.constants.camera_geometry, id=0) v = Vision(cam) w = Window(500, [m, CameraPanel(500, v)]) while True: try: v.update() except IOError: continue m.update_cubes_from(v) print "Right: {:.1f}, Left: {:.1f}".format( rightIR.distInches, leftIR.distInches) if leftIR.distInches < 14 and rightIR.distInches < 14: print("corner")