]> rtime.felk.cvut.cz Git - hubacji1/iamcar2.git/blobdiff - scripts/plot_json_objects_scenario.py
Reorder scenario plot
[hubacji1/iamcar2.git] / scripts / plot_json_objects_scenario.py
index 56e2fc5d1ecbb5aacdb8be545006010814b2d830..41509310aaaa450f59c5119ec7abacc155304907 100644 (file)
@@ -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