def onStart( self ): c = WorldEditor.camera() c.speed = WorldEditor.getOptionFloat( "app/cameraSpeed" ) c.turboSpeed = WorldEditor.getOptionFloat( "app/cameraSpeed2" ) self.alphafunc = Functor.TerrainTextureFunctor() self.guiview = View.AlphaGUITextureToolView( self.alphafunc ) viewmap = "" try: viewmap = WorldEditor.getOptionString( "tools/alphaTool" ) except: pass if viewmap == "": viewmap = "resources/maps/gizmo/disc.bmp" self.alphatool = WorldEditor.Tool( Locator.TerrainToolLocator(), View.TerrainTextureToolView( viewmap ), self.alphafunc ) vismap = "" try: vismap = WorldEditor.getOptionString( "tools/chunkVisualisation" ) except: pass if vismap == "": vismap = "resources/maps/gizmo/square.bmp" self.chunkvis = View.TerrainChunkTextureToolView( vismap ) scv = WorldEditor.getOptionString( "tools/showChunkVisualisation" ) if scv == "true": self.alphatool.addView( self.chunkvis, "chunkVisualisation" ) self.alphatool.addView( self.guiview, "alphaGUI" ) self.guiview.visible = 1 self.alphatool.size = WorldEditor.getOptionFloat( "tools/alphaToolSize" ) self.alphatool.strength = WorldEditor.getOptionFloat( "tools/alphaToolStrength" ) self.heightfunc = Functor.TerrainHeightFilterFunctor() # Create the ecotype tool self.ecotool = WorldEditor.Tool( Locator.TerrainChunkLocator(), View.TerrainChunkTextureToolView( vismap ), Functor.HeightPoleEcotypeFunctor() ); self.ecotool.size = 10000 # Create the object manipulation tool self.objtool = WorldEditor.Tool() self.objtool.functor = Functor.ScriptedFunctor( ChunkItemFunctor( self.objtool, self.objInfo ) ) # Make the closed captions commentary viewer self.cc = GUI.ClosedCaptions( WorldEditor.getOptionInt( "consoles/numMessageLines" ) ) self.onResume( 0 )
def __remove_chunked(self, path: str) -> bool: path = PurePath(path) parent_path = path.parent file_name = path.name recipe_path = parent_path / (file_name + StoreSuffixes.RECIPE_FILE.value) recipe_dest = Locator.locate(recipe_path, self.__store_list) recipe = self.stores[recipe_dest].download_file(recipe_path) chunks = json.loads(recipe.decode())['chunks'] with ThreadPoolExecutor(max_workers=3) as executor: futures = [] for idx in range(chunks): chunk_path = parent_path / (file_name + '.{0}'.format(idx) + StoreSuffixes.CHUNK_FILE.value) chunk_dest = Locator.locate(chunk_path, self.__store_list) futures.append(executor.submit(self.stores[chunk_dest].remove, chunk_path)) self.stores[recipe_dest].remove(recipe_path) return True
def mirror_materials(selected_mtrl): mem = model.member(selected_mtrl[0]._as_tuple[0]) locator = Locator.Locator3D() locator.SetDefaults() orig_point, pt_on_plane, plane_normal, ok = mirror_plane(locator) if ok: try: to_mem = member.MemberLocate( 'Locate member to copy material to or Return to keep on current member: ' ) to_mem.number # to throw an error if user right clicks and selects 'ok' with no selection param.ClearSelection() except: to_mem = mem # if not member is seleced, the material will stay on the original member. if ok: mirror_mtrl = model.MirrorMaterialCopyToMember( selected_mtrl[0], model.member(to_mem.number), pt_on_plane, plane_normal) mirror_offset = ( orig_point - pt_on_plane ) * 2 # gets the offset that MirrorMaterialCopyToMember gives by default mirror_point = orig_point - mirror_offset # gets the corresponding point of the mirrored material mirror_mtrl_idx = mirror_mtrl._as_tuple[2] mirror_xform = Transform3D.Transform3D(to_mem.number, mirror_mtrl_idx) ref_offset = mirror_xform.t - mirror_point # negates any offset from MirrorMaterialCopyToMember such that the second point # will correspond to the original point releative to the mirrored material. if move_mtrl(to_mem, mirror_mtrl, orig_point, locator, ref_offset, mirror_xform): param.RedrawScreen()
def onStart(self): self.cc = GUI.ClosedCaptions( BigBang.opts._consoles._numMessageLines.asInt) self.cc.addAsView() self.cc.visible = 1 self.chunkTool = BigBang.Tool() self.chunkLocator = Locator.OriginLocator() self.chunkViz = View.TerrainChunkTextureToolView( "resources/maps/gizmo/squareTool.dds") self.chunkViz.numPerChunk = 1 self.chunkTool.locator = self.chunkLocator self.chunkTool.addView(self.chunkViz, "chunkViz") self.chunkTool.functor = None self.chunkTool.size = 5000 #2000 m. far plane self.oldFarPlane = BigBang.farPlane() BigBang.farPlane(2000.0) #no fog self.oldFog = BigBang.opts._render._misc._drawFog.asFloat BigBang.opts._render._misc._drawFog.asFloat = self.oldFog #fast camera c = BigBang.camera() self.oldCameraSpeed = c.speed self.oldCameraSpeedTurbo = c.turboSpeed c.speed = 500 c.turboSpeed = 1000 self.onResume(0)
def __init__( self, tool, oi ): # set up the tool we are part of self.mouseLocator = Locator.ChunkItemLocator( Locator.TerrainToolLocator() ) self.mouseRevealer = self.mouseLocator.revealer self.selection = WorldEditor.ChunkItemGroup() self.mouseView = View.ChunkItemBounds( self.mouseRevealer, 0xff0000ff ) self.selView = View.ChunkItemBounds( self.selection, 0xff00ff00 ) tool.locator = self.mouseLocator tool.addView( self.mouseView ) tool.addView( self.selView ) # store a reference to the object info class self.objInfo = oi
def download_maybe_chunked(self, path): parent_path = path.parent file_name = path.name recipe_path = parent_path / (file_name + StoreSuffixes.RECIPE_FILE.value) dest = Locator.locate(recipe_path, self.__store_list) recipe = self.stores[dest].download_file(recipe_path) chunks = json.loads(recipe.decode())['chunks'] data = bytearray() with ThreadPoolExecutor(max_workers=3) as executor: futures = [] for idx in range(chunks): chunk_path = parent_path / (file_name + '.{0}'.format(idx) + StoreSuffixes.CHUNK_FILE.value) dest = Locator.locate(chunk_path, self.__store_list) futures.append(executor.submit(self.stores[dest].download_file, chunk_path)) for idx in range(chunks): data.extend(futures[idx].result()) return data
def upload_file(self, path: str, data) -> bool: path = PurePath(path) parent_path = path.parent file_name = path.name need_chunking = (len(data) > self.__chunking_threshold) if need_chunking: try: dest_name = Locator.locate(path, self.__store_list) self.stores[dest_name].download_file(path) except NoEntryError: idx = 0 with ThreadPoolExecutor(max_workers=3) as executor: futures = [] off = 0 while off < len(data): if (len(data) - off) < (4 * self.MB): sz = len(data) - off else: sz = 4 * self.MB chunk_path = parent_path / (file_name + '.{0}'.format(idx) + StoreSuffixes.CHUNK_FILE.value) chunk_dest = Locator.locate(chunk_path, self.__store_list) futures.append(executor.submit(self.stores[chunk_dest].upload_file, chunk_path, data[off:(off+sz)])) off = off + sz idx = idx + 1 for future in futures: if future.result() is False: return False recipe_path = parent_path / (file_name + StoreSuffixes.RECIPE_FILE.value) recipe_dest = Locator.locate(recipe_path, self.__store_list) recipe = str.encode(json.dumps({'chunks': idx})) self.stores[recipe_dest].upload_file(recipe_path, recipe) else: raise DuplicateEntryError('small file is already there') else: try: recipe_path = parent_path / (file_name + StoreSuffixes.RECIPE_FILE.value) recipe_dest = Locator.locate(recipe_path, self.__store_list) self.stores[recipe_dest].download_file(recipe_path) except NoEntryError: dest_name = Locator.locate(path, self.__store_list) self.stores[dest_name].upload_file(path, data) else: raise DuplicateEntryError('recipe is already there') return True
def download_file(self, path: str) -> bytearray: path = PurePath(path) dest_name = Locator.locate(path, self.__store_list) try: data = self.stores[dest_name].download_file(path) except NoEntryError: data = self.download_maybe_chunked(path) return data
def Execute(start, testCount, TCID): for i in range (start, testCount+start): if ExcelFunc.readData(PathExcelFile, sheetName, i, 1) == TCID: keyword = ExcelFunc.readData(PathExcelFile, sheetName, i, 4) objectName = ExcelFunc.readData(PathExcelFile, sheetName, i, 5) object = Locator.FindObject(objectName, sheetName) data = ExcelFunc.readData(PathExcelFile, sheetName, i, 6) print(keyword, objectName) Perform_Keyword.Execute(keyword, object, data)
def run(bssid_raw): bssid = bssid_raw googleAPI = Locator.GooglePlaces() try: (loc_x, loc_y) = WigleLocation.getCoordinates(bssid) except: (loc_x, loc_y) = googleAPI.get_coordinates(bssid) zillowAPI = Locator.ZillowAPI(loc_x, loc_y) if (zillowAPI.isHouse()): address = googleAPI.get_address(loc_x, loc_y) data = ReverseAddressLookup.sendRequest(address) for resident in data["current_residents"]: for key, val in resident.items(): try: print(key + ": " + val) except: print(key + ": ") if (key == "associated_people"): print([ person["relation"] + ": " + person["name"] for person in val ]) if (key == "historical_addresses"): print([ "%s, %s %s %s, %s" % (address["street_line_1"], address["city"], address["state_code"], address["postal_code"], address["country_code"]) for address in val ]) print() df = googleAPI.get_points_of_interest(loc_x, loc_y) print(df.head())
def __remove(self, path: str) -> bool: path = PurePath(path) dest = Locator.locate(path, self.__store_list) self.stores[dest].remove(path) return True
#Phillips, King #Calls all of the other methods. Note, this will have to be replaced once we start using ROS, but this allows us to get started on the individual parts much more easily from PIL import Image; from freenect import sync_get_depth as get_depth, sync_get_video as get_video; import numpy as np; import Locator,Classifier,Router,Kinect; img=Image.open("Finder1.jpg")#Images will eventually draw from webcam robotPos=Locator.locateRobot(img) targetPos=Locator.locateTarget(img) #(depths,_)=get_depth() #need Kinect hooked up for this to work. Moore, can you create some simulations of the output of this? depths=[[0]*img.size[0] for i in range(img.size[1])] knownHeights=Kinect.getHeights(img,depths,robotPos) drivable=Classifier.getDriveable(img, knownHeights) (dist,waypoints)=Router.getRoute(drivable,robotPos,targetPos)
def locatorTool(self): import Locator reload(Locator) instance = Locator.create_locator() instance.create()
prev=wp cv2.imshow("Route",pic) cv2.waitKey(0) def onTarget(robotPos,targetPos,threshold=30): dist=math.sqrt((robotPos[0]-targetPos[0])**2+(robotPos[1]-targetPos[1])**2) radius=20 camera_port=0 ramp_frames=0 cap = cv2.VideoCapture(0) #targetPos=(180,160) for i in range(20):#Getting rid of first frames of camera because they are unreliable junk,overheadPic=cap.read() targetPos=Locator.getTargetPos(overheadPic) targetPos=map(int, targetPos) print "Target pos: "+str(targetPos) print "Done initializing" rospy.init_node('Driver') posListener=tfListener.tfListener() timeBetweenRelearn=2#Set amount of time to go in between relearning/predicting/routing prevWaypoints=None#Used in case there is no path to target prevDist=-1 while True: Mover.spin() #Spins in circle to gather data for gmapping time.sleep(3) (trans,rot)=posListener.getPos() print "(trans,rot) "+str((trans,rot)) (gmap,gpos, gres)=mapClient.getMapAndPos(trans,rot) #Now marking target as driveable
from selenium.common.exceptions import * from selenium import webdriver import PT_Login import PT_Booking import Perform_Keyword import Locator import ExcelFunc import openpyxl import time PathExcelFile = "C:\\Users\\cheqws133-user\\PyCharmProjects\\Data\\PhpTravels Test Case v3.xlsx" sheetName = "Suites" suiteCount = ExcelFunc.getRowCount(PathExcelFile, sheetName) + 1 for i in range(2, suiteCount): if ExcelFunc.readData(PathExcelFile, sheetName, i, 5) == "Yes": TCID = ExcelFunc.readData(PathExcelFile, sheetName, i, 2) sheetName = ExcelFunc.readData(PathExcelFile, sheetName, i, 4) rowCount = ExcelFunc.getRowCount(PathExcelFile, sheetName) testCount = Locator.CountCase(sheetName, rowCount, TCID) start = Locator.FindRow(sheetName, rowCount, TCID) if sheetName == "Login": PT_Login.Execute(start, testCount, TCID) if sheetName == "Booking": PT_Booking.Execute(start, testCount, TCID) sheetName = "Suites"
import cv2; import Locator; import time; cap = cv2.VideoCapture(0) while(True): ret, frame = cap.read() print "here" pos=Locator.getRobotPos(frame) cv2.imshow("blah",frame) if cv2.waitKey(1) & 0xFF == ord('q'): break cap.release() cv2.destroyAllWindows() """ for i in range(30): ret, frame = cap.read() ret, frame = cap.read() cv2.imwrite('robotPic.png',frame) cap.release() cv2.destroyAllWindows() """
def LocatorTool(self): import Locator reload(Locator) locatorTool = Locator.Locator() locatorTool.CreateUI()
def locatorUI(self): import Locator reload(Locator) locatorTool = Locator.LocatorUI() locatorTool.create()