scenario = get_scenario(SCEN_FILE)
- plt.rcParams["font.size"] = 24
+ # Font size to be approximately the same in the paper:
+ # - sc1-0: 16
+ # - sc3-2: 12
+ # - sc4-0+: 22
+ plt.rcParams["font.size"] = 22
plt.rcParams['hatch.linewidth'] = 1.0
+ plt.rcParams['lines.linewidth'] = 1.0
fig = plt.figure()
# here subplot starts
ax = fig.add_subplot(111)
ax.set_aspect("equal")
- ax.set_title("{}".format(SCEN_FILE))
+ ax.set_title("Possible Entry Configurations".format(SCEN_FILE[-8:-5].replace("_", "-")))
ax.set_xlabel("x [m]")
ax.set_ylabel("y [m]")
- #ax.set_xlim([34, 53]) # 19
- #ax.set_ylim([-1, 16]) # 17
- #ax.set_xlim([28, 53]) # 25
- #ax.set_ylim([-1, 21]) # 22
+ # For Possible Entry Points (Possible Entry Configurations) use:
+ #ax.set_xlim([35.6, 46.4])
+ #ax.set_ylim([2.9, 2.9 + 6.84])
+
+ # For Last Maneuver use:
+ #ax.set_xlim([38, 44])
+ #ax.set_ylim([3.1, 6.9])
+
+ # For Scenario 3-2 detail use:
+ #ax.set_xlim([0, 15])
+ #ax.set_ylim([35, 50])
+
+ # Set min and max to center the plot.
MINX = scenario["init"][0]
MINY = scenario["init"][1]
if "obst" in scenario and len(scenario["obst"]) > 0:
if n[1] < MINY:
MINY = n[1]
+ # Plot all the nodes (if exists), obstacles, and slot.
if "nodes_x" in scenario and "nodes_y" in scenario:
plt.plot(
scenario["nodes_x"] - MINX,
ms=2,
lw=0,
)
- if "obst" in scenario and len(scenario["obst"]) > 0:
+ if "obst" in scenario and len(scenario["obst"]) > 0:
for o in scenario["obst"]:
- plt.plot(*plot_nodes(o), color="blue")
- if "last" in scenario and len(scenario["last"]) > 0:
- for n in scenario["last"]:
- plt.plot(*plot_car(n), color="peachpuff")
- if "path" in scenario and len(scenario["path"]) > 0:
- for n in scenario["path"]:
- plt.plot(*plot_car(n), color="peachpuff")
- plt.plot(*plot_nodes(scenario["path"]), color="orange")
- if "last" in scenario and len(scenario["last"]) > 0:
- plt.plot(*plot_nodes(scenario["last"]), color="orange")
+ plt.plot(*plot_nodes(o), color="blue", linestyle=":")
if "slot" in scenario and len(scenario["slot"]) > 0:
- plt.plot(*plot_nodes(scenario["slot"][0]), color="gray")
+ plt.plot(*plot_nodes(scenario["slot"][0]), color="black")
for s in scenario["slot"]:
- pass#plt.plot(*plot_nodes(s), color="gray")
- if "init" in scenario and len(scenario["init"]) == 3:
+ plt.plot(*plot_nodes(s), color="black")
+
+ # Plot `init`, `entry`, and `goal` configurations.
+ if "init" in scenario and len(scenario["entry"]) == 3:
plt.plot(*plot_car(scenario["init"]), color="red")
plt.plot(
scenario["init"][0] - MINX,
marker="+",
ms=12
)
- if "goals" in scenario:
- for i in scenario["goals"]:
- if len(i) == 3:
- plt.plot(*plot_car(i), color="darkseagreen")
- plt.plot(i[0] - MINX, i[1] - MINY, color="darkseagreen", marker="+", ms=12)
- if "goal" in scenario and len(scenario["goal"]) == 3:
- # plot entry point
- plt.plot(*plot_car(scenario["goal"]), color="magenta")
+ if "entry" in scenario and len(scenario["entry"]) == 3:
+ plt.plot(*plot_car(scenario["entry"]), color="magenta")
plt.plot(
- scenario["goal"][0] - MINX,
- scenario["goal"][1] - MINY,
+ scenario["entry"][0] - MINX,
+ scenario["entry"][1] - MINY,
color="magenta",
marker="+",
ms=12
)
- # plot gc
- if "last" in scenario:
- plt.plot(*plot_car(scenario["last"][0]), color="green")
+ if "goal" in scenario and len(scenario["goal"]) == 3:
+ plt.plot(*plot_car(scenario["goal"]), color="green")
plt.plot(
- scenario["last"][0][0] - MINX,
- scenario["last"][0][1] - MINY,
+ scenario["goal"][0] - MINX,
+ scenario["goal"][1] - MINY,
color="green",
marker="+",
ms=12
)
- if "starts" in scenario and len(scenario["starts"]) > 0:
- print("possible starts:")
- for p in scenario["starts"]:
- plt.plot(*p, color="red", marker="+", ms=12)
- print(" {}".format(p))
+
+ # Plot `path` and `max_path`.
+ if "max_path" in scenario and len(scenario["path"]) > 0:
+ plt.plot(*plot_nodes(scenario["max_path"]), color="orange")
+ if "path" in scenario and len(scenario["path"]) > 0:
+ plt.plot(*plot_nodes(scenario["path"]), color="orange")
+
+ # If there are possible starts specified, you may print and plot them.
+ #if "starts" in scenario and len(scenario["starts"]) > 0:
+ # print("possible starts:")
+ # for p in scenario["starts"]:
+ # plt.plot(*p, color="red", marker="+", ms=12)
+ # print(" {}".format(p))
+
+ # For the Last Maneuver figure from the paper, use:
+ # - `init2` -- orange
+ #plt.plot(*plot_car(scenario["init2"]), color="orange")
+ #plt.plot(
+ # scenario["init2"][0] - MINX,
+ # scenario["init2"][1] - MINY,
+ # color="orange",
+ # #marker="+",
+ # ms=12
+ #)
+ # - `goal2` -- orange
+ #plt.plot(*plot_car(scenario["goal2"]), color="orange")
+ #plt.plot(
+ # scenario["goal2"][0] - MINX,
+ # scenario["goal2"][1] - MINY,
+ # color="orange",
+ # #marker="+",
+ # ms=12
+ #)
+ # - `goal2` -- middle (orange)
+ #plt.plot(*plot_car(scenario["goals"][0]), color="orange")
+ #plt.plot(
+ # scenario["goal2"][0] - MINX,
+ # scenario["goal2"][1] - MINY,
+ # color="orange",
+ # #marker="+",
+ # ms=12
+ #)
+ # - `init1` -- green
+ #plt.plot(*plot_car(scenario["init1"]), color="green")
+ #plt.plot(
+ # scenario["init1"][0] - MINX,
+ # scenario["init1"][1] - MINY,
+ # color="green",
+ # #marker="+",
+ # ms=12
+ #)
+ # - `goal1` -- green
+ #plt.plot(*plot_car(scenario["goal1"]), color="green")
+ #plt.plot(
+ # scenario["goal1"][0] - MINX,
+ # scenario["goal1"][1] - MINY,
+ # color="green",
+ # #marker="+",
+ # ms=12
+ #)
+
+ # For the Possible Entry Configurations from the paper, use:
+ #if "inits" in scenario:
+ # for i in scenario["inits"]:
+ # print(i)
+ # if len(i) == 3:
+ # plt.plot(*plot_car(i), color="gray")
+ # plt.plot(
+ # i[0] - MINX,
+ # i[1] - MINY,
+ # color="gray",
+ # 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,
+ # )
+
+ # The `scenario` may also include:
+ # - `last` -- not sure what this is, see the source code. Maybe overlaps
+ # with the `goal`.
+ # - `last1` -- used to demonstrate In-Slot Planner (was Parking Slot
+ # Planner (PSP.))
+ # - `last2` -- used to demonstrate In-Slot Planner (was Parking Slot
+ # Planner (PSP.))
+ # - `max_orig_path` -- maximum original path. I used this when comparing
+ # original paths but I had to copy the `max_orig_path` by hand from
+ # different scenario result.
+ # - `orig_path` -- the path before the optimization.
+ # - `max_path` -- the maximum path after optimization. Must be copied by
+ # hand.
+ # - `path` -- optimized path of the scenario.
handles, labels = ax.get_legend_handles_labels()
+ # Uncommnent the following line and comment the plt.show() to store to the
+ # file.
+ # plt.savefig("out.eps", bbox_inches="tight")
plt.show()
plt.close(fig)