def figure_4(figure="a", save_dir="figures"): print("Creating figure 4{} ...".format(figure)) save_path = save_dir + "/Figure_4" + figure if figure == "a": goal_filepath = "figures/goals_laby/*.pkl" elif figure == "b": goal_filepath = "figures/goals_laby_hgg/*.pkl" else: raise Exception("Only Figures 4a-b!") goal_list = [] for filepath in sorted(glob.glob(goal_filepath)): print(filepath) file = open(filepath, "rb") goal = pickle.load(file) goal_list.append(goal) color_list = ["red", "orange", "yellow", "green"] adapt_dict = dict() adapt_dict["field"] = [1.3, 0.75, 0.5, 0.25, 0.35, 0.1] adapt_dict["obstacles"] = [[1.3 - 0.1, 0.75, 0.6 - 0.1, 0.11, 0.02, 0.1], [1.3 - 0.23, 0.75, 0.6 - 0.1, 0.02, 0.35, 0.1], [1.3 + 0.03, 0.75, 0.6 - 0.1, 0.02, 0.2, 0.1]] num_vertices = [31, 31, 11] graph = DistanceGraph(None, field=adapt_dict["field"], num_vertices=num_vertices, obstacles=adapt_dict["obstacles"]) graph.plot_goals(goals=goal_list, colors=color_list, azim=-56, elev=28, save_path=save_path) print("... saved to: {}.pdf".format(save_path))
def figure_6(figure="a", save_dir="figures"): print("Creating figure {} ...".format(figure)) save_path = save_dir + "/Figure_6" + figure if figure == 'a': goal_filepath = "figures/goals_pushNew/*.pkl" else: goal_filepath = "figures/goals_pushNew_hgg/*.pkl" goal_list = [] for filepath in sorted(glob.glob(goal_filepath)): print(filepath) file = open(filepath, "rb") goal = pickle.load(file) goal_list.append(goal) color_list = ["red", "orange", "yellow", "green"] adapt_dict = dict() adapt_dict["field"] = [1.3, 0.75, 0.5, 0.25, 0.35, 0.1] adapt_dict["obstacles"] = [[1.3-0.07, 0.75, 0.6-0.1, 0.18, 0.04, 0.1]] num_vertices = [31, 31, 11] graph = DistanceGraph(None, field=adapt_dict["field"], num_vertices=num_vertices, obstacles=adapt_dict["obstacles"]) graph.plot_goals(goals=goal_list, colors=color_list, azim=-56, elev=28, save_path=save_path, extra=1) print("... saved to: {}.pdf".format(save_path))
def create_graph_distance(env, args): obstacles = list() field = env.env.env.adapt_dict["field"] obstacles = env.env.env.adapt_dict["obstacles"] num_vertices = args.num_vertices graph = DistanceGraph(args=args, field=field, num_vertices=num_vertices, obstacles=obstacles) graph.compute_cs_graph() graph.compute_dist_matrix() return graph
def create_graph_distance(self): obstacles = list() field = self.env.env.env.adapt_dict["field"] obstacles = self.env.env.env.adapt_dict["obstacles"] num_vertices = self.args.num_vertices graph = DistanceGraph(args=self.args, field=field, num_vertices=num_vertices, obstacles=obstacles) graph.compute_cs_graph() graph.compute_dist_matrix() self.graph = graph
def figure_1(figure="a", save_dir="figures"): print("Creating figure 1{} ...".format(figure)) save_path = save_dir + "/Figure_1" + figure adapt_dict = dict() # FetchPushObstacle modified! adapt_dict["field"] = [1.3, 0.75, 0.6, 0.25, 0.35, 0.2] adapt_dict["obstacles"] = [[1.3, 0.75, 0.6 - 0.1, 0.25, 0.05, 0.1]] num_vertices = [21, 21, 11] # [20, 20, 10] goal_1a = [1.5, 0.645, 0.44] goal_1b = [1.5, 0.75, 0.68] goal_2 = [1.5, 0.855, 0.44] graph = DistanceGraph(None, field=adapt_dict["field"], num_vertices=num_vertices, obstacles=adapt_dict["obstacles"]) graph.compute_cs_graph() graph.compute_dist_matrix(compute_predecessors=True) if figure == "a": dist, path = graph.get_dist(goal_1a, goal_2, return_path=True) goals = [goal_1a, goal_2] print("Dist: {}".format(dist)) graph.plot_graph(goals=goals, obstacle_vertices=False, graph=False, path=path, save_path=save_path) elif figure == "b": dist, path = graph.get_dist(goal_1b, goal_2, return_path=True) goals = [goal_1b, goal_2] print("Dist: {}".format(dist)) graph.plot_graph(goals=goals, obstacle_vertices=False, graph=False, path=path, save_path=save_path) elif figure == "c": goals = [goal_1a, goal_2] graph.plot_graph(goals=goals, obstacle_vertices=False, graph=False, path=goals, save_path=save_path) elif figure == "d": goals = [goal_1b, goal_2] graph.plot_graph(goals=goals, obstacle_vertices=False, graph=False, path=goals, save_path=save_path) else: raise Exception("Only Figures 1a-d!") print("... saved to: {}.pdf".format(save_path))
def figure_2(figure="a", save_dir="figures"): print("Creating figure 2{} ...".format(figure)) save_path = save_dir + "/Figure_2" + figure adapt_dict = dict() # FetchPushObstacle modified! adapt_dict["field"] = [1.3, 0.75, 0.6, 0.25, 0.35, 0.2] adapt_dict["obstacles"] = [[1.3, 0.75, 0.6 - 0.1, 0.25, 0.2, 0.1]] num_vertices = [4, 4, 4] graph = DistanceGraph(None, field=adapt_dict["field"], num_vertices=num_vertices, obstacles=adapt_dict["obstacles"]) graph.compute_cs_graph() graph.compute_dist_matrix(compute_predecessors=True) if figure == "a": print("HI") graph.plot_graph(obstacle_vertices=True, graph=False, azim=10, elev=16, save_path=save_path) elif figure == "b": graph.plot_graph(obstacle_vertices=True, graph=True, azim=10, elev=16, save_path=save_path) elif figure == "c": goal_1 = [1.5, 0.45, 0.405] goal_2 = [1.4, 1.05, 0.405] goals = [goal_1, goal_2] dist, path = graph.get_dist(goal_1, goal_2, return_path=True) print("Dist: {}".format(dist)) print("Path: {}".format(path)) graph.plot_graph(obstacle_vertices=True, graph=True, goals=goals, path=path, azim=10, elev=16, save_path=save_path) elif figure == "d": goal_1 = [1.5, 0.65, 0.78] goal_2 = [1.4, 1.05, 0.405] goals = [goal_1, goal_2] dist, path = graph.get_dist(goal_1, goal_2, return_path=True) print("Dist: {}".format(dist)) graph.plot_graph(obstacle_vertices=True, graph=True, goals=goals, path=path, azim=10, elev=16, save_path=save_path) elif figure == "e": goal_1 = [1.5, 0.75, 0.405] goal_2 = [1.4, 1.05, 0.405] goals = [goal_1, goal_2] dist, path = graph.get_dist(goal_1, goal_2, return_path=True) print("Dist: {}".format(dist)) graph.plot_graph(obstacle_vertices=True, graph=True, goals=goals, path=path, azim=10, elev=16, save_path=save_path) elif figure == "f": goal_1 = [1.5, 0.35, 0.405] goal_2 = [1.4, 1.05, 0.405] goals = [goal_1, goal_2] dist, path = graph.get_dist(goal_1, goal_2, return_path=True) print("Dist: {}".format(dist)) graph.plot_graph(obstacle_vertices=True, graph=True, goals=goals, path=path, azim=10, elev=16, save_path=save_path) else: raise Exception("Only Figures 2a-f!") print("... saved to: {}.pdf".format(save_path))
def figure_7(figure="a", save_dir="figures"): print("Creating figure 7{} ...".format(figure)) save_path = save_dir + "/Figure_7" + figure adapt_dict = dict() # FetchPushObstacle modified! adapt_dict["field"] = [1.3, 0.75, 0.6, 0.25, 0.35, 0.2] adapt_dict["obstacles"] = [[1.3 - 0.05, 0.75, 0.6 - 0.1, 0.20, 0.04, 0.1]] num_vertices = [20, 41, 10] # [20, 20, 10] goal_1 = [1.3, 0.6, 0.4] goal_2 = [1.3, 0.9, 0.4] graph = DistanceGraph(None, field=adapt_dict["field"], num_vertices=num_vertices, obstacles=adapt_dict["obstacles"]) graph.compute_cs_graph() goals = [goal_1, goal_2] graph.compute_dist_matrix(compute_predecessors=True) if figure == "a": dist, path = graph.get_dist(goal_1, goal_2, return_path=True) goals = [goal_1, goal_2] print("Dist: {}".format(dist)) graph.plot_graph(goals=goals, obstacle_vertices=False, graph=False, azim=10, elev=16, path=path, save_path=save_path, extra=1) if figure == "b": graph.plot_graph(goals=goals, obstacle_vertices=False, graph=False, azim=10, elev=16, path=goals, save_path=save_path, extra=1) print("... saved to: {}.pdf".format(save_path))