def __init__(self, options): self.options = options self.db = self.db_connect() self.m = utils.Map(self.db, options.map) if options.srid: self.srid = options.srid else: self.srid = self.m.srid if options.region: region_name, p, has_data = self.region_paths().next() self.x_min, self.y_min, self.x_max, self.y_max = p.bounds else: # TODO if --srid is specified then this is wrong self.x_min = self.m.x_min self.x_max = self.m.x_max self.y_min = self.m.y_min self.y_max = self.m.y_max self.init_output_grid() if options.cart: self.f = utils.Interpolator(options.cart, self.m) else: self.f = None if options.output: self.out = open(options.output, 'w') else: self.out = sys.stdout if options.exclude_regions: self.exclude_regions = set(shlex.split(options.exclude_regions)) else: self.exclude_regions = set()
def __init__(self, options, carts): self.options = options self.carts = carts db_connection_data = [] if options.db_host: db_connection_data.append("host=" + options.db_host) if options.db_name: db_connection_data.append(" dbname=" + options.db_name) if options.db_user: db_connection_data.append(" user="******" ".join(db_connection_data)) self.m = utils.Map(self.db, options.map) if options.format != "geojson": if options.output: self.out = open(options.output, 'w') else: self.out = sys.stdout if self.options.simplification_json: self.simplification_dict = json.loads( self.options.simplification_json) else: self.simplification_dict = {} if options.exclude_regions: self.exclude_regions = set(shlex.split(options.exclude_regions)) else: self.exclude_regions = set()
def __init__(self, options=None): if options is None: self.options = self.parse_args() else: self.options = options self.db = self.db_connect() self.m = utils.Map(self.db, self.options.map) self._init_dimensions()
def get_omap(self): map_service_name = rospy.get_param("~static_map", "static_map") print "Fetching map from service: ", map_service_name rospy.wait_for_service(map_service_name) map_msg = rospy.ServiceProxy(map_service_name, GetMap)().map self.map = utils.Map(map_msg) self.map_initialized = True print "Finished loading map"
def _add_map(self, **data): _id = int(data["id"]) if self.get_map(_id): log.error("Map with id \"%s\" already exists. (%s)", _id, self.get_map(_id)) return _map = utils.Map(**data) # self._add_map_nearby(_map, *list(map(self.get_map, data['nearby']))) _map._nearby = data['nearby'] self._maps.append(_map)
def random_map(): length = 20 width = 20 map = utils.get_random_map(map=utils.Map(), length=length, width=width, level=10) global board board = utils.Board(map=map) map_info = json.dumps(map, default=lambda o: o.__dict__, indent=4) return map_info
def __init__(self, options): self.options = options self.db = psycopg2.connect("host=localhost") self.m = utils.Map(self.db, options.map) if options.cart: self.interpolator = utils.Interpolator(options.cart, self.m) else: self.interpolator = None if options.output: self.out = options.output else: self.out = sys.stdout
def __init__(self, options, carts): self.options = options self.carts = carts self.db = psycopg2.connect("host=localhost") self.m = utils.Map(self.db, options.map) if options.output: self.out = open(options.output, 'w') else: self.out = sys.stdout if self.options.simplification_json: self.simplification_dict = json.loads( self.options.simplification_json) else: self.simplification_dict = {}
def __init__(self, options): self.options = options self.db = psycopg2.connect("host=localhost") self.m = utils.Map(self.db, options.map) if options.cart: self.f = utils.Interpolator(options.cart, self.m) else: self.f = None if options.output: self.out = open(options.output, 'w') else: self.out = sys.stdout if options.exclude_regions: self.exclude_regions = set(shlex.split(options.exclude_regions)) else: self.exclude_regions = set()
help='load checkpoints and model from this dir', required=True, type=str) parser.add_argument('--checkpoint_file', help='load checkpoints and model from this file', required=True, type=str) #train_r0.125_p1_n-2.0_i4_k0.0_best_checkpoint.pth0 #expdir = 'temp/fb15k_ex25_sl_hul0' args = parser.parse_args() config = {} config.update(vars(args)) args = utils.Map(config) o2n, n2o = utils.get_template_id_maps(args.num_templates, args.exclude_t_ids) args.o2n = o2n args.n2o = n2o for key in ['train_labels_path', 'val_labels_path']: if args[key] == 'None': args[key] = None settings.set_settings(args) #args.output_path = tempfile.TemporaryDirectory().name os.makedirs(args.output_path) train_loader, val_loader, labelled_train_loader = dataset.get_data_loaders( args)
def post(self): map = utils.Map(10, 10).toList() self.response.headers["Content-Type"] = "application/json" self.response.write(json.dumps(map))
import utils as u W = 10 H = 10 # p1_map = u.Map(W, H) # p2_map = u.Map(W, H) # print(p1_map) # print(p2_map) p1 = u.Player_stdio(u.Map(W, H, "p1")) p2 = u.Player_dummy(u.Map(W, H, "p2")) print(p1.map) p1.gen_ships() print(p1.map) print(p2.map) p2.gen_ships() print(p2.map) while True: p1.out_fight_res(p2.in_fight(p1.out_fight())) p2.out_fight_res(p1.in_fight(p2.out_fight()))
imuData = str('X=%f,Y=%f,Z=%f' % (imu.accel['x'], imu.accel['y'], imu.accel['z'])) # External inertial measurement unit object compass = peripherals.exIMU('Compass', 1) heading = str(compass.heading) # 0-360 degrees # Laser emitter object laser = peripherals.Laser('Laser Emitter', 1) # Ultrasonic sensor object ultra = peripherals.Ultrasonic('Ultrasonic Sensor', 1) distance = str(round(ultra.ultdist(),2)) # Reads initial distance # Minimap object minimap = utils.Map(400,400,initHeading=compass.heading) minimap.draw_map() def goal_nav(justRotate=False,scan=False): goalDist = minimap.goalDist diffClockwise = minimap.goalHeading - minimap.heading if diffClockwise>180.0: diffClockwise -= 360.0 diffClockwise *= -1 direction = 1 elif diffClockwise<=-180.0: diffClockwise += 360.0 diffClockwise *= -1
import FrameFactory as viz import numpy as np import utils import math from array2gif import write_gif map_size = 250 border_size = 2 map = np.ones((map_size, map_size)).astype(int) map[100:151, 100:151] = 0 map[0:border_size, :] = 0 map[:, 0:border_size] = 0 map[map_size - border_size:, :] = 0 map[:, map_size - border_size:] = 0 map_object = utils.Map(map, np.array([[[40, 40]]]), np.array([[[210, 210]]])) robot_body = utils.build_robot_body(10) + [[[65, 65]]] sensor_angles = np.array( [[math.radians(-60), math.radians(-30), math.radians(0), math.radians(30), math.radians(60)]]).T sensor_start_points = utils.calc_coordinates(sensor_angles, np.array([[10]]), [[[65, 65]]]) # (1, ?, 2) sensor_end_points = utils.calc_coordinates(sensor_angles, np.array([[30]]), [[[65, 65]]]) # (1, ?, 2) sensor_lines = utils.calc_line_coordinates(sensor_start_points, sensor_end_points) img = viz.get_image_zxy(robot_body, sensor_lines, map_object) write_gif(img, "map.gif", fps=5) print(str(img))