def my_stats(csv_file): sql = ("SELECT t1.usr, t1.country, t1.iso FROM " "(SELECT users.uid, users.name AS usr, field_data_field_firstname.field_firstname_value, field_data_field_lastname.field_lastname_value, " "users.mail, from_unixtime(users.created) AS created, from_unixtime(users.login), taxonomy_term_data.name AS country, field_data_field_iso2.field_iso2_value AS iso " "FROM users LEFT JOIN field_data_field_firstname ON field_data_field_firstname.entity_id = users.uid LEFT JOIN field_data_field_lastname ON field_data_field_lastname.entity_id = users.uid " "LEFT JOIN field_data_field_country_mono ON field_data_field_country_mono.entity_id = users.uid " "LEFT JOIN taxonomy_term_data ON taxonomy_term_data.tid = field_data_field_country_mono.field_country_mono_tid " "LEFT JOIN field_data_field_iso2 ON field_data_field_iso2.entity_id = taxonomy_term_data.tid WHERE users.login <> 0) AS t1" ) launcher.launch(sql, cur, csv_file, conn, statfunc=my)
def start_up(bn): try: launcher.launch(bn) build() nginx.reloadNginx() except Exception as e: print "############# Error launching " + bn print(e)
def main(): """Parses a module name and launches a corresponding module.""" logging.basicConfig(level=logging.INFO) parser = argparse.ArgumentParser( prog='launcher', description='Launch a python module or file.') parser.add_argument('module', type=str, help='Either a python file path or a module name.') parser.add_argument('args', nargs=argparse.REMAINDER) args = parser.parse_args() launcher.launch(args.module, args.args)
def compile(root, folder, filepathList): """ Create documentation for given file list """ # Init param fpath = os.path.join(folder, "current") # YUIDoc don't need any exlude: vendor folder and min content are disable by default params = [ "yuidoc", "--outdir", fpath, "--themedir", tmpl, root ] # Run everything (see launcher.py) launch(params)
def compile(root, folder, filepathList): """ Create documentation for given file list """ # Init param fpath = os.path.join(folder, "current") params = [ "jsdoc", "--destination", fpath ] # Bind filepath to parameter for val in filepathList: params.append(val) # Run everything (see launcher.py) launch(params)
def launch_games(args, defaults, description): import os import pipe_ale_interface import logging logging.basicConfig(level=logging.INFO) import time """ Sequential game starter """ games = [ ('tutankham', 'experiments/tutankham_07-24-00-58_0p00025_0p99/') ,('seaquest', 'experiments/seaquest_07-24-01-05_0p00025_0p99/') ,('gopher', 'experiments/gopher_07-24-00-59_0p00025_0p99/') ] for (rom, folder) in games: try: # if one game stops accidentially, it doesn't affect other games logging.info('looking for the last network_file_*** in ' + folder) lst = os.listdir(folder) lst = [f for f in lst if f.startswith('network_file')] lstcouples = [f.split('_')[-1] for f in lst] numbers = [int(f.split('.')[0]) for f in lstcouples] maxnum = max(numbers) nn_file = os.path.join(folder,'network_file_'+str(maxnum)+'.pkl') logging.info('nn_file '+nn_file) # create pipe ALE, which by default is headless ale = pipe_ale_interface.PipeALEInterface(rom=rom) # specify network file defaults.NN_FILE = nn_file defaults.ROM = rom # launch experiment launcher.launch(args, defaults, description, ale) # some kind of miss-architecture in ale-socket place del ale.sl ale.s.close() # necessary because of connection refuse :) seems server does not close connection in time time.sleep(1) except Exception, e: logging.error(str(e))
def compile(name, folder, filepathList): """ Compile a javascript file regarding it's filepath """ # Init param fpath = os.path.join(folder, getOutput()) params = [ "uglifyjs", "-o", fpath % name ] # Bind filepath to parameter for val in filepathList: params.append(val) # Run everything (see launcher.py) launch(params)
def compile(name, folder, filepathList): """ Compile a javascript file regarding it's filepath """ # Init param fpath = os.path.join(folder, getOutput()) params = [ "java", "-jar", "./tools/archive/google-closure.jar", # can also be: ADVANCED_OPTIMIZATIONS "--compilation_level", "SIMPLE_OPTIMIZATIONS", "--js_output_file", fpath % name ] # Bind filepath to parameter for val in filepathList: params.append("--js") params.append(val) # Run everything (see launcher.py) launch(params)
def run_experiment(self, args): try: if self.n_fold <= 0: # no cross validation # reuse dataloader to share underlying dataset -> save memory train_loader = self.train_loader.new(batch_size=args.batch_size, shuffle=not args.no_shuffle) val_loader = self.val_loader.new(batch_size=args.test_batch_size) test_loader = self.test_loader.new(batch_size=args.test_batch_size) result = launcher.launch( args, (train_loader, val_loader, test_loader, self.x_shape, self.out_dim, self.regression)) else: # k-fold cross validation fold_results = [] test_loader = self.test_loader.new(batch_size=args.test_batch_size) args.regression = self.regression for k in range(self.n_fold): t0 = time.time() train_ids, val_ids = self.get_fold_ids(k) train_loader = self.train_loader.subset(train_ids, batch_size=args.batch_size, shuffle=not args.no_shuffle) val_loader = self.train_loader.subset(val_ids, batch_size=args.test_batch_size) fold_result = launcher.launch( args, (train_loader, val_loader, test_loader, self.x_shape, self.out_dim, self.regression)) fold_results.append(fold_result) result = self.mean_dict(fold_results) result['args'] = args result['n_fold'] = self.n_fold result['fold_results'] = fold_results except (AssertionError, RuntimeError, IOError, OverflowError, MemoryError) as error: print('Error:', error, '\nAborting args=', args) result = {'validation_score': float('inf')} result['input_args'] = self.args result['input_args_grid'] = self.args_grid result['input_n_fold'] = self.n_fold return result
def main(): # Get command line arguments parser = argparse.ArgumentParser(description="Run SigMonD Analysis") parser.add_argument( "-c", "--configs", type=str, required=False, metavar='CONFIG-FILE(S)', nargs='+', help= "Run sigmond by using a configuration file specified by CONFIG-FILE") parser.add_argument("-v", "--verbose", action="store_const", dest="loglevel", const=logging.INFO, default=logging.WARNING, help="Sets logging level to INFO") parser.add_argument("-d", "--debug", action="store_const", dest="loglevel", const=logging.DEBUG, default=logging.WARNING, help="Sets logging level to DEBUG") args = parser.parse_args() logging.basicConfig(format='%(levelname)s: %(message)s', handlers=[ExitOnExceptionHandler()], level=args.loglevel) try: launcher.launch(args.configs) except KeyboardInterrupt: print("\n\nGoodbye, {}".format(getpass.getuser())) return
def pg_stats(start, end, csv_file, sql=None): # print type(args) if sql: sql = (sql, {"start": start, "end": end}) else: sql = ( ( "select sum(d.total_records) from occurrence_download d where date(d.created) BETWEEN %(start)s AND %(end)s and d.status = 'SUCCEEDED' AND d.notification_addresses NOT LIKE '*****@*****.**' AND created_by != 'nagios' " "union all " "select count(distinct d.created_by) from occurrence_download d where date(d.created) BETWEEN %(start)s AND %(end)s and d.status = 'SUCCEEDED' AND d.notification_addresses NOT LIKE '*****@*****.**' AND created_by != 'nagios' " "union all " "select count(distinct d.key) from occurrence_download d where date(d.created) BETWEEN %(start)s AND %(end)s and d.status = 'SUCCEEDED' AND d.notification_addresses NOT LIKE '*****@*****.**' AND created_by != 'nagios' " ), {"start": start, "end": end}, ) return launcher.launch(sql, cur, csv_file, conn, statfunc=postgres_stats)
dir = vfh.navigate(goalDir, prevDir) if dir is None: strategy = self.driver.stopG() prevDir = 0.0 else: goal = combinedPose((pose[0], pose[1], pose[2] + dir), (1.0, 0, 0)) strategy = self.driver.goToG( goal, TOLERATED_MISS, angleThreshold=ANGULAR_THRESHOLD, angularSpeed=ANGULAR_SPEED ) prevDir = dir vfh.laserMeasurements = None for (speed, angularSpeed) in strategy: self.robot.setSpeedPxPa(speed, angularSpeed) self.robot.update() pose = self.robot.localisation.pose() isThere = math.hypot(pose[0] - x, pose[1] - y) <= TOLERATED_MISS if isThere or vfh.laserMeasurements is not None: break if __name__ == "__main__": import sys from eduromaxi import EduroMaxi import launcher launcher.launch(sys.argv, EduroMaxi, VFHTest)
phi_length = 1 #num_frames - tipo istorija time #neaiskus CLIP_DELTA = 0 FREEZE_INTERVAL = -1 ##Neural agent epsilon_start = 1.0 epsilon_min = 0.1 epsilon_decay = 1e5 replay_memory_size = 1e3 #sitas nedidelis turi buti 1e3 experiment_prefix = "exper_" replay_start_size = 80 #kiek sukaupia randomu update_frequency = 1 #pvz niekad 30stepu nepadaro be mirimo #epochos ir pan steps_per_epoch = 50 #max minuciu nemirsta; Savaitgaliu nepamirst epochs = 200000 #200 steps_per_test = 300 death_ends_episode = False trainfile = "train_EURUSD_UTC_1 Min_Bid_2014.07.01_2014.11.29.csv" testfile = "test_EURUSD_UTC_1 Min_Bid_2014.11.30_2015.05.07.csv" #nauji test_no_reset = 1 #conda update matplotlib launcher.launch(Defaults)
normalizeAnglePIPI(backHeading - startHeading)) > math.pi / 2) def sonarCheck(): return bool(self.robot.sonar) # Check the sensor information now report('Move:', moveCheck()) report('Laser:', laserCheck()) report('Camera:', cameraCheck()) report('GPS:', gpsCheck()) report('Compass:'******'Sonar:', sonarCheck()) def __performMove(self, strategy, timeout): startTime = self.robot.time for cmd in strategy: self.robot.setSpeedPxPa(*cmd) self.robot.update() if self.robot.time >= startTime + timeout: break if __name__ == '__main__': import sys import eduromaxi import launcher launcher.launch(sys.argv, eduromaxi.EduroMaxi, SystemCheck)
def ver0(self, verbose=False): # Go straight for 2 meters print "ver0", self.robot.battery self.driver.goStraight(2.0, timeout=30) print 'Game over.', self.robot.battery for k in xrange(10): self.robot.setSpeedPxPa(0.0, 0.0) self.robot.update() raise EmergencyStopException( ) # TODO: Introduce GameOverException as in Eurobot def __call__(self): print "RUNNING:", self.code if self.code.startswith("cmd:"): return eval(self.code[4:]) return self.run() if __name__ == "__main__": from eduromaxi import EduroMaxi import launcher launcher.launch(sys.argv, EduroMaxi, SICKRobotDay2016, configFn=setupGripperModule) # vim: expandtab sw=4 ts=4
self.wait(10.0) self.turnLights(on=False) else: print "DIGIT", digit, "FAILURE -> repeat" self.driver.stop() self.driver.goStraight(-0.2) self.turnWithWatchdog( math.radians(self.random(10, 180)), angularSpeed=math.radians(40)) print 'Game over.', self.robot.battery for k in xrange(10): self.robot.setSpeedPxPa(0.0, 0.0) self.robot.update() raise EmergencyStopException( ) # TODO: Introduce GameOverException as in Eurobot def __call__(self): print "RUNNING:", self.code if self.code.startswith("cmd:"): return eval(self.code[4:]) return self.run() if __name__ == "__main__": # code = sys.argv[1] ... i.e. 123456789 or 876543210 or some other combinations for test from eduromaxi import EduroMaxi import launcher launcher.launch(sys.argv, EduroMaxi, SICKRobotDay2014, configFn=setupHandModule)
sa = max( -0.1, min( 0.1, -errA/2.0 ))*1.35*(desiredSpeed/0.4) # originally set for 0.4=OK # print "%0.2f\t%d\t%0.2f\t%0.2f\t%0.2f" % (errY, int(math.degrees(errA)), drone.vy, sy, sa) prevTime = drone.time drone.moveXYZA( sx, sy, sz, sa ) maxControlGap = max( drone.time - prevTime, maxControlGap ) poseHistory.append( (drone.time, (drone.coord[0], drone.coord[1], drone.heading), (drone.angleFB, drone.angleLR), altitude) ) print "NAVI-OFF", drone.time - startTime drone.hover(0.5) drone.land() drone.setVideoChannel( front=True ) except ManualControlException, e: print "ManualControlException" if drone.ctrlState == 3: # CTRL_FLYING=3 ... i.e. stop the current motion drone.hover(0.1) drone.land() drone.wait(1.0) drone.stopVideo() print "MaxVideoDelay", maxVideoDelay print "MaxControlGap", maxControlGap print "Battery", drone.battery if __name__ == "__main__": if len(sys.argv) > 2 and sys.argv[1] == "img": imgmain( sys.argv[1:], processFrame ) sys.exit( 0 ) import launcher launcher.launch( sys.argv, RobotemRovneDrone, competeRobotemRovne )
self.robot.attachGPS() self.robot.attachLaser() cameraURL = params['url'] if 'url' in params else camera.DEFAULT_URL self.robot.attachCamera(cameraExe='cat', url=cameraURL) self.robot.addExtension(emergencyStopExtension) self.robot.addExtension(displayGpsStatusExtension) self.robot.localisation = SimpleOdometry() def __call__(self): joy = Joy() MaxSpeed = 0.6 AScale = 1. try: self.robot.gps.start() self.robot.laser.start() self.robot.camera.start() while 1: joy.update() self.robot.setSpeedPxPa(joy.Speed * MaxSpeed, -joy.Angle * AScale) self.robot.update() except EmergencyStopException, e: print "EmergencyStopException" self.robot.gps.requestStop() self.robot.laser.requestStop() self.robot.camera.requestStop() if __name__ == "__main__": launcher.launch(sys.argv, EduroMaxi, Joydrive)
""" Lesson 4 - fly forward """ import sys sys.path.append('..') # access to drone source without installation from ardrone2 import ARDrone2, ManualControlException def testLesson4( drone ): try: drone.takeoff() startTime = drone.time while drone.time - startTime < 2.0: sx, sy, sz, sa = 0.1, 0.0, 0.0, 0.0 drone.moveXYZA( sx, sy, sz, sa ) except ManualControlException, e: print "ManualControlException" if drone.ctrlState == 3: # CTRL_FLYING=3 ... i.e. stop the current motion drone.hover(0.1) drone.land() print "Battery", drone.battery if __name__ == "__main__": import launcher launcher.launch( sys.argv, ARDrone2, testLesson4 ) # vim: expandtab sw=4 ts=4
return self.robot.compass is not None and abs(normalizeAnglePIPI(backHeading - startHeading)) > math.pi / 2 def sonarCheck(): return bool(self.robot.sonar) # Check the sensor information now report("Move:", moveCheck()) report("Laser:", laserCheck()) report("Camera:", cameraCheck()) report("GPS:", gpsCheck()) report("Compass:"******"Sonar:", sonarCheck()) def __performMove(self, strategy, timeout): startTime = self.robot.time for cmd in strategy: self.robot.setSpeedPxPa(*cmd) self.robot.update() if self.robot.time >= startTime + timeout: break if __name__ == "__main__": import sys import eduromaxi import launcher launcher.launch(sys.argv, eduromaxi.EduroMaxi, SystemCheck)
pose = robot.localisation.pose() print "%.3f %.3f 0" % pose[0:2] for i in xrange(541): a = math.radians((i - 270) / 2.0) d = data[i] / 1000.0 if data[i] > 0: x = d * math.cos(a) # tilted y = d * math.sin(a) heading = pose[2] ch = math.cos(heading) sh = math.sin(heading) print "%.3f %.3f %.3f" % (pose[0] + ch * ct * x - sh * y, pose[1] + ch * y + sh * ct * x, st * x + 0.3) # if self.limit > 0: # self.limit -= 1 # else: # sys.exit(1) def __call__(self): # DO NOTHING ... just parse data available in parseLaserExtension while 1: self.robot.update() from eduromaxi import EduroMaxi import launcher if __name__ == "__main__": launcher.launch(sys.argv, EduroMaxi, Laser3D)
drone.hover(2.0) stage += 1 realDistance=0 print math.hypot(x-newX,y-newY) newX = drone.coord[0] newY = drone.coord[1] #GPS printing print "Byla dosazena pozadovana vzdalenost" print "GPS coordinates: ", drone.gps if(drone.gps is not None): lat = drone.gps[0] lon = drone.gps[1] print lat, lon drone.hover(2.0) except ManualControlException, e: print "ManualControlException" drone.land() print "Battery landing: ", drone.battery if __name__ == "__main__": import launcher launcher.launch( sys.argv, ARDrone2, gps_gather2 ) # vim: expandtab sw=4 ts=4
# start GPS sooner to get position fix self.robot.gps.start() self.robot.laser.start() self.waitForStart() self.robot.camera.start() print "battery:", self.robot.battery startTime = self.robot.time while True: self.robot.setSpeedPxPa( 0.0, 0.0 ) self.robot.update() except EmergencyStopException, e: print "EmergencyStopException" print "battery:", self.robot.battery self.robot.camera.requestStop() self.robot.gps.requestStop() self.robot.laser.requestStop() def __call__( self ): print "OSGAR RUNNING:", self.configFilename if self.configFilename.startswith("cmd:"): return eval( self.configFilename[4:] ) return self.ver0() from eduromaxi import EduroMaxi import launcher if __name__ == "__main__": launcher.launch( sys.argv, EduroMaxi, Osgar, configFn=setupHandModule ) # vim: expandtab sw=4 ts=4
A2 = combinedPose( (A[0], A[1], line.angle), (0, offset, 0) ) B2 = combinedPose( (B[0], B[1], line.angle), (2.0, offset, 0) ) line = Line(A2, B2) viewlog.dumpBeacon( A[:2], color=(200,0,0) ) viewlog.dumpBeacon( B[:2], color=(200,128,0) ) viewlog.dumpBeacon( A2[:2], color=(255,0,0) ) viewlog.dumpBeacon( B2[:2], color=(255,128,0) ) if len(ends) > num + 1: break else: print "BACKUP solution!!!" goal = combinedPose( self.robot.localisation.pose(), (1.0, 0, 0) ) line = Line( self.robot.localisation.pose(), goal ) def __call__( self ): print "RUNNING:", self.configFilename if self.configFilename.startswith("cmd:"): return eval( self.configFilename[4:] ) # return self.ver2([-1,1]*10, detectWeeds = False, detectBlockedRow = False) # Task1 # return self.ver2( [-3,1,-2,-3,5], detectWeeds = False, detectBlockedRow = True ) # Task2 S-3L-1R-2L-3L-5R-F return self.ver2([-2,2,0], detectWeeds = True, detectBlockedRow = False) # Task3 from eduromaxi import EduroMaxi import launcher if __name__ == "__main__": launcher.launch(sys.argv, EduroMaxi, FieldRobot, configFn=setupHandModule)
# ---------------------- BASE_ROM_PATH = "../roms/" ROM = 'SUMO' FRAME_SKIP = 4 # ---------------------- # Agent/Network parameters: # ---------------------- UPDATE_RULE = 'rmsprop' BATCH_ACCUMULATOR = 'mean' LEARNING_RATE = .0002 DISCOUNT = .95 RMS_DECAY = .99 # (Rho) RMS_EPSILON = 1e-6 MOMENTUM = 0 EPSILON_START = 1.0 EPSILON_MIN = .1 EPSILON_DECAY = 1000000 PHI_LENGTH = 1 UPDATE_FREQUENCY = 1 REPLAY_MEMORY_SIZE = 1000000 BATCH_SIZE = 32 NETWORK_TYPE = "nips_dnn" FREEZE_INTERVAL = -1 REPLAY_START_SIZE = 100 IMAGE_RESIZE = 'crop' if __name__ == "__main__": launcher.launch(sys.argv[1:], Defaults, __doc__, traffic_situation='simpleT')
#GPS printing print "Byla dosazena pozadovana vzdalenost" print "GPS coordinates: ", drone.gps if(drone.gps is not None): lat = drone.gps[0] lon = drone.gps[1] print lat, lon drone.hover(2.0) except ManualControlException, e: print "ManualControlException" drone.land() print "Battery landing: ", drone.battery # nefungovalo - nemohu volat float def distanceGPS(s1, d1, s2, d2): # Return value in meters distanceGPS=math.acos(math.cos(math.radians(90-s1))*math.cos(math.radians(90-s2))+math.sin(math.radians(90-s1))*math.sin(math.radians(90-s2))*math.cos(math.radians(d1-d2)))*6371 print "!!!!!!!!!!!!!!!!!!!!! TESTOVACI HODNOTA1 ", distanceGPS*1000 return distanceGPS if __name__ == "__main__": import launcher launcher.launch( sys.argv, ARDrone2, gps_distance ) # vim: expandtab sw=4 ts=4
sx=0 drone.hover(2.0) startTime = drone.time while drone.time - startTime < 3.0: sa = 0.1 drone.moveXYZA(sx, sy, sz, sa) sa=0 drone.hover(2.0) except ManualControlException, e: print "ManualControlException" if drone.ctrlState == 3: # CTRL_FLYING=3 ... i.e. stop the current motion drone.hover(1.0) drone.land() x,y,z = drone.coord e=math.hypot(x,y) print e print "Battery", drone.battery print "pozice", drone.coord if __name__ == "__main__": import launcher launcher.launch( sys.argv, ARDrone2, testLesson4_uprava ) # vim: expandtab sw=4 ts=4
# ---------------------- BASE_ROM_PATH = "../roms/" ROM = 'SUMO_FIXED' FRAME_SKIP = 4 # ---------------------- # Agent/Network parameters: # ---------------------- UPDATE_RULE = 'rmsprop' BATCH_ACCUMULATOR = 'mean' LEARNING_RATE = .0002 DISCOUNT = .95 RMS_DECAY = .99 # (Rho) RMS_EPSILON = 1e-6 MOMENTUM = 0 EPSILON_START = 1.0 EPSILON_MIN = .1 EPSILON_DECAY = 1000000 PHI_LENGTH = 1 UPDATE_FREQUENCY = 1 REPLAY_MEMORY_SIZE = 1000000 BATCH_SIZE = 32 NETWORK_TYPE = "nips_cuda" FREEZE_INTERVAL = -1 REPLAY_START_SIZE = 100 IMAGE_RESIZE = 'crop' if __name__ == "__main__": launcher.launch(sys.argv[1:], Defaults, __doc__, 'fixed')
drone.poseHistory = [] print "NAVI-ON" startTime = drone.time # maxControlGap = stayAtPosition( drone, desiredHeight=desiredHeight, timeout=30.0 ) maxControlGap = followRow( drone, desiredHeight=desiredHeight, timeout=25.0 ) lastUpdate = None print "NAVI-OFF", drone.time - startTime drone.hover(0.5) drone.land() drone.setVideoChannel( front=True ) except ManualControlException, e: print "ManualControlException" if drone.ctrlState == 3: # CTRL_FLYING=3 ... i.e. stop the current motion drone.hover(0.1) drone.land() drone.wait(1.0) drone.stopVideo() # print "MaxVideoDelay", maxVideoDelay print "MaxControlGap", maxControlGap print "Battery", drone.battery if __name__ == "__main__": if len(sys.argv) > 2 and sys.argv[1] == "img": imgmain( sys.argv[1:], processFrame ) sys.exit( 0 ) import launcher launcher.launch( sys.argv, FieldRobotDrone, competeFieldRobot )
except EmergencyStopException, e: print "EmergencyStopException" robot.camera.requestStop() robot.laser.requestStop() class Spinner: def __init__(self, robot, configFile=None, verbose = False): self.robot = robot self.verbose = verbose MAX_ACC = 1.4 self.robot.maxAcc = MAX_ACC self.robot.attachLaser() self.robot.attachCamera( cameraExe = "../robotchallenge/redcone" ) self.robot.addExtension( emergencyStopExtension ) def __call__(self): ver0(self.robot, self.verbose) from eduromaxi import EduroMaxi import launcher if __name__ == "__main__": if len(sys.argv) < 2: print __doc__ sys.exit(-1) launcher.launch(sys.argv, EduroMaxi, Spinner)
# print "%0.2f\t%d\t%0.2f\t%0.2f\t%0.2f" % (errY, int(math.degrees(errA)), drone.vy, sy, sa) prevTime = drone.time drone.moveXYZA(sx, sy, sz, sa) maxControlGap = max(drone.time - prevTime, maxControlGap) poseHistory.append( (drone.time, (drone.coord[0], drone.coord[1], drone.heading), (drone.angleFB, drone.angleLR), altitude)) print "NAVI-OFF", drone.time - startTime drone.hover(0.5) drone.land() drone.setVideoChannel(front=True) except ManualControlException, e: print "ManualControlException" if drone.ctrlState == 3: # CTRL_FLYING=3 ... i.e. stop the current motion drone.hover(0.1) drone.land() drone.wait(1.0) drone.stopVideo() print "MaxVideoDelay", maxVideoDelay print "MaxControlGap", maxControlGap print "Battery", drone.battery if __name__ == "__main__": if len(sys.argv) > 2 and sys.argv[1] == "img": imgmain(sys.argv[1:], processFrame) sys.exit(0) import launcher launcher.launch(sys.argv, RobotemRovneDrone, competeRobotemRovne)
""" Lesson 4 - fly forward """ import sys sys.path.append('..') # access to drone source without installation from ardrone2 import ARDrone2, ManualControlException def testLesson4(drone): try: drone.takeoff() startTime = drone.time while drone.time - startTime < 2.0: sx, sy, sz, sa = 0.1, 0.0, 0.0, 0.0 drone.moveXYZA(sx, sy, sz, sa) except ManualControlException, e: print "ManualControlException" if drone.ctrlState == 3: # CTRL_FLYING=3 ... i.e. stop the current motion drone.hover(0.1) drone.land() print "Battery", drone.battery if __name__ == "__main__": import launcher launcher.launch(sys.argv, ARDrone2, testLesson4) # vim: expandtab sw=4 ts=4
import os, sys, ConfigParser, time start = time.time() # Read the configuration file. config = ConfigParser.SafeConfigParser(os.environ) config.read(['../parm/bwrf.conf']) # Add the scripts directory to the system path # and import the modules. SCRIPTSbwrf = config.get("DEFAULT", "SCRIPTSbwrf") sys.path.append(SCRIPTSbwrf) import launcher, inputs, wps, forecast, post, publish # Run the bWRF system. launcher.launch(config) input_start = time.time() inputs.init_input(config) inputs.run_input(config) print("Total time in input: ", (time.time() - input_start) / 60.0, " minutes") wps_start = time.time() wps.init_wps(config) wps.run_geogrid(config) wps.run_ungrib(config) wps.run_metgrid(config) print("Total time in wps: ", (time.time() - wps_start) / 60.0, " minutes") fcst_start = time.time() forecast.init_wrf(config)
print "EmergencyStopException" robot.camera.requestStop() robot.gps.requestStop() robot.laser.requestStop() class FollowMe: def __init__(self, robot, configFile=None, verbose=False): self.robot = robot self.verbose = verbose MAX_ACC = 1.4 self.robot.maxAcc = MAX_ACC # self.robot.attachGPS() self.robot.attachLaser() # self.robot.attachCamera() self.robot.attachCamera(cameraExe="../robotchallenge/rc") self.robot.addExtension(emergencyStopExtension) def __call__(self): ver0(self.robot, self.verbose) from eduromaxi import EduroMaxi import launcher if __name__ == "__main__": if len(sys.argv) < 2: print __doc__ sys.exit(-1) launcher.launch(sys.argv, EduroMaxi, FollowMe)
print "EmergencyStopException" robot.camera.requestStop() robot.gps.requestStop() robot.laser.requestStop() class FollowMe: def __init__(self, robot, configFile=None, verbose = False): self.robot = robot self.verbose = verbose MAX_ACC = 1.4 self.robot.maxAcc = MAX_ACC # self.robot.attachGPS() self.robot.attachLaser() # self.robot.attachCamera() self.robot.attachCamera( cameraExe = "../robotchallenge/rc" ) self.robot.addExtension( emergencyStopExtension ) def __call__(self): ver0(self.robot, self.verbose) from eduromaxi import EduroMaxi import launcher if __name__ == "__main__": if len(sys.argv) < 2: print __doc__ sys.exit(-1) launcher.launch(sys.argv, EduroMaxi, FollowMe)
type=int, default=1, metavar='S', help='Random seed, set to make the result reproducible. 0=disabled.') # Other params parser.add_argument( '--save-result', type=int, default=1, metavar='SR', help= 'SR = 0 | 1 | 2. 0: no saving. 1: save log file. 2: save log and best model.' ) parser.add_argument( '--verbose', type=int, default=3, metavar='V', help='Level of verbose: 0 (silent), 1 (warning), 2 (info), ' '3 (model:summary), 4 (model:warning), 5 (model:details), 6 (model:debug).' ) args = parser.parse_args() args.no_cuda = True args.algorithm = 'misc' args.optimizer = 'rforest' result = launch(args)
self.robot.camera.start() self.robot.rfu620.start() self.robot.localisation = SimpleOdometry() while True: # self.ver0(verbose = self.verbose) self.ver1(verbose = self.verbose) # self.test_line(verbose = self.verbose) except EmergencyStopException, e: print "EmergencyStopException at {} sec".format(self.robot.time - self.start_time) gripperDisableServos(self.robot.can) self.robot.laser.requestStop() self.robot.rfu620.requestStop() self.robot.camera.requestStop() def __call__( self ): print "RUNNING:", self.code if self.code.startswith("cmd:"): return eval(self.code[4:]) return self.run() if __name__ == "__main__": from eduromaxi import EduroMaxi import launcher launcher.launch(sys.argv, EduroMaxi, SICKRobotDay2016, configFn=setupGripperModule) # vim: expandtab sw=4 ts=4
DISCOUNT = .99 RMS_DECAY = .95 # (Rho) RMS_EPSILON = .01 MOMENTUM = 0 # Note that the "momentum" value mentioned in the Nature # paper is not used in the same way as a traditional momentum # term. It is used to track gradient for the purpose of # estimating the standard deviation. This package uses # rho/RMS_DECAY to track both the history of the gradient # and the squared gradient. CLIP_DELTA = 1.0 EPSILON_START = 1.0 EPSILON_MIN = .1 EPSILON_DECAY = 1000000 PHI_LENGTH = 4 UPDATE_FREQUENCY = 4 REPLAY_MEMORY_SIZE = 1000000 BATCH_SIZE = 32 NETWORK_TYPE = "nature_cpu" FREEZE_INTERVAL = 10000 REPLAY_START_SIZE = 50000 RESIZE_METHOD = 'scale' RESIZED_WIDTH = 84 RESIZED_HEIGHT = 84 DEATH_ENDS_EPISODE = 'true' MAX_START_NULLOPS = 30 DETERMINISTIC = True CUDNN_DETERMINISTIC = False if __name__ == "__main__": launcher.launch(sys.argv[1:], Defaults, __doc__)
B2 = combinedPose((B[0], B[1], line.angle), (2.0, offset, 0)) line = Line(A2, B2) viewlog.dumpBeacon(A[:2], color=(200, 0, 0)) viewlog.dumpBeacon(B[:2], color=(200, 128, 0)) viewlog.dumpBeacon(A2[:2], color=(255, 0, 0)) viewlog.dumpBeacon(B2[:2], color=(255, 128, 0)) if len(ends) > num + 1: break else: print "BACKUP solution!!!" goal = combinedPose(self.robot.localisation.pose(), (1.0, 0, 0)) line = Line(self.robot.localisation.pose(), goal) def __call__(self): print "RUNNING:", self.configFilename if self.configFilename.startswith("cmd:"): return eval(self.configFilename[4:]) # return self.ver2([-1,1]*10, detectWeeds = False, detectBlockedRow = False) # Task1 # return self.ver2( [2,-1,0,-2,3,2,0], detectWeeds = False, detectBlockedRow = True ) # Task2 S-2R-1L-0-2L-3R-2R-F return self.ver2([-2, 2] * 10, detectWeeds=True, detectBlockedRow=False) # Task3 from eduromaxi import EduroMaxi import launcher if __name__ == "__main__": launcher.launch(sys.argv, EduroMaxi, FieldRobot, configFn=setupHandModule)
""" Lesson 3 - logging examples """ import sys sys.path.append('..') # access to drone source without installation from ardrone2 import ARDrone2, ManualControlException def drone_reset( drone ): try: if(drone.ctrlState==0): drone.reset() except ManualControlException, e: print "ManualControlException" drone.land() print "Battery landing: ", drone.battery if __name__ == "__main__": import launcher launcher.launch( sys.argv, ARDrone2, drone_reset ) # vim: expandtab sw=4 ts=4
# ---------------------- UPDATE_RULE = 'deepmind_rmsprop' BATCH_ACCUMULATOR = 'sum' LEARNING_RATE = .00025 DISCOUNT = .99 RMS_DECAY = .95 # (Rho) RMS_EPSILON = .01 DEPTH = 3 MOMENTUM = 0 # Note that the "momentum" value mentioned in the Nature # paper is not used in the same way as a traditional momentum # term. It is used to track gradient for the purpose of # estimating the standard deviation. This package uses # rho/RMS_DECAY to track both the history of the gradient # and the squared gradient. CLIP_DELTA = 1.0 EPSILON_START = 1.0 EPSILON_MIN = .1 EPSILON_DECAY = 1000000 UPDATE_FREQUENCY = 1 REPLAY_MEMORY_SIZE = 1000000 BATCH_SIZE = 128 NETWORK_TYPE = "go_dnn_3" FREEZE_INTERVAL = 10000 REPLAY_START_SIZE = 1000 DETERMINISTIC = True CUDNN_DETERMINISTIC = False if __name__ == "__main__": launcher.launch([], Defaults, __doc__)
print "NAVI-ON" startTime = drone.time # maxControlGap = stayAtPosition( drone, desiredHeight=desiredHeight, timeout=30.0 ) maxControlGap = followRow(drone, desiredHeight=desiredHeight, timeout=25.0) lastUpdate = None print "NAVI-OFF", drone.time - startTime drone.hover(0.5) drone.land() drone.setVideoChannel(front=True) except ManualControlException, e: print "ManualControlException" if drone.ctrlState == 3: # CTRL_FLYING=3 ... i.e. stop the current motion drone.hover(0.1) drone.land() drone.wait(1.0) drone.stopVideo() # print "MaxVideoDelay", maxVideoDelay print "MaxControlGap", maxControlGap print "Battery", drone.battery if __name__ == "__main__": if len(sys.argv) > 2 and sys.argv[1] == "img": imgmain(sys.argv[1:], processFrame) sys.exit(0) import launcher launcher.launch(sys.argv, FieldRobotDrone, competeFieldRobot)
maxVideoDelay = max( videoDelay, maxVideoDelay ) toDel = 0 for oldTime, oldPose, oldAngles, oldAltitude in poseHistory: toDel += 1 if oldTime >= videoTime: break poseHistory = poseHistory[:toDel] print "FRAME", frameNumber/15 # TODO except ManualControlException, e: print "ManualControlException" if drone.ctrlState == 3: # CTRL_FLYING=3 ... i.e. stop the current motion drone.hover(0.1) drone.land() drone.wait(1.0) drone.stopVideo() print "MaxVideoDelay", maxVideoDelay print "MaxControlGap", maxControlGap print "Battery", drone.battery if __name__ == "__main__": if len(sys.argv) > 2 and sys.argv[1] == "img": imgmain( sys.argv[1:], processFrame ) sys.exit( 0 ) import launcher launcher.launch( sys.argv, FreTask4Drone, freTask4 )
digitMissionCompleted = True print "DIGIT", digit, "COMPLETED", self.robot.time-gameStartTime self.turnLights(on=True) self.wait( 10.0 ) self.turnLights(on=False) else: print "DIGIT", digit, "FAILURE -> repeat" self.driver.stop() self.driver.goStraight(-0.2) self.turnWithWatchdog( math.radians(self.random(10, 180)), angularSpeed = math.radians(40) ) print 'Game over.', self.robot.battery for k in xrange(10): self.robot.setSpeedPxPa(0.0, 0.0) self.robot.update() raise EmergencyStopException() # TODO: Introduce GameOverException as in Eurobot def __call__( self ): print "RUNNING:", self.code if self.code.startswith("cmd:"): return eval( self.code[4:] ) return self.run() if __name__ == "__main__": # code = sys.argv[1] ... i.e. 123456789 or 876543210 or some other combinations for test from eduromaxi import EduroMaxi import launcher launcher.launch(sys.argv, EduroMaxi, SICKRobotDay2014, configFn=setupHandModule)
drone.setVideoChannel( front=True ) startTime = drone.time while drone.time - startTime < 5: sx, sy, sz, sa = 0.1, 0.0, 0.0, 0.0 drone.moveXYZA(sx, sy, sz, sa) drone.hover(2.0) drone.land() except ManualControlException, e: print "ManualControlException" if drone.ctrlState == 3: # CTRL_FLYING=3 ... i.e. stop the current motion drone.hover(1.0) drone.land() x,y,z = drone.coord e=math.hypot(x,y) print e print "Battery", drone.battery print "pozice", drone.coord if __name__ == "__main__": import launcher launcher.launch( sys.argv, ARDrone2, prelet_nad_stolem ) # vim: expandtab sw=4 ts=4
strategy = self.driver.stopG() prevDir = 0.0 else: goal = combinedPose( (pose[0], pose[1], pose[2] + dir), (1.0, 0, 0)) strategy = self.driver.goToG( goal, TOLERATED_MISS, angleThreshold=ANGULAR_THRESHOLD, angularSpeed=ANGULAR_SPEED) prevDir = dir vfh.laserMeasurements = None for (speed, angularSpeed) in strategy: self.robot.setSpeedPxPa(speed, angularSpeed) self.robot.update() pose = self.robot.localisation.pose() isThere = math.hypot(pose[0] - x, pose[1] - y) <= TOLERATED_MISS if isThere or vfh.laserMeasurements is not None: break if __name__ == "__main__": import sys from eduromaxi import EduroMaxi import launcher launcher.launch(sys.argv, EduroMaxi, VFHTest)
# ---------------------- BASE_ROM_PATH = "../roms/" ROM = 'SUMO' FRAME_SKIP = 4 # ---------------------- # Agent/Network parameters: # ---------------------- UPDATE_RULE = 'sgd' BATCH_ACCUMULATOR = 'mean' LEARNING_RATE = .0002 # .0002 DISCOUNT = .95 RMS_DECAY = .99 # (Rho) RMS_EPSILON = 1e-6 MOMENTUM = 0 EPSILON_START = 1.0 EPSILON_MIN = .1 EPSILON_DECAY = 1000000 PHI_LENGTH = 1 UPDATE_FREQUENCY = 1 REPLAY_MEMORY_SIZE = 1000000 BATCH_SIZE = 32 NETWORK_TYPE = "linear" FREEZE_INTERVAL = -1 REPLAY_START_SIZE = 100 IMAGE_RESIZE = 'crop' if __name__ == "__main__": launcher.launch(sys.argv[1:], Defaults, __doc__, traffic_situation='simpleX', agent_type='1D')
self.robot.gps.start() self.robot.laser.start() self.waitForStart() self.robot.camera.start() print "battery:", self.robot.battery startTime = self.robot.time while True: self.robot.setSpeedPxPa(0.0, 0.0) self.robot.update() except EmergencyStopException, e: print "EmergencyStopException" print "battery:", self.robot.battery self.robot.camera.requestStop() self.robot.gps.requestStop() self.robot.laser.requestStop() def __call__(self): print "OSGAR RUNNING:", self.configFilename if self.configFilename.startswith("cmd:"): return eval(self.configFilename[4:]) return self.ver0() from eduromaxi import EduroMaxi import launcher if __name__ == "__main__": launcher.launch(sys.argv, EduroMaxi, Osgar, configFn=setupHandModule) # vim: expandtab sw=4 ts=4
#neaiskus CLIP_DELTA=0 FREEZE_INTERVAL=-1 ##Neural agent epsilon_start=1.0 epsilon_min=0.1 epsilon_decay=1e5 replay_memory_size=1e3 #sitas nedidelis turi buti 1e3 experiment_prefix="exper_" replay_start_size=80 #kiek sukaupia randomu update_frequency=1#pvz niekad 30stepu nepadaro be mirimo #epochos ir pan steps_per_epoch=50 #max minuciu nemirsta; Savaitgaliu nepamirst epochs=10000#200000 steps_per_test=300 death_ends_episode=False #trainfile="train_EURUSD_UTC_1 Min_Bid_2014.07.01_2014.11.29.csv" #testfile="testdata.csv" trainfile="./data/hourly_train.csv" testfile="./data/hourly_test.csv" #nauji test_no_reset=1 #conda update matplotlib launcher.launch(Defaults)
"""Use it only for start launcher module """ try: import launcher launcher.launch() except: import traceback print "\nUnexpected error:\n" traceback.print_exc() raw_input("\nProcess canceled. Press Enter for close...")
EPSILON_START = 1.0 EPSILON_MIN = .1 #or 0.01 for tuned ddqn EPSILON_DECAY = 1000000 PHI_LENGTH = 4 UPDATE_FREQUENCY = 4 REPLAY_MEMORY_SIZE = 1000000 BATCH_SIZE = 32 FREEZE_INTERVAL = 10000 #30000 for tuned ddqn REPLAY_START_SIZE = 50000 #50000 RESIZE_METHOD = 'scale' #scale vs crop RESIZED_WIDTH = 84 RESIZED_HEIGHT = 84 OFFSET = 18 DEATH_ENDS_EPISODE = True CAP_REWARD = True MAX_START_NULLOPS = 30 OPTIMAL_EPS = 0.05 #0.05 or 0.001 for tuned ddqn DOUBLE_Q = False MEAN_FRAME = False TEMP = 1 TERMINATION_REG = 0.0 NUM_OPTIONS = 8 ACTOR_LR = 0.00025 ENTROPY_REG = 0.0 BASELINE = False if __name__ == "__main__": launcher.launch(sys.argv[1:], Defaults, __doc__)
# print "%0.2f\t%d\t%0.2f\t%0.2f\t%0.2f" % (errY, int(math.degrees(errA)), drone.vy, sy, sa) prevTime = drone.time drone.moveXYZA(sx, sy, sz, sa) maxControlGap = max(drone.time - prevTime, maxControlGap) poseHistory.append( (drone.time, (drone.coord[0], drone.coord[1], drone.heading), (drone.angleFB, drone.angleLR))) print "NAVI-OFF", drone.time - startTime drone.hover(0.5) drone.land() drone.setVideoChannel(front=True) except ManualControlException, e: print "ManualControlException" if drone.ctrlState == 3: # CTRL_FLYING=3 ... i.e. stop the current motion drone.hover(0.1) drone.land() drone.wait(1.0) drone.stopVideo() print "MaxVideoDelay", maxVideoDelay print "MaxControlGap", maxControlGap print "Loops", len(loops) - 1, [ int(now - prev) for prev, now in zip(loops[:-1], loops[1:]) ] print "Battery", drone.battery if __name__ == "__main__": import launcher launcher.launch(sys.argv, AirRaceDrone, competeAirRace)