From: Jiri Vlasak Date: Mon, 3 May 2021 13:31:44 +0000 (+0200) Subject: Rewrite plot init, entry, goal X-Git-Tag: v0.5.0~25 X-Git-Url: http://rtime.felk.cvut.cz/gitweb/hubacji1/iamcar2.git/commitdiff_plain/554fc7973b93fc5eeebaf842c781fc54d46a5242 Rewrite plot init, entry, goal --- diff --git a/scripts/plot_json_objects_scenario.py b/scripts/plot_json_objects_scenario.py index 0397599..da2a823 100644 --- a/scripts/plot_json_objects_scenario.py +++ b/scripts/plot_json_objects_scenario.py @@ -215,6 +215,56 @@ 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 "entries" in scenario: + for e in scenario["entries"]: + plt.plot(*plot_car(e), color="orange") + plt.plot( + e[0] - MINX, + e[1] - MINY, + color="orange", + 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 "entry" in scenario and len(scenario["entry"]) == 4: + esc = scenario["entry"] + plt.plot(*plot_car([esc[0], esc[1], esc[2]]), color="magenta") + plt.plot(*plot_car([esc[0], esc[1], esc[3]]), 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 + ) + # If there are possible starts specified, you may print and plot them. #if "starts" in scenario and len(scenario["starts"]) > 0: # print("possible starts:") @@ -293,35 +343,6 @@ if __name__ == "__main__": # # 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")