]> rtime.felk.cvut.cz Git - hubacji1/iamcar2.git/commitdiff
By default, show plotted scenario
authorJiri Vlasak <hubacji1@fel.cvut.cz>
Tue, 14 Mar 2023 17:18:58 +0000 (18:18 +0100)
committerJiri Vlasak <hubacji1@fel.cvut.cz>
Tue, 14 Mar 2023 17:18:58 +0000 (18:18 +0100)
scripts/plot_scenario.py

index 804275a016fd79522d6b442fc3250a8f7942c021..0d10501ae2680a7fa01d2169e2b2924000b1b221 100755 (executable)
@@ -202,8 +202,8 @@ if __name__ == "__main__":
     plt.rcParams["figure.figsize"] = [14, 7]
     plt.rcParams["font.family"] = "cmr10"
     plt.rcParams["font.size"] = 24
-    plt.rcParams['hatch.linewidth'] = 6.0
-    plt.rcParams['lines.linewidth'] = 2.0
+    plt.rcParams['hatch.linewidth'] = 1  # 6.0
+    plt.rcParams['lines.linewidth'] = 1  # 2.0
     fig = plt.figure()
 
     # here subplot starts
@@ -331,8 +331,8 @@ if __name__ == "__main__":
                 if n[1] > MAXY:
                     MAXY = n[1]
     print("w: {}, h: {}".format(abs(MAXX - MINX), abs(MAXY - MINY)))
