def generate_config_files(start_i, end_i): P.initialize_experiment() for config_num in range(start_i, end_i): # attempt to space landmarks config = None attempts = 0 # It's easier to generate a config with less objects, so to have a truly uniform distribution, we must sample it here. if FORCE_LANDMARK_SELECTION: num_objects = len(FORCE_LANDMARK_SELECTION) else: num_objects = int(random.uniform(MIN_NUM_OBJECTS, MAX_NUM_OBJECTS)) print("making config %d with %d objects" % (config_num, num_objects)) while True: config = try_make_config(num_objects) attempts += 1 sys.stdout.write("\r Attempts: " + str(attempts)) if config is not None: print("") break if MAKE_LAKES: config = add_lake_to_config(config, X_RANGE, Y_RANGE) path = paths.get_env_config_path(config_num) os.makedirs(os.path.dirname(path), exist_ok=True) with open(path, 'w') as fp: json.dump(config, fp)
def make_config_with_landmark(landmark_name=None, num_objects=10): config = None while config is None: while config is None: config = try_make_config(num_objects, landmark_name) config = add_lake_to_config(config, X_RANGE, Y_RANGE) pos_x = config["xPos"][0] pos_z = config["zPos"][0] return config, pos_x, pos_z
def main(start_i, end_i, config_type): P.initialize_experiment() for config_num in range(start_i, end_i): # attempt to space landmarks config = None attempts = 0 # It's easier to generate a config with less objects, so to have a truly uniform distribution, we must sample it here. num_objects = int(random.uniform(MIN_NUM_OBJECTS, MAX_NUM_OBJECTS)) if FORCE_LANDMARK_SELECTION: num_objects = len(FORCE_LANDMARK_SELECTION) print("making config %d with %d objects" % (config_num, num_objects)) while True: if config_type == ConfigType.RANDOM or config_type == ConfigType.RANDOM_CORNER: start_pos, start_heading = None, None if config_type == ConfigType.RANDOM_CORNER: start_pos, start_heading = pick_drone_start_pos() config = try_make_config_random(num_objects, start_pos, start_heading) if config is not None and MAKE_LAKES: config = add_lake_to_config(config, X_RANGE, Y_RANGE) elif config_type == ConfigType.CIRCLE_OF_LANDMARKS: config = try_make_config_circle_of_landmarks(num_objects) elif config_type == ConfigType.CIRCLE_PERMUTATIONS: config = try_make_config_circle_permutations(num_objects, config_num) else: print ("Invalid config type!" + str(config_type)) quit(-1) attempts += 1 sys.stdout.write("\r Attemtps: " + str(attempts)) if config is not None: print("") break os.makedirs(paths.get_env_config_dir(), exist_ok=True) path = os.path.join(paths.get_env_config_path(config_num)) with open(path, 'w') as fp: json.dump(config, fp)
def generate_config_files(start_i, end_i): P.initialize_experiment() config_metadata = { "all_landmark_names": list(PORTABLE_LANDMARK_RADII.keys()), "all_landmark_radii": PORTABLE_LANDMARK_RADII, "new_config_every_n": NEW_CONFIG_EVERY_N } os.makedirs(os.path.dirname(paths.get_config_metadata_path()), exist_ok=True) with open(paths.get_config_metadata_path(), "w") as fp: json.dump(config_metadata, fp) config = None for config_num in range(start_i, end_i): # attempt to space landmarks attempts = 0 # It's easier to generate a config with less objects, so to have a truly uniform distribution, we must sample it here. if FORCE_LANDMARK_SELECTION: num_objects = len(FORCE_LANDMARK_SELECTION) else: num_objects = int(random.uniform(MIN_NUM_OBJECTS, MAX_NUM_OBJECTS)) if config_num % NEW_CONFIG_EVERY_N == 0 or config is None: print("making config %d with %d objects" % (config_num, num_objects)) while True: config = try_make_config(num_objects) attempts += 1 sys.stdout.write("\r Attempts: " + str(attempts)) if config is not None: print("") break if MAKE_LAKES: config = add_lake_to_config(config, X_RANGE, Y_RANGE) path = paths.get_env_config_path(config_num) os.makedirs(os.path.dirname(path), exist_ok=True) with open(path, 'w') as fp: json.dump(config, fp)