]> rtime.felk.cvut.cz Git - hubacji1/iamcar2.git/commitdiff
Rewrite plot init, entry, goal
authorJiri Vlasak <hubacji1@fel.cvut.cz>
Mon, 3 May 2021 13:31:44 +0000 (15:31 +0200)
committerJiri Vlasak <hubacji1@fel.cvut.cz>
Mon, 3 May 2021 13:31:44 +0000 (15:31 +0200)
scripts/plot_json_objects_scenario.py

index 0397599c85362b748c2419c05046aa3c778c49f1..da2a823718305f57409c687c5ef7e97d1124099c 100644 (file)
@@ -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")