From b7afb598a8b44412638a999a527a0bd49cf90707 Mon Sep 17 00:00:00 2001 From: Jiri Vlasak Date: Wed, 7 Apr 2021 12:45:13 +0200 Subject: [PATCH] Reorder scenario plot --- scripts/plot_json_objects_scenario.py | 90 ++++++++++++++------------- 1 file changed, 46 insertions(+), 44 deletions(-) diff --git a/scripts/plot_json_objects_scenario.py b/scripts/plot_json_objects_scenario.py index 56e2fc5..4150931 100644 --- a/scripts/plot_json_objects_scenario.py +++ b/scripts/plot_json_objects_scenario.py @@ -215,41 +215,6 @@ if __name__ == "__main__": #for s in scenario["slot"]: # plt.plot(*plot_nodes(s), color="black") - # Plot `init`, `entry`, and `goal` configurations. - if "init" in scenario and len(scenario["init"]) == 3: - plt.plot(*plot_car(scenario["init"]), color="red") - plt.plot( - scenario["init"][0] - MINX, - scenario["init"][1] - MINY, - color="red", - marker="+", - ms=12 - ) - if "entry" in scenario and len(scenario["entry"]) == 3: - plt.plot(*plot_car(scenario["entry"]), color="magenta") - plt.plot( - scenario["entry"][0] - MINX, - scenario["entry"][1] - MINY, - color="magenta", - marker="+", - ms=12 - ) - if "goal" in scenario and len(scenario["goal"]) == 3: - plt.plot(*plot_car(scenario["goal"]), color="green") - plt.plot( - scenario["goal"][0] - MINX, - scenario["goal"][1] - MINY, - color="green", - marker="+", - ms=12 - ) - - # Plot `path` and `max_path`. - if sc2 and "path" in sc2 and len(sc2["path"]) > 0: - plt.plot(*plot_nodes(sc2["path"]), color="orange") - if "path" in scenario and len(scenario["path"]) > 0: - plt.plot(*plot_nodes(scenario["path"]), color="green") - # If there are possible starts specified, you may print and plot them. #if "starts" in scenario and len(scenario["starts"]) > 0: # print("possible starts:") @@ -306,7 +271,9 @@ if __name__ == "__main__": # For the Possible Entry Configurations from the paper, use: #if "inits" in scenario: - # for i in scenario["inits"]: + # #for i in scenario["inits"]: + # for j in range(0, len(scenario["inits"]), 110): + # i = scenario["inits"][j] # print(i) # if len(i) == 3: # plt.plot(*plot_car(i), color="gray") @@ -317,14 +284,49 @@ if __name__ == "__main__": # marker="+", # ms=12, # ) - # plt.plot(*plot_car(scenario["inits"][0]), color="magenta") - # plt.plot( - # scenario["inits"][0][0] - MINX, - # scenario["inits"][0][1] - MINY, - # color="magenta", - # marker="+", - # ms=12, - # ) + # #plt.plot(*plot_car(scenario["inits"][0]), color="magenta") + # #plt.plot( + # # scenario["inits"][0][0] - MINX, + # # scenario["inits"][0][1] - MINY, + # # color="magenta", + # # marker="+", + # # ms=12, + # #) + + # Plot `init`, `entry`, and `goal` configurations. + if "init" in scenario and len(scenario["init"]) == 3: + plt.plot(*plot_car(scenario["init"]), color="red") + plt.plot( + scenario["init"][0] - MINX, + scenario["init"][1] - MINY, + color="red", + marker="+", + ms=12 + ) + if "entry" in scenario and len(scenario["entry"]) == 3: + plt.plot(*plot_car(scenario["entry"]), color="magenta") + plt.plot( + scenario["entry"][0] - MINX, + scenario["entry"][1] - MINY, + color="magenta", + marker="+", + ms=12 + ) + if "goal" in scenario and len(scenario["goal"]) == 3: + plt.plot(*plot_car(scenario["goal"]), color="green") + plt.plot( + scenario["goal"][0] - MINX, + scenario["goal"][1] - MINY, + color="green", + marker="+", + ms=12 + ) + + # Plot `path` and `max_path`. + if sc2 and "path" in sc2 and len(sc2["path"]) > 0: + plt.plot(*plot_nodes(sc2["path"]), color="orange") + if "path" in scenario and len(scenario["path"]) > 0: + plt.plot(*plot_nodes(scenario["path"]), color="green") # The `scenario` may also include: # - `last` -- not sure what this is, see the source code. Maybe overlaps -- 2.39.2