-    #MINY = -25
-    #MINX = -10
+    MINY = 0
+    MINX = 0
     c1 = plt.Circle(
         (-744239.7727016528 - MINX, -1044308.987006895 - MINY),
         4.8677125017335845,
@@ -363,153 +363,153 @@ if __name__ == "__main__":
     #ax.add_patch(c4)
 
     # For Goal Zone figure, "Goal zone" file name in j1/figs/
-    def r2d(w):
-        return w*180.0/pi
-    ax.set_ylim([-4.8, 2.8])
-    ax.set_xlim([-13, 5])
-    gz_ccr = matplotlib.patches.Arc(
-        (-744206.185356 - MINX, -1044330.294266 - MINY),
-        5.207071 * 2, 5.207071 * 2,
-        theta1=r2d(atan2(-1044325.281765 - -1044330.294266, -744204.775115 - -744206.185356)),
-        theta2=r2d(atan2(-1044325.6618554679 - -1044330.294266, -744208.5632466434 - -744206.185356)),
-        color="magenta",
-        fill=False,
-        lw=2,
-    )
-    ax.add_patch(gz_ccr)
-    gz_ccr = matplotlib.patches.Arc(
-        (-744206.185356 - MINX + 3.99, -1044330.294266 - MINY + 2.05),
-        5.207071 * 2, 5.207071 * 2,
-        theta1=r2d(atan2(-1044325.281765 - -1044330.294266, -744204.775115 - -744206.185356)),
-        theta2=r2d(atan2(-1044325.6618554679 - -1044330.294266, -744208.5632466434 - -744206.185356)),
-        color="magenta",
-        fill=False,
-        lw=2, ls="dotted",
-    )
-    ax.add_patch(gz_ccr)
-    gz_gh = 0.47424360277825361
-    gz_ih = -0.27424360277825361
-    def li(x, y, h, le=10.0):
-        return (x, x + le * cos(h)), (y, y + le * sin(h))
-    # gz border
-    plt.plot(*li(-744204.775115 - MINX, -1044325.281765 - MINY, gz_gh),
-        color="orange", ls="dotted")
-    plt.plot(*li(-744204.775115 - MINX, -1044325.281765 - MINY, gz_ih),
-        color="red", ls="dotted")
-    # path
-    plt.plot(
-        *li(-744208.5632466434 - MINX, -1044325.6618554679 - MINY, gz_gh, 4.47),
-        color="orange", ls="solid")
-    plt.plot(
-        *li(-744199.2632466434 - MINX, -1044323.6618554679 - MINY, gz_ih, -1.55),
-        color="red", ls="solid")
-    ax.text(
-        -744208.5632466434 - MINX,
-        -1044325.6618554679 - MINY - 1.5,
-        "C",
-        color="orange",
-        fontfamily="serif",
-        fontstyle="italic",
-    )
-    ax.text(
-        -744208.5632466434 - MINX + 0.35,
-        -1044325.6618554679 - MINY - 1.7,
-        "E",
-        color="orange",
-        fontfamily="serif",
-        fontstyle="italic",
-        fontsize=16,
-    )
-    ax.text(
-        -744199.2632466434 - MINX,
-        -1044323.6618554679 - MINY - 1.5,
-        "C",
-        color="red",
-        fontfamily="serif",
-        fontstyle="italic",
-    )
-    ax.text(
-        -744199.2632466434 - MINX + 0.35,
-        -1044323.6618554679 - MINY - 1.7,
-        "g",
-        color="red",
-        fontfamily="serif",
-        fontstyle="italic",
-        fontsize=16,
-    )
-    ax.text(
-        -744199.2632466434 - MINX,
-        -1044323.6618554679 - MINY - 3.9,
-        "θ",
-        color="red",
-        fontfamily="serif",
-        fontstyle="italic",
-    )
-    ax.text(
-        -744199.2632466434 - MINX + 0.35,
-        -1044323.6618554679 - MINY - 4.1,
-        "G",
-        color="red",
-        fontfamily="serif",
-        fontstyle="italic",
-        fontsize=16,
-    )
-    ax.arrow(
-        -744199.2632466434 - MINX,
-        -1044323.6618554679 - MINY - 3.18,
-        cos(gz_ih),
-        sin(gz_ih),
-        width=0.05,
-        color="red",
-        zorder=2,
-    )
-    ax.text(
-        -744199.2632466434 - MINX,
-        -1044323.6618554679 - MINY + 1.9,
-        "θ",
-        color="orange",
-        fontfamily="serif",
-        fontstyle="italic",
-    )
-    ax.text(
-        -744199.2632466434 - MINX + 0.35,
-        -1044323.6618554679 - MINY + 1.7,
-        "E",
-        color="orange",
-        fontfamily="serif",
-        fontstyle="italic",
-        fontsize=16,
-    )
-    ax.arrow(
-        -744199.2632466434 - MINX,
-        -1044323.6618554679 - MINY + 1.22,
-        cos(gz_gh),
-        sin(gz_gh),
-        width=0.05,
-        color="orange",
-        zorder=2,
-    )
-    ax.text(
-        -744199.2632466434 - MINX + 2,
-        -1044323.6618554679 - MINY + -3,
-        "G",
-        color="dimgray",
-        fontfamily="serif",
-        fontstyle="normal",
-        fontweight="bold",
-        backgroundcolor="white",
-    )
-    ax.fill((
-            -MINX -744204.775115,
-            -MINX -744204.775115 + 15 * cos(0.47424360277825361),
-            -MINX -744204.775115 + 15 * cos(0.27424360277825361),
-            -MINX -744204.775115,
-        ), (
-            -MINY -1044325.281765,
-            -MINY -1044325.281765 + 15 * sin(0.47424360277825361),
-            -MINY -1044325.281765 - 15 * sin(0.27424360277825361),
-            -MINY -1044325.281765,
-        ), color="gainsboro", fill=False, hatch="x")
+    def r2d(w):
+        return w*180.0/pi
+    ax.set_ylim([-4.8, 2.8])
+    ax.set_xlim([-13, 5])
+    gz_ccr = matplotlib.patches.Arc(
+        (-744206.185356 - MINX, -1044330.294266 - MINY),
+        5.207071 * 2, 5.207071 * 2,
+        theta1=r2d(atan2(-1044325.281765 - -1044330.294266, -744204.775115 - -744206.185356)),
+        theta2=r2d(atan2(-1044325.6618554679 - -1044330.294266, -744208.5632466434 - -744206.185356)),
+        color="magenta",
+        fill=False,
+        lw=2,
+    )
+    ax.add_patch(gz_ccr)
+    gz_ccr = matplotlib.patches.Arc(
+        (-744206.185356 - MINX + 3.99, -1044330.294266 - MINY + 2.05),
+        5.207071 * 2, 5.207071 * 2,
+        theta1=r2d(atan2(-1044325.281765 - -1044330.294266, -744204.775115 - -744206.185356)),
+        theta2=r2d(atan2(-1044325.6618554679 - -1044330.294266, -744208.5632466434 - -744206.185356)),
+        color="magenta",
+        fill=False,
+        lw=2, ls="dotted",
+    )
+    ax.add_patch(gz_ccr)
+    gz_gh = 0.47424360277825361
+    gz_ih = -0.27424360277825361
+    def li(x, y, h, le=10.0):
+        return (x, x + le * cos(h)), (y, y + le * sin(h))
+    # gz border
+    plt.plot(*li(-744204.775115 - MINX, -1044325.281765 - MINY, gz_gh),
+        color="orange", ls="dotted")
+    plt.plot(*li(-744204.775115 - MINX, -1044325.281765 - MINY, gz_ih),
+        color="red", ls="dotted")
+    # path
+    plt.plot(
+        *li(-744208.5632466434 - MINX, -1044325.6618554679 - MINY, gz_gh, 4.47),
+        color="orange", ls="solid")
+    plt.plot(
+        *li(-744199.2632466434 - MINX, -1044323.6618554679 - MINY, gz_ih, -1.55),
+        color="red", ls="solid")
+    ax.text(
+        -744208.5632466434 - MINX,
+        -1044325.6618554679 - MINY - 1.5,
+        "C",
+        color="orange",
+        fontfamily="serif",
+        fontstyle="italic",
+    )
+    ax.text(
+        -744208.5632466434 - MINX + 0.35,
+        -1044325.6618554679 - MINY - 1.7,
+        "E",
+        color="orange",
+        fontfamily="serif",
+        fontstyle="italic",
+        fontsize=16,
+    )
+    ax.text(
+        -744199.2632466434 - MINX,
+        -1044323.6618554679 - MINY - 1.5,
+        "C",
+        color="red",
+        fontfamily="serif",
+        fontstyle="italic",
+    )
+    ax.text(
+        -744199.2632466434 - MINX + 0.35,
+        -1044323.6618554679 - MINY - 1.7,
+        "g",
+        color="red",
+        fontfamily="serif",
+        fontstyle="italic",
+        fontsize=16,
+    )
+    ax.text(
+        -744199.2632466434 - MINX,
+        -1044323.6618554679 - MINY - 3.9,
+        "θ",
+        color="red",
+        fontfamily="serif",
+        fontstyle="italic",
+    )
+    ax.text(
+        -744199.2632466434 - MINX + 0.35,
+        -1044323.6618554679 - MINY - 4.1,
+        "G",
+        color="red",
+        fontfamily="serif",
+        fontstyle="italic",
+        fontsize=16,
+    )
+    ax.arrow(
+        -744199.2632466434 - MINX,
+        -1044323.6618554679 - MINY - 3.18,
+        cos(gz_ih),
+        sin(gz_ih),
+        width=0.05,
+        color="red",
+        zorder=2,
+    )
+    ax.text(
+        -744199.2632466434 - MINX,
+        -1044323.6618554679 - MINY + 1.9,
+        "θ",
+        color="orange",
+        fontfamily="serif",
+        fontstyle="italic",
+    )
+    ax.text(
+        -744199.2632466434 - MINX + 0.35,
+        -1044323.6618554679 - MINY + 1.7,
+        "E",
+        color="orange",
+        fontfamily="serif",
+        fontstyle="italic",
+        fontsize=16,
+    )
+    ax.arrow(
+        -744199.2632466434 - MINX,
+        -1044323.6618554679 - MINY + 1.22,
+        cos(gz_gh),
+        sin(gz_gh),
+        width=0.05,
+        color="orange",
+        zorder=2,
+    )
+    ax.text(
+        -744199.2632466434 - MINX + 2,
+        -1044323.6618554679 - MINY + -3,
+        "G",
+        color="dimgray",
+        fontfamily="serif",
+        fontstyle="normal",
+        fontweight="bold",
+        backgroundcolor="white",
+    )
+    ax.fill((
+            -MINX -744204.775115,
+            -MINX -744204.775115 + 15 * cos(0.47424360277825361),
+            -MINX -744204.775115 + 15 * cos(0.27424360277825361),
+            -MINX -744204.775115,
+        ), (
+            -MINY -1044325.281765,
+            -MINY -1044325.281765 + 15 * sin(0.47424360277825361),
+            -MINY -1044325.281765 - 15 * sin(0.27424360277825361),
+            -MINY -1044325.281765,
+        ), color="gainsboro", fill=False, hatch="x")
     # --- End of Goal Zone figure ---
 
     # Plot all the nodes (if exists.)
@@ -855,5 +855,6 @@ if __name__ == "__main__":
 
     # Uncommnent the following line and comment the plt.show() to store to the
     # file.
-    plt.savefig("out.pdf", bbox_inches="tight")
+    #plt.savefig("out.pdf", bbox_inches="tight")
+    plt.show()
     plt.close(fig)