def my_form_post(): date = request.form['date'] time = request.form['time'] rounds = request.form['rounds'] teams = request.form['teams'] duration = request.form['duration'] byes = request.form['byes'] duration = int(duration) rounds = int(rounds) teams = teams.split() byes = int(byes) driver.driver(date, time, duration, rounds, teams, byes) return app.send_static_file('test.csv')
def resultsOneCL(llkName=None, signal=None, cl=None): out = {} cl2 = 100*cl f = driver(signalToTest=signal, whiteList=signal.categories(), llkName=llkName, ) method = configuration.limit.method() plSeedParams = configuration.limit.plSeedParams(signal.binaryExclusion) fArgs = (cl, cl2, plSeedParams["usePlSeed"]) if method == "nlls": return formattedClsResults(f.nlls(), *fArgs) elif "CLs" in method: if "Custom" in method: results = f.clsCustom(nToys=configuration.limit.nToys(), testStatType=configuration.limit.testStatistic(), ) elif "hcg" in f.note(): results = f.cls() else: results = f.cls(cl=cl, nToys=configuration.limit.nToys(), testStatType=configuration.limit.testStatistic(), calculatorType=configuration.limit.calculatorType(), plSeedParams=plSeedParams, ) out.update(formattedClsResults(results, *fArgs)) else: results = f.interval(cl=cl, method=method, nIterationsMax=10, ) for key, value in results.iteritems(): out["%s%g" % (key, cl2)] = (value, description(key, cl2)) outKey = "excluded%g" % cl2 out[outKey] = (compare(results["upperLimit"], 1.0), "is (%g%% upper limit on XS factor)<1?" % cl2) return out
# lets us ssh/scp files without typing in a pw every time setup_kerb_auth() dir_name = get_time_suffix() if not os.path.exists(dir_name): os.makedirs(dir_name) #setup_index_file() counter = 0 while True: for callsign in callsigns: print('Handling {0}\n'.format(callsign)) aprsfile = 'aprs_{0}_{1}.xml'.format(callsign, dir_name) print(aprsfile) driver(callsign, 7.11, 2000, 1.5, 6, aprsfile, 42.3122, -85.2042) new_file_dir = '{0}/{1}{2:02d}.html'.format(dir_name, callsign, counter) shutil.copyfile('index.html', new_file_dir) print('Pushing {0}.html to caen\n'.format(callsign)) args = ('scp', 'index.html', '[email protected]:Public/html/{0}RAP.html'.format(callsign)) popen = Popen(args).wait() sleep(120) counter += 1
def test_flake(self): c = 4 test = driverClass.driver() o = test.getOutput() self.assertEqual(c, o)
# Similar to CUDA-C: cu_monte_carlo_pricer<<<gridsz, blksz, 0, stream>>> steplist = [cu_step[gridsz, blksz, strm] for gridsz, strm in zip(gridszlist, strmlist)] d_lastlist = [cuda.to_device(paths[s:e, 0], to=mm.get(stream=strm)) for (s, e), strm in zip(partitions, strmlist)] for j in range(1, paths.shape[1]): for prng, d_norm in zip(prnglist, d_normlist): prng.normal(d_norm, mean=0, sigma=1) d_pathslist = [cuda.to_device(paths[s:e, j], stream=strm, to=mm.get(stream=strm)) for (s, e), strm in zip(partitions, strmlist)] for step, args in zip(steplist, zip(d_lastlist, d_pathslist, d_normlist)): d_last, d_paths, d_norm = args step(d_last, d_paths, dt, c0, c1, d_norm) for d_paths, strm, (s, e) in zip(d_pathslist, strmlist, partitions): d_paths.copy_to_host(paths[s:e, j], stream=strm) mm.free(d_last, stream=strm) d_lastlist = d_pathslist for strm in strmlist: strm.synchronize() if __name__ == '__main__': from driver import driver driver(monte_carlo_pricer, pinned=True)
#!/usr/bin/env python import roslib roslib.load_manifest('project_rrt') import rospy from driver import driver if __name__ == '__main__': try: pilot = driver() pilot.drive() except rospy.ROSInterruptException: pass
self._validate_bags(right,'==') return self._same(right) def __ne__(self,right): self._validate_bags(right,'!=') return not self._same(right) @staticmethod def _gen(x): for k,v in x.items(): for i in range(v): yield k def __iter__(self): return Bag._gen(dict(self.counts)) if __name__ == '__main__': import driver driver.driver() if __name__ == '__main__': #Put your own test code here to test Bag before doing bsc tests print('Start simple testing') import driver driver.default_file_name = 'bscp21F19.txt' # driver.default_show_exception =True # driver.default_show_exception_message =True # driver.default_show_traceback =True driver.driver()
def code_metric(file): f = open(file, 'r') l = map(lambda x: (1,x), filter(lambda x: x !=0 ,map(lambda x:len(x.rstrip()), f))) return reduce(lambda x,y: (x[0]+y[0],x[1]+y[1]), l) if __name__=="__main__": import predicate,random,driver from goody import irange driver.driver() # type quit in driver to return and execute code below print('Testing separate') print(separate(predicate.is_positive,[])) print(separate(predicate.is_positive,[1, -3, -2, 4, 0, -1, 8])) print(separate(predicate.is_prime,[i for i in irange(2,20)])) print(separate(lambda x : len(x) <= 3,'to be or not to be that is the question'.split(' '))) print('\nTesting is_sorted') print(is_sorted([])) print(is_sorted([1,2,3,4,5,6,7])) print(is_sorted([1,2,3,7,4,5,6])) print(is_sorted([1,2,3,4,5,6,5])) print(is_sorted([7,6,5,4,3,2,1])) print('\nTesting sort')
def park(X, Y, angle=0): """ Parks the car to the lot. Args: X: bias in x-axis Y: bias in y-axis angle: bias of angle Returns: None """ R = 29.5 # 需要调参,与servo参数相匹配 k = 0.1 k1 = 2 # Y=Y-2; gama = (Y - R * np.sin(angle)) / (X - R - R * np.cos(angle)) X1 = ((X - R - R * np.cos(angle))**2) / (R**2) n = 0 while ((np.abs(k1 - k) / np.abs(k)) > 0.0001) and n < 30: k = k1 FK = k**4 + (8 - X1 * (gama**2 + 1)) * k**2 + (16 - (4 * gama**2 + 4) * X1) F1K = 4 * k**3 + 2 * (8 - X1 * (gama**2 + 1)) * k k1 = k - (FK / F1K) n = n + 1 k = k1 l = k * R tana = (k + 2 * gama) / (gama * k - 2) a = np.arctan(tana) print("a=", a) print("l=", l) print("angle=", angle) # a=np.pi*0 # l=10 if n >= 30: a = 0.995807703453048 l = 6.708203932504121 print("[warning] ----------------no answer------------------------") else: print("----------------- solution found --------------------") dist1f = (a + angle) * R dist2f = l dist3f = a * R dist1 = int(178 * np.abs(dist1f) + 63) dist2 = int(178 * np.abs(dist2f) + 63) dist3 = int(178 * np.abs(dist3f) + 63) sign1 = np.abs(dist1f) / dist1f sign2 = np.abs(dist2f) / dist2f sign3 = np.abs(dist3f) / dist3f kt = 0.35 # 需要调参,将dist转化为时间参数,与motor参数相匹配 time1 = kt * dist1f + 1 time2 = np.abs(kt * dist2f) + 1 time3 = kt * dist3f + 1 time_gap = 0.7 print("distant1=", dist1) print("distant2=", dist2) print("distant3=", dist3) print("distant1f=", dist1f) print("distant2f=", dist2f) print("distant3f=", dist3f) print("inX=", X) print("inY=", Y) print("calX=", R - 2 * R * np.cos(a) + R * np.cos(angle) + l * np.sin(a)) print("calY=", 2 * R * np.sin(a) + R * np.sin(angle) + l * np.cos(a)) motorspeed = -0.05 d = driver.driver() d.setStatus(motor=0, servo=-1, dist=0, mode="distance") time.sleep(1) d.setStatus(motor=motorspeed * sign1, servo=-1, dist=dist1, mode="distance") time.sleep(time1) d.setStatus(motor=0, servo=0, dist=0, mode="distance") time.sleep(time_gap) d.setStatus(motor=motorspeed * sign2, servo=0, dist=dist2, mode="distance") time.sleep(time2) d.setStatus(motor=0, servo=1, dist=0, mode="distance") time.sleep(time_gap) d.setStatus(motor=motorspeed * sign3, servo=1, dist=dist3, mode="distance") time.sleep(time3) d.setStatus(motor=0.0, servo=0.0, dist=0x00, mode="stop") # time.sleep(time_gap); d.close() del d print("==========piCar Client Fin==========")
def cruise(): """ Tracks the black line. Acquires images from front camera and uses it to do pure pursuit. Uses functions in driver.py to drive the pi car. There is a three-step process to reach the goal. Step 1. Employs CameraCapturer class to acquire images from front camera and rectify lens distortion. Step 2. Chooses the ROI and binarizes the it. Then uses morphology method to get the target point. Step 3. According to target point, applies pure pursuit algorithm and uses functions in driver.py to drive the car. Args: None Returns: None """ # Initialize CameraCapturer and drive cap = camera_capturer.CameraCapturer("front") d = driver.driver() d.setStatus(motor=0.4, servo=0, mode="speed") last_time = time.time() target = OFFSET # -int(cap.width / 5) # Parameters of PID controller kp = 1.2 ki = 0 kd = 0.1 # Initialize error to 0 for PID controller error_p = 0 error_i = 0 error_d = 0 error = 0 servo = 0 last_servo = 0 last_angle = 0 n = 0.2 try: while True: this_time = time.time() if this_time - last_time > PERIOD: # Execute the code below every # PERIOD time last_time = this_time # d.setStatus(motor=0, servo=n, mode="speed") # n = -n # continue # ----------------------------------------------------------- # # Start your code here # # Image processing. Outputs a target_point. frame = cap.get_frame() start = time.time() skel, img_bin_rev = image_processing.image_process(frame) white_rate = \ np.size(img_bin_rev[img_bin_rev == 255]) / img_bin_rev.size if white_rate > 0.3: print("stay", white_rate) d.setStatus(servo=last_servo) continue target_point, width, _, img_DEBUG, angle = \ choose_target_point(skel, target) end = time.time() if angle == 0: angle = last_angle pass else: # Update the PID error error_p = angle # **(9/7) error_i += error_p error_d = error_p - error error = error_p # PID controller servo = utils.constrain( -kp * error_p - ki * error_i - kd * error_d, 1, -1) d.setStatus(servo=servo) last_servo = servo # print("servo: ", servo, "error_p: ", error_p) # img_DEBUG[:, target] = 255 # if DEBUG: # # cv.imshow("frame", frame) # cv.imshow("img_bin_rev", img_bin_rev) # cv.imshow("img_DEBUG", img_DEBUG) # cv.waitKey(300) # ----------------------------------------------------------- # else: # time.sleep(0.01) pass except KeyboardInterrupt: d.setStatus(servo=0, motor=0)
result[compare(a[1:], "")] += 1 else: result[compare_one(a[0], b[0])] += 1 result[compare(a[1:], b[1:])] += 1 return sorted(result.items(), key=lambda x: x[1], reverse=True)[0][0] def code_metric(file): pass if __name__ == "__main__": import predicate, random, driver from goody import irange driver.driver() # type quit in driver to return and execute code below print('Testing separate') print(separate(predicate.is_positive, [])) print(separate(predicate.is_positive, [1, -3, -2, 4, 0, -1, 8])) print(separate(predicate.is_prime, [i for i in irange(2, 20)])) print( separate(lambda x: len(x) <= 3, 'to be or not to be that is the question'.split(' '))) print('\nTesting is_sorted') print(is_sorted([])) print(is_sorted([1, 2, 3, 4, 5, 6, 7])) print(is_sorted([1, 2, 3, 7, 4, 5, 6])) print(is_sorted([1, 2, 3, 4, 5, 6, 5])) print(is_sorted([7, 6, 5, 4, 3, 2, 1]))
if hi_link(bl_domains): return hi_link(bl_domains) if hi_link(al_domains): return hi_link(al_domains) if hi_link(gg_domains): return hi_link(gg_domains) return None if __name__ == '__main__': co_name = raw_input('Enter a Company Name: ') webdriver = driver() bl_domains = bloomberg.crawler(co_name, webdriver) gg_domains = google.crawler(co_name, webdriver) #ln_domains = linkedin.crawler(co_name) #Login Redirection issue al_domains = angel.crawler(co_name, webdriver) domain = domain_filter(bl_domains, al_domains, gg_domains) if domain: print 'Company website is ' + domain else: print "Couldn't find the company website" webdriver.quit()
#!/usr/bin/env python import velocity_functions as vf import matplotlib.pyplot as plt import numpy as np from driver import driver H = driver(H0=0.05, H_loc=0.5) H.plot() H.plot('gif')
#!/usr/bin/env python import roslib; roslib.load_manifest('project_rrt') import rospy from driver import driver if __name__ == '__main__': try: pilot = driver() pilot.drive() except rospy.ROSInterruptException: pass
def run_picar(): print("==========piCar Client Start==========") d = driver() d.setStatus(motor=0.0, servo=0.0, dist=0x00, mode="stop") taskmode = 1 cameraswitch = False try: cap = cv2.VideoCapture(1) d.setStatus(mode="speed") last_state = 0 last_servo = 0 count = 0 c, c2 = 0, 0 start = False start2 = False while taskmode == 1: ret, frame = cap.read() if start is False: c += 1 if c < 50: continue else: start = True if ret == True: img = cv2.flip(frame, -1) img2 = img[150:460, 100:639, :] img3 = img[280:460, 100:639, :] circles, img2_h, cimg, img_h = detection.pre_detect(img2) if circles is not None: p = detection.detect(circles, img2, img2_h, cimg, img_h) if p > 0: d.setStatus(motor=0.0, servo=0.0, dist=0x00, mode="stop") print("find stop") taskmode = 2 time.sleep(2) break else: time.sleep(0.1) contours, road, road_found = roads.binary(img3) point_find, pre_pointx, cross_num = points.find_points(road) state, x_final = motion.set_state3(pre_pointx, road_found, cross_num) # my_servo, my_motor = motion.set_sm(state, pre_pointx) # backward state regulation flag = False if state == -1: count += 1 if count < 10: state = last_state flag = True # my_servo = last_servo elif last_state == -1: state = -1 count = 0 if last_state == -1 and state != -1: count = 0 # turning regulation my_servo, my_motor = motion.set_sm3(state, x_final) # print(my_servo,flag) if flag is True: my_servo = last_servo # cv2.drawContours(img, road, -1, (0, 255, 0), 1) if my_servo - last_servo > 0.5: my_servo = last_servo + 0.5 elif my_servo - last_servo < -0.5: my_servo = last_servo - 0.5 d.setStatus(motor=my_motor, servo=my_servo, mode="speed") time.sleep(0.1) print(state, my_servo, my_motor) print(pre_pointx) last_state = state last_servo = my_servo # time.sleep(1) # d.heartBeat() # d.getStatus(sensor=0, mode=0) time.sleep(0.15) if (taskmode == 2) and (cameraswitch is False): cap.release() cap2 = cv2.VideoCapture(0) flagset = 0 stage_in = 1 while taskmode == 2: ret, frame = cap2.read() if start2 is False: c2 += 1 if c2 < 40: continue else: start2 = True if ret == True: img = frame[200:480, :, :] x, y, p1, p2, slope, flag, img2 = parking.find_parking(img, 2) ss, sm, stage = parking.run(x, y, p1, p2, flag, stage_in) stage_in = stage print stage_in d.setStatus(motor=sm, servo=ss, mode="speed") time.sleep(0.4) except KeyboardInterrupt: pass d.setStatus(motor=0.0, servo=0.0, dist=0x00, mode="stop") # cap2.release() d.close() del d print("==========piCar Client Fin==========") return 0
def step(last, dt, c0, c1, noise): return last * math.exp(c0 * dt + c1 * noise) def monte_carlo_pricer(paths, dt, interest, volatility): n = paths.shape[0] blksz = cuda.get_current_device().MAX_THREADS_PER_BLOCK gridsz = int(math.ceil(float(n) / blksz)) # Instantiate cuRAND PRNG prng = PRNG(PRNG.MRG32K3A) # Allocate device side array d_normdist = cuda.device_array(n, dtype=np.double) c0 = interest - 0.5 * volatility ** 2 c1 = volatility * math.sqrt(dt) # Simulation loop d_last = cuda.to_device(paths[:, 0]) for j in range(1, paths.shape[1]): prng.normal(d_normdist, mean=0, sigma=1) d_paths = cuda.to_device(paths[:, j]) step(d_last, dt, c0, c1, d_normdist, out=d_paths) d_paths.copy_to_host(paths[:, j]) d_last = d_paths if __name__ == '__main__': from driver import driver driver(monte_carlo_pricer)
def go(selections=[], options=None, hMap=None): nCategories = 0 report = {} nlls = {} for iSel, sel in enumerate(selections): if options.category and sel.name != options.category: continue if options.system: cmd = ["time", "./test.py"] for item in dir(options): if item.startswith("_"): continue if item in ['read_file', 'read_module', 'ensure_value']: continue if item in ["system", "bestFit"]: continue if item in [ "genBands", "ignoreHad", "interval", "plotBands", "significances", "simultaneous" ]: if getattr(options, item): cmd.append("--%s" % item) elif item == "category": cmd.append("--category=%s" % sel.name) else: cmd.append("--%s=%s" % (item, getattr(options, item))) cmd = " ".join(cmd) print cmd os.system(cmd) continue nCategories += 1 whiteList = [sel.name] if sel.name else [] if options.significances and sel: nlls[sel.name] = significances(whiteList=whiteList, selName=sel.name, options=options) continue f = driver( llkName=options.llk, whiteList=whiteList, ignoreHad=options.ignoreHad, separateSystObs=not options.genBands, #trace=True **signalArgs(whiteList, options)) if options.genBands: f.ensemble(nToys=options.nToys, stdout=True, reuseResults=False) if options.interval: cl = 0.95 if f.likelihoodSpec.standardPoi() else 0.68 print f.interval( cl=cl, method=["profileLikelihood", "feldmanCousins"][0], makePlots=True, ) #f.profile() if options.bestFit: errorsFromToys = options.nToys * bool(options.plotBands) dct = f.bestFit( drawMc=False, drawComponents=False, errorsFromToys=errorsFromToys, printPages=False, drawRatios=False, significance=options.ignoreHad, #msgThreshold=r.RooFit.DEBUG, msgThreshold=r.RooFit.WARNING, ) if dct: report[sel.name] = dct for key, pValue in dct.iteritems(): if key not in hMap: continue hMap[key].GetXaxis().SetBinLabel(1 + iSel, sel.name) hMap[key].SetBinContent(1 + iSel, pValue) #f.qcdPlot() #f.debug() #f.cppDrive(tool="") # #print f.cls(cl=cl, # makePlots=True, # testStatType=3, # nToys=50, # nWorkers=1, # plusMinus={"OneSigma": 1.0, # "TwoSigma": 2.0}, # calculatorType=["frequentist", # "asymptotic", # "asymptoticNom"][1], # #plSeedParams={"usePlSeed": True, # # "plNIterationsMax": 10, # # "nPoints": 7, # # "minFactor": 0.5, # # "maxFactor":2.0}, # plSeedParams={"usePlSeed": True, # "plNIterationsMax": 10, # "nPoints": 10, # "minFactor": 0.0, # "maxFactor":3.0}, # ) # #f.writeMlTable(fileName="mlTables_%s.tex" % "_".join(whiteList), # categories=sorted([x.name for x in selections])) # return nCategories, report, nlls
if err_array[i] != None: err += err_count[i] * err_array[i] return err #对控制数据的范围进行控制(-1,1) def constrain(data): if data >= 1: data = 1 if data <= -1: data = -1 return data d = driver() #实体化类 d.setStatus(motor=0.0, servo=0.0, dist=0x00, mode="stop") speed_P = 1 speed_I = 0 speed_D = 0 speed_err = 0 last_speed_err = 0 speed_err_sum = 0 speed_err_diff = 0 #转向控制部分的参数 steer_P = 2 steer_I = 0 steer_D = 0
if __name__ == '__main__': win_sound = Sound('win.wav') win_sound.play() end_sound = Sound('game_over.wav') start_sound = Sound('start.wav') #load high score #pickle.dump(0,open("score.pk",'wb')) try: high_score = pickle.load(open("score.pk",'rb')) except: high_score = 0 print("high score = %d" % high_score) setup() leds = driver.driver() leds.set_pwm(max_pwm) while True: score = 0 output = "%4d" % high_score leds.update(output) leds.fade(0,max_pwm,length) print("wait for button") GPIO.wait_for_edge(butt,GPIO.FALLING) leds.fade(max_pwm,0,length) cam_thread=cam.CamThread() dot_time = 0.5 #dot intro leds.update(' 4') start_sound.play() leds.set_pwm(max_pwm)
import sys from math import sqrt, exp from timeit import default_timer as timer #from matplotlib import pyplot from numba import jit, double, void if sys.version_info[0] == 2: range = xrange @jit(double[:](double, double[:], double, double, double[:])) def step(dt, prices, c0, c1, noises): return prices * np.exp(c0 * dt + c1 * noises) @jit(void(double[:, :], double, double, double)) def monte_carlo_pricer(paths, dt, interest, volatility): c0 = interest - 0.5 * volatility**2 c1 = volatility * np.sqrt(dt) for j in range(1, paths.shape[1]): prices = paths[:, j - 1] noises = np.random.normal(0., 1., prices.size) paths[:, j] = step(dt, prices, c0, c1, noises) if __name__ == '__main__': from driver import driver driver(monte_carlo_pricer)
def run_picar(): print("==========piCar Client Start==========") d = driver() d.setStatus(motor=0.0, servo=0.0, dist=0x00, mode="stop") t = 10 b = True # d.setStatus(...) # Motor control: # motor = ... # forward 0 -> 1.0 # backward 0 -> -1.0 # Servo control: # servo = ... # left = mid = right # 1.0 = 0.0 = -1.0 # Distance: # dist = ... # 0 -> 0xffffffff # Mode control: # 1:speed # 2:distance # 3:stop # d.getStatus(...) # query mode: # mode = any # sensor = any try: print("Test 1/2: speed mode") d.setStatus(mode="speed") while True: st = t * 0.1 -1 sm = st if abs(st) < 0.4: sm = 0.4 if st > 0 else -0.4 if st == 0: sm = 0 d.setStatus(motor = sm, servo = st) print("Motor: %0.2f, Servo: %0.2f" % (sm, st)) if b: t += 1 else: t -= 1 if t > 20: b = False t -= 2 if t < 0: b = True t += 2 time.sleep(1) # d.heartBeat() d.getStatus(sensor = 0, mode = 0) time.sleep(1) except KeyboardInterrupt: pass try: print("Test 2/2: distance mode") d.setStatus(motor = 0.5, dist = 0x1ff00, mode="distance") while True: ss = t * 0.1 - 1 d.setStatus(servo = ss) print("Servo: %0.2f" % ss) if b: t += 1 else: t -= 1 if t > 20: b = False t -= 2 if t < 0: b = True t += 2 time.sleep(1) d.getStatus(sensor = 0, mode = 0) time.sleep(1) except KeyboardInterrupt: pass d.setStatus(motor=0.0, servo=0.0, dist=0x00, mode="stop") d.close() del d print("==========piCar Client Fin==========") return 0
cmd_args.get_arglist(), queue=queue, name='PO' + logfile.qsubname, resource_list=resource_list, outfile=str(logfile), join=True) #if os.path.isfile(logfile.name): # os.system('grep INTERACTIVE '+logfile.name) else: df = SciFile() df.import_data([file]) from driver import driver cleanup_files = driver(df, currsf, sectorlist=sectorlist, productlist=productlist, forcereprocess=True) log.interactive('\n' + asterisks + '\n') currdatelist = [] day_count = (opass.enddt - opass.startdt).days + 1 for dt in (opass.startdt + timedelta(n) for n in range(day_count)): currdatelist.append(dt.strftime('%Y%m%d')) find_existing_products(sensor, currsf, opass.actualsectornames, productlist, currdatelist, clean=False, forceclean=False)
from datetime import datetime, timedelta from daily_schedule_fetcher import DailyScheduleFetcher from booking import Booking from court_schedule import CourtSchedule from clear import clear import pytz import driver driver = driver.driver() COURT_THREE_URL = 'https://nuevents.neu.edu/CustomBrowseEvents.aspx?data=pw7uNs6e9v8qbfdIsvc5fDYq1MFunilYcWUxDMrP56yKqAjIwwaKA11U%2fQckiFjB2tWbX%2fc8606fDHS3t5PPuSnrcoE8cTQGmAOsO4wdf4ZaUfDtNt1OGQ%3d%3d' COURT_TWO_URL = 'https://nuevents.neu.edu/CustomBrowseEvents.aspx?data=8dCpAXZOtNUwCu7Xw7lFdvnMLXWJvC%2fXnljDAys%2fqmQx5OHc0kgRwku22rLLnqz9V187%2fQc5LcOubs4EolABUmZFwTbc8EyCREjolwr1Ekq69xl3QSidow%3d%3d' SPORT_COURT_URL = 'https://nuevents.neu.edu/CustomBrowseEvents.aspx?data=2sdeuuZ3cxh0hVZgJYA84txwBAjutRyjhYavKNQt%2f1ZU02OX1qeFfxh8QvnmqjnnvPoiPyTnIl8ZtHpxkgfPUK6dvglR7G8DdxFP69QIaS4hyDGPHot7LbGnj5jMFpqD' COURT_SCHEDULE_URLS = [COURT_THREE_URL, COURT_TWO_URL, SPORT_COURT_URL] court_name_to_url_map = { "Main Court": COURT_THREE_URL, "Middle Court": COURT_TWO_URL, "Sport Court": SPORT_COURT_URL } NY_TIMEZONE = pytz.timezone('America/New_York') def get_basketball_courts_summary(): clear() output = '\nMarino Court Schedule\n' court_schedules = fetch_court_schedules_for_today() now = getNow() open_court_count = 0 for court_schedule in court_schedules:
for i in 'kamilSALAKHIEV': tree[ord(i)] = ord(i) # print(tree) # generate_random_million() # plot() # generate_million() #db_test() #db_load_test() # page_test() # page_pair_test() # tree_test() #cursor_test() drv = driver() cur = drv.connect() curs = cur.cursor() curs.execute("SELECT * from student as l1 INNER JOIN student AS l2 ON l1.id^ = l2.id^") print curs.fetchall() curs.execute("SELECT * FroM student WHERE name = Aaron Baker ORDER BY name") print curs.fetchall() #print("Writing to main database file: ") #container = Storage() #container.open_file('storage/student.txt') #container.read(10) #container.seek(40000) #container.read(10) #container.save_all('storage')
# -*- coding: utf-8 -*- """ Created on Thu Jun 21 22:07:07 2018 @author: Dynasting """ from driver import driver import cv2 import numpy as np import math import time dri = driver() flag1 = True flag2 = flag3 = flag4 = False dri.setStatus(motor=0, servo=0, mode="speed") cap = cv2.VideoCapture(1) ret, frame = cap.read() for i in range(15): ret, frame = cap.read() cv2.waitKey(150) while (cap.isOpened()): # read image ret, frame = cap.read() rows, cols, dimension = frame.shape M = cv2.getRotationMatrix2D((cols / 2, rows / 2), 180, 1) img = cv2.warpAffine(frame, M, (cols, rows)) # get hand data from the rectangle sub window on the screen #cv2.rectangle(img, (50,50), (400,500), (0,255,0),0) crop_img = img[50:400, 50:500]
def kc_3f(): d = driver() d.setStatus(motor=0, servo=0, mode="speed") cap = cv2.VideoCapture(1) #open forward camera for i in range(15): #mask pictures with bad light condition ret, frame = cap.read() cv2.waitKey(100) #first stage: following black line sm, st = 0.0, 0.0 last_st = st sharpturn_count = 0 while True: #get real-time image ret, frame = cap.read() #reverse image to get the right perspective rows, cols, dimension = frame.shape M = cv2.getRotationMatrix2D((cols / 2, rows / 2), 180, 1) dst = cv2.warpAffine(frame, M, (cols, rows)) #if the car find the stop sign, then quit "following black line" mode d_sign = readStopSign(dst) if d_sign['detect']: d.setStatus(motor=0.0, servo=0.0, dist=0x00, mode="stop") break #cut out a roi of image around aim point and handle it to a binary image thresh1 = img_process( dst[425:435, :]) # thresh value is 90, need to adjust accordingly thresh2 = img_process( dst[400:410, :]) # thresh value is 90, need to adjust accordingly #cv2.imwrite("thresh.png",thresh) #find center of black line around aim point and control the car accordingly flag1, target_y1 = find_blackline(thresh1, 640, 50) flag2, target_y2 = find_blackline(thresh2, 640, 50) if (flag1 == 0 and flag2 == 0): #formal mode st = standardize(k_p_servo * (320.0 - 0.3 * target_y1 - 0.7 * target_y2) / 320.0) sm = 0.05 elif (flag1 == 1 or flag2 == 1): #crossroad appears thresh = img_process(dst[370:380, :]) flag3, target_y3 = find_blackline(thresh, 640, 50) if (flag3 == 0): st = standardize(k_p_servo * (1 - target_y3 / 320.0)) sm = 0.1 else: st = last_st sm = 0.03 elif (flag2 == 2 or flag1 == 2): #black points is too little,black line is lost st = last_st sm = 0.05 if abs(st) == 1: sharpturn_count += 1 else: sharpturn_count = 0 if sharpturn_count == 7: d.setStatus(motor=-0.05, servo=0) elif sharpturn_count == 8: d.setStatus(motor=0, servo=0) sharpturn_count = 0 else: d.setStatus(motor=sm, servo=st) print "flag1", flag1, "target_y1", target_y1, "flag2", flag2, "target_y2", target_y2 print("Motor: %0.2f, Servo: %0.2f" % (sm, st)) last_st = st time.sleep(0.2) #second stage: move towards the stop sign until the distance between car and sign is small enough while True: ret, frame = cap.read() #reverse image to get the right perspective rows, cols, dimension = frame.shape M = cv2.getRotationMatrix2D((cols / 2, rows / 2), 180, 1) dst = cv2.warpAffine(frame, M, (cols, rows)) d_sign = readStopSign(dst) if not d_sign['error'] and d_sign['detect']: x, y, r = d_sign['x'], d_sign['y'], d_sign['size'] if y >= thresh_y or r >= thresh_r: d.setStatus(motor=0.0, servo=0.0, dist=0x00, mode="stop") break else: st, sm = standsrdize(1.0 - x / 320.0), 0.05 d.setStatus(motor=sm, servo=st, mode="speed") print("Motor: %0.2f, Servo: %0.2f" % (sm, st)) time.sleep(0.5) else: d.setStatus(motor=0, servo=0, mode="stop") #print "error! cann't find the stop sign." cap.release() #third stage: open back camera and park the car to specific garage cap = cv2.VideoCapture(0) #open back camera for i in range(15): #mask pictures with bad light condition ret, frame = cap.read() cv2.waitKey(100) a, b = 1.2, 0.2 check_flag = False last_st = 0 while True: ret, frame = cap.read() result = detectGarage(frame) if not result['error']: if result['stop']: d.setStatus(motor=0.0, servo=0.0, dist=0x00, mode="stop") if not check_flag: check_flag = True time.sleep(0.5) continue else: break if result['status'] == 1: a, b = 1.0, 0.22 else: a, b = 1.3, 0.27 err_p, err_a = result['err_position'], result['err_angle'] #print("err_position: %0.2f, err_angle: %0.2f" % (err_p,err_a)) st = standardize(a * err_p + b * err_a) sm = -0.05 if abs(st - last_st) >= 0.25: sm = 0 d.setStatus(motor=sm, servo=st, mode="speed") print("Motor: %0.2f, Servo: %0.2f" % (sm, st)) last_st = st time.sleep(0.4) else: d.setStatus(motor=0, servo=0, mode="stop") #print "error! cann't find the garage." #finally, stop the car and quit the program d.setStatus(motor=0.0, servo=0.0, dist=0x00, mode="stop") cap.release() cv2.destroyAllWindows() d.close() del d return 0
for i in 'kamilSALAKHIEV': tree[ord(i)] = ord(i) # print(tree) # generate_random_million() # plot() # generate_million() #db_test() #db_load_test() # page_test() # page_pair_test() # tree_test() #cursor_test() drv = driver() cur = drv.connect() curs = cur.cursor() curs.execute( "SELECT * from student as l1 INNER JOIN student AS l2 ON l1.id^ = l2.id^") print curs.fetchall() curs.execute("SELECT * FroM student WHERE name = Aaron Baker ORDER BY name") print curs.fetchall() #print("Writing to main database file: ") #container = Storage() #container.open_file('storage/student.txt') #container.read(10) #container.seek(40000) #container.read(10) #container.save_all('storage')
6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31 } @staticmethod def is_leap_year(year): return (year % 4 == 0 and year % 100 != 0) or year % 400 == 0 @staticmethod def days_in(year, month): return Date.month_dict[month] + (1 if month == 2 and Date.is_leap_year(year) else 0) if __name__ == '__main__': # Put in simple tests for Date before allowing driver to run print() import driver driver.default_file_name = 'bsc1.txt' # driver.default_show_traceback = True # driver.default_show_exception = True # driver.default_show_exception_message = True driver.driver()
def __init__(self): self.__car = driver()
from driver import driver import random import time import pyttsx import voice robot = driver(True) go = True def start_workout(min=5, max=10): number = random.randint(min, max) print(number) voice.say("You are going to do " + str(number) + " pushups") time.sleep(.5) voice.say("Three") time.sleep(1.9) voice.say("Two") time.sleep(1.9) voice.say("One") time.sleep(1.9) voice.say("Go!") #print("This is your robot coach. Lets do some pushups") #min = int(raw_input("Enter the minimum amount of pushups you are willing to do\n")) #max = int(raw_input("Enter the maximum amount of pushups you are willing to do\n")) for i in range(number): robot.forward() time.sleep(.4) robot.stop() robot.backward()
driver.turn_off() delay_func(0.2) driver.update(char) driver.set_pwm(max_bright) delay_func(1.1) driver.fade(max_bright,0,fade_time) if __name__ == '__main__': try: print("starting...") #first time init for raspi if raspi: driver = driver.driver() driver.update('P') driver.fade(0,max_bright,fade_time) driver.fade(max_bright,0,fade_time) driver.fade(0,max_bright,fade_time) driver.fade(max_bright,0,fade_time) while True: #create high score thread t_stop = threading.Event() t = threading.Thread(target=show_highscores, args=(t_stop,)) t.start() #think I need this because the raspi interrupt handler interferes with keyboardinterrupt #wait for button to start game try:
def __init__(self): # pygame init() init() #mixer.init() # Obj utils self.u = game_utils() self.d = driver() self.s = scene(self) self.p = page(self) # self.debug = game_debug(self) # display initialized. self.screen_size = 800, 600 self.screen = display.set_mode(self.screen_size) self.main_title = 'Worm Jumping' self.set_display() # load image self.playarea_image = self.u.load_image('S-3-800x600.png') self.playinfo_image = self.u.load_image('S-3-200x600.png') self.dancing_block_image = self.u.load_image('dancingblock.png', -1) self.key_dancing_image = self.u.load_image('keydancing.png', -1) self.cow_logo_image = self.u.load_image('mgamelogo.png', -1) self.menu_background_image = self.u.load_image('menu_background.png') self.menu_background2_image = self.u.load_image('menu_background2.png') # load sound self.knock_sounds = [ self.u.load_sound('humanbomb.ogg'), self.u.load_sound('shotb.ogg'), self.u.load_sound('laserrocket.ogg') ] self.click_sounds = [ self.u.load_sound('click_1d.ogg'), self.u.load_sound('click_h1.ogg'), self.u.load_sound('clickverb.ogg') ] self.page_sounds = [ self.u.load_sound('book_page_f2.ogg'), self.u.load_sound('book_page_s.ogg'), self.u.load_sound('book_page_f.ogg'), self.u.load_sound('book_page_s2.ogg') ] # load fonts self.game_info_font = font.Font(self.u.load_font('graffiti.ttf'), 36) self.menu_info_font = font.Font(self.u.load_font('graffiti.ttf'), 24) self.game_info_small_font = font.Font(self.u.load_font('station.ttf'), 18) self.sys_font = font.Font(None, 56) # load music self.u.play_music('coco.ogg') # Sprite Group init self.spider_group = sprite.Group() self.block_group = sprite.Group() self.groundblock_group = sprite.Group() self.menu_group = sprite.Group() self.init_base_int() # Set this value for test configure menu. self.config_speed = 170.00 self.config_max = 170.00 self.config_keep = 170.00 self.config_music = 170.00 # page int set. self.NEW_GAME_PAGE = -1 self.GAME_PAGE = 1 self.CONFIGURE_PAGE = 2 self.QUIT_PAGE = 3 self.MAIN_PAGE = 4 # init menus Obj. self.m_m = main_menu(self, self.s.menu_s, self.menu_background_image) self.c_m = configure_menu(self, self.s.menu_s, self.menu_background_image) self.p_m = playing_menu(self, self.s.menu_s, self.menu_background_image) self.c_g_m = configure_game_menu(self, self.s.menu_choicebar_s, self.menu_background2_image) # self.choicebar = choicebar(self, self.s.menu_choicebar_s) self.m_list = []
# -*- coding: utf-8 -*- """ Created on Thu Apr 12 21:25:25 2018 @author: Thinkpad """ import cv2 import numpy as np from driver import driver cap=cv2.VideoCapture(0) d=driver() d.setStatus(mode="speed") #*****************************图像处理部分*********************************** #*************************************************************************** def ImgPro(): #img = cv2.imread("F://testimages//road2.jpg", cv2.IMREAD_COLOR) img=cap.read() cv2.imshow("color", img ) dst=img.copy() size=np.shape(img) height=size[0] width=size[1] grayImg=cv2.cvtColor(dst,cv2.COLOR_BGR2GRAY) #cv2.imshow("grayImg",grayImg) medianImg= cv2.medianBlur(grayImg,3)
def gen(self): fh = open(self.package_name + ".sv", "w") fh.write(self.header.replace("file_name", self.package_name + ".sv")) fh.write("`ifndef _%s_\n" % (self.package_name.upper())) fh.write("`define _%s_\n" % (self.package_name.upper())) fh.write("\n") fh.write("package %s;\n" % (self.package_name)) fh.write(" import uvm_pkg::*;\n") fh.write("\n") fh.write(" `include \"%s.sv\"\n" % (self.defines_name)) fh.write(" `include \"%s.sv\"\n" % (self.config_name)) fh.write(" `include \"%s.sv\"\n" % (self.transaction_name)) fh.write(" `include \"%s.sv\"\n" % (self.config_name)) fh.write(" `include \"%s.sv\"\n" % (self.callback_name)) fh.write(" `include \"%s.sv\"\n" % (self.cov_callback_name)) fh.write(" `include \"%s.sv\"\n" % (self.master_driver_name)) fh.write(" `include \"%s.sv\"\n" % (self.master_sequencer_name)) fh.write(" `include \"%s.sv\"\n" % (self.master_sequence_name)) fh.write(" `include \"%s.sv\"\n" % (self.slave_driver_name)) fh.write(" `include \"%s.sv\"\n" % (self.slave_sequencer_name)) fh.write(" `include \"%s.sv\"\n" % (self.slave_sequence_name)) fh.write(" `include \"%s.sv\"\n" % (self.monitor_name)) fh.write(" `include \"%s.sv\"\n" % (self.master_agent_name)) fh.write(" `include \"%s.sv\"\n" % (self.slave_agent_name)) fh.write("\n") fh.write("endpackage: %s\n" % (self.package_name)) fh.write("\n") fh.write("`endif //_%s_\n" % (self.package_name.upper())) fh.close() #Generate agent components agent_defines = defines.defines(self.header, self.agent_setting) agent_defines.gen() agent_interface = interface.interface(self.header, self.agent_setting) agent_interface.gen() agent_cfg = cfg.cfg(self.header, self.agent_setting) agent_cfg.gen() agent_transaction = transaction.transaction(self.header, self.agent_setting) agent_transaction.gen() agent_sequencer = sequencer.sequencer(self.header, self.agent_setting) agent_sequencer.sequencer_gen() agent_sequence = sequence.sequence(self.header, self.agent_setting) agent_sequence.sequence_gen() agent_drv = driver.driver(self.header, self.agent_setting) agent_drv.master_driver_gen() agent_drv.slave_driver_gen() agent_mon = monitor.monitor(self.header, self.agent_setting) agent_mon.monitor_gen() agent_callback = callback.callback(self.header, self.agent_setting) agent_callback.callback_gen() agent_callback.cov_callback_gen() agent_agent = agent.agent(self.header, self.agent_setting) agent_agent.agent_gen()
def __eq__(self,right): if type(right) is Poly: return self.terms is right.terms elif type(right) in [int, float]: return self.__call__(0) == right if __name__ == '__main__': # Some simple tests; you can comment them out and/or add your own before # the driver is called. # print('Start simple tests') # p = Poly((3,2),(-2,1), (4,0)) # print(' For Polynomial: 3x^2 - 2x + 4') # print(' str(p):',p) # print(' repr(p):',repr(p)) # print(' len(p):',len(p)) # print(' p(2):',p(2)) # print(' list collecting iterator results:',[t for t in p]) # print(' p+p:',p+p) # print(' p+2:',p+2) # print(' p*p:',p*p) # print(' p*2:',p*2) # print('End simple tests\n') import driver #driver.default_show_exception=True #driver.default_show_exception_message=True #driver.default_show_traceback=True driver.driver()
def getvalue(): global tick tick=request.form['symbol'] global p p = driver.driver(tick) return render_template('op.html',output=p)