2 """Plot JSON formatted scenario."""
4 from math import cos, pi, sin, atan, atan2
6 from matplotlib import pyplot as plt
7 from sys import argv, exit
10 from path2traj import BicycleCar
24 #BCAR_DR = 5.171 - 4.236
28 #BCAR_DR = 3.622 - BCAR_DF
37 def get_scenario(fname):
38 """Load scenario from file."""
40 raise ValueError("File name as argument needed")
41 with open(fname, "r") as f:
42 scenario = loads(f.read())
45 def plot_nodes(nodes=[]):
46 """Return ``xcoords``, ``ycoords`` arrays of nodes to plot.
49 nodes -- The list of nodes to plot.
54 xcoords.append(n[0] - MINX)
55 ycoords.append(n[1] - MINY)
56 return (xcoords, ycoords)
59 """Return ``xcoords``, ``ycoords`` arrays of car frame to plot.
62 pose -- The pose of a car.
65 lfx += (BCAR_W / 2.0) * cos(pose[2] + pi / 2.0)
66 lfx += BCAR_DF * cos(pose[2])
67 lfx += BCAR_SD * cos(pose[2])
70 lf3x += (BCAR_W / 2.0) * cos(pose[2] + pi / 2.0)
71 lf3x += 2/3 * BCAR_DF * cos(pose[2])
72 lf3x += BCAR_SD * cos(pose[2])
75 lrx += (BCAR_W / 2.0) * cos(pose[2] + pi / 2.0)
76 lrx += -BCAR_DR * cos(pose[2])
77 lrx += -BCAR_SD * cos(pose[2])
80 rrx += (BCAR_W / 2.0) * cos(pose[2] - pi / 2.0)
81 rrx += -BCAR_DR * cos(pose[2])
82 rrx += -BCAR_SD * cos(pose[2])
85 rfx += (BCAR_W / 2.0) * cos(pose[2] - pi / 2.0)
86 rfx += BCAR_DF * cos(pose[2])
87 rfx += BCAR_SD * cos(pose[2])
90 rf3x += (BCAR_W / 2.0) * cos(pose[2] - pi / 2.0)
91 rf3x += 2/3 * BCAR_DF * cos(pose[2])
92 rf3x += BCAR_SD * cos(pose[2])
95 lfy += (BCAR_W / 2.0) * sin(pose[2] + pi / 2.0)
96 lfy += BCAR_DF * sin(pose[2])
97 lfy += BCAR_SD * sin(pose[2])
100 lf3y += (BCAR_W / 2.0) * sin(pose[2] + pi / 2.0)
101 lf3y += 2/3 * BCAR_DF * sin(pose[2])
102 lf3y += BCAR_SD * sin(pose[2])
105 lry += (BCAR_W / 2.0) * sin(pose[2] + pi / 2.0)
106 lry += -BCAR_DR * sin(pose[2])
107 lry += -BCAR_SD * sin(pose[2])
110 rry += (BCAR_W / 2.0) * sin(pose[2] - pi / 2.0)
111 rry += -BCAR_DR * sin(pose[2])
112 rry += -BCAR_SD * sin(pose[2])
115 rfy += (BCAR_W / 2.0) * sin(pose[2] - pi / 2.0)
116 rfy += BCAR_DF * sin(pose[2])
117 rfy += BCAR_SD * sin(pose[2])
120 rf3y += (BCAR_W / 2.0) * sin(pose[2] - pi / 2.0)
121 rf3y += 2/3 * BCAR_DF * sin(pose[2])
122 rf3y += BCAR_SD * sin(pose[2])
125 cfx += BCAR_DF * cos(pose[2])
126 cfx += BCAR_SD * cos(pose[2])
129 cfy += BCAR_DF * sin(pose[2])
130 cfy += BCAR_SD * sin(pose[2])
132 xcoords = (lfx, lrx, rrx, rfx, cfx, rf3x, lf3x, cfx, lfx)
133 ycoords = (lfy, lry, rry, rfy, cfy, rf3y, lf3y, cfy, lfy)
134 return ([x - MINX for x in xcoords], [y - MINY for y in ycoords])
136 def plot_car_corners(pose):
137 """Return ``xcoords``, ``ycoords`` arrays of car frame corners.
140 pose -- The pose of a car.
143 lfx += (BCAR_W / 2.0) * cos(pose[2] + pi / 2.0)
144 lfx += BCAR_DF * cos(pose[2])
145 lfx += BCAR_SD * cos(pose[2])
148 lrx += (BCAR_W / 2.0) * cos(pose[2] + pi / 2.0)
149 lrx += -BCAR_DR * cos(pose[2])
150 lrx += -BCAR_SD * cos(pose[2])
153 rrx += (BCAR_W / 2.0) * cos(pose[2] - pi / 2.0)
154 rrx += -BCAR_DR * cos(pose[2])
155 rrx += -BCAR_SD * cos(pose[2])
158 rfx += (BCAR_W / 2.0) * cos(pose[2] - pi / 2.0)
159 rfx += BCAR_DF * cos(pose[2])
160 rfx += BCAR_SD * cos(pose[2])
163 lfy += (BCAR_W / 2.0) * sin(pose[2] + pi / 2.0)
164 lfy += BCAR_DF * sin(pose[2])
165 lfy += BCAR_SD * sin(pose[2])
168 lry += (BCAR_W / 2.0) * sin(pose[2] + pi / 2.0)
169 lry += -BCAR_DR * sin(pose[2])
170 lry += -BCAR_SD * sin(pose[2])
173 rry += (BCAR_W / 2.0) * sin(pose[2] - pi / 2.0)
174 rry += -BCAR_DR * sin(pose[2])
175 rry += -BCAR_SD * sin(pose[2])
178 rfy += (BCAR_W / 2.0) * sin(pose[2] - pi / 2.0)
179 rfy += BCAR_DF * sin(pose[2])
180 rfy += BCAR_SD * sin(pose[2])
182 xcoords = (lfx, lrx, rrx, rfx)
183 ycoords = (lfy, lry, rry, rfy)
184 return ([x - MINX for x in xcoords], [y - MINY for y in ycoords])
186 if __name__ == "__main__":
190 elif (len(argv) == 3):
193 sc2 = get_scenario(SCEN_FILE2)
195 SCEN_FILE = "sc.json"
197 scenario = get_scenario(SCEN_FILE)
199 # Font size to be approximately the same in the paper:
203 plt.rc('axes', unicode_minus=False)
204 plt.rcParams["figure.figsize"] = [14, 7]
205 plt.rcParams["font.family"] = "cmr10"
206 plt.rcParams["font.size"] = 24
207 plt.rcParams['hatch.linewidth'] = 0.5 # 6.0
208 plt.rcParams['lines.linewidth'] = 1.0 # 2.0
211 # here subplot starts
212 ax = fig.add_subplot(111)
213 ax.set_aspect("equal")
214 ax.set_title(SCEN_FILE.split(".")[0])
215 ax.set_xlabel("x [m]")
216 ax.set_ylabel("y [m]")
217 # For stage, comment upper, uncomment following:
222 #ax.set_xlim([4, 32]) # 28
223 #ax.set_ylim([7, 29]) # 22
225 #ax.set_xlim([-1, 27]) # 28
226 #ax.set_ylim([-1, 21]) # 22
228 #ax.set_xlim([-9.9, 18.1]) # 28
229 #ax.set_ylim([-4.9, 17.1]) # 22
231 #ax.set_xlim([4, 32]) # 28
232 #ax.set_ylim([-4, 18]) # 22
234 #ax.set_xlim([-7, 21]) # 28
235 #ax.set_ylim([7, 29]) # 22
237 #ax.set_xlim([-7, 21]) # 28
238 #ax.set_ylim([2, 24]) # 22
240 #ax.set_xlim([-1, 27]) # 28
241 #ax.set_ylim([-1, 21]) # 22
243 # For Possible Entry Points (Possible Entry Configurations) use:
244 #plt.rcParams["font.size"] = 26
245 #ax.set_xlim([37.6, 45.6])
246 #ax.set_ylim([2.4, 8.5])
247 #ax.set_title("Possible configurations")
249 # For Last Maneuver use:
250 #ax.set_xlim([38, 44])
251 #ax.set_ylim([3.1, 6.9])
253 # For Scenario 3-2 detail use:
255 #ax.set_title("Scenario 1")
256 #ax.set_xlim([1, 16]) # w=15
257 #ax.set_ylim([35.1, 49.9]) # h=15
259 # For Scenario 4-0 detail use:
261 #ax.set_title("Scenario 2")
262 #ax.set_xlim([32, 53]) # w=19
263 #ax.set_ylim([0.5, 19.5]) # h=18
265 # For Scenario 4-1 detail use:
267 #ax.set_title("Scenario 3")
268 #ax.set_xlim([32.5, 48.5]) # w=16
269 #ax.set_ylim([1, 16]) # h=15
271 # For Scenario 5-1 detail use:
273 #ax.set_title("Scenario 4")
274 #ax.set_xlim([10.1, 27])
275 #ax.set_ylim([10.1, 26])
277 # For Scenario 4-1-{0,14} detail use:
279 #ax.set_title("Scenario 5") # Scenario 6
280 #ax.set_xlim([32.5, 48.5]) # w=16
281 #ax.set_ylim([1, 16.3]) # h=15.3
283 # For Scenario 5-3-34 detail use:
285 #ax.set_title("Scenario 7") # Scenario 8
286 #ax.set_xlim([5.5, 27.5])
287 #ax.set_ylim([15.1, 35])
289 # For Scenario 5-3-29 detail use:
291 #ax.set_title("Scenario 8")
292 #ax.set_xlim([5.5, 27.5])
293 #ax.set_ylim([10.1, 30])
295 # For Real-world parking scenario in Introduction section use:
296 #ax.set_title("Real-world parking scenario with artificial obstacle")
297 #ax.set_xlim([23, 58.5])
298 #ax.set_ylim([-8.4, 20.9])
299 #ax.text(34, 9.2, "Initial configuration", color="red")
300 #ax.text(43.5, 8.5, "Final path", color="blue")
301 #ax.text(48.25, 5.5, "Entry\nconfigurations", color="orange", ha="right")
302 #ax.text(38, 3.8, "Parking\nslot", color="blue", ha="right", backgroundcolor="white")
303 #ax.text(35.2, 5.5, "Goal configuration", color="green")
306 #ax.set_title("Computed goal")
307 #ax.set_xlim([6.8, 16.2])
308 #ax.set_ylim([15, 20])
310 # For simple scenarios 92 and 96 (simple-1k-test49)
311 # - Use MINY=-25, MINX=-10 for 96.
312 #ax.set_title("Simple parking scenario")
313 #ax.set_xlim([-11, 24]) # w=35
314 #ax.set_ylim([-2.5, 37.5]) # h=40
316 # Set min and max to center the plot.
317 MINX = scenario["init"][0]
318 MINY = scenario["init"][1]
319 MAXX = scenario["init"][0]
320 MAXY = scenario["init"][1]
321 if ("obst" in scenario and isinstance(scenario["obst"], list)
322 and len(scenario["obst"]) > 0):
323 for o in scenario["obst"]:
335 print("w: {}, h: {}".format(abs(MAXX - MINX), abs(MAXY - MINY)))
339 (-744239.7727016528 - MINX, -1044308.987006895 - MINY),
346 (-744239.7727016528 - MINX, -1044308.987006895 - MINY),
353 (-744238.8067612824 - MINX, -1044309.1038891475 - MINY),
360 (-744238.8067612824 - MINX, -1044309.1038891475 - MINY),
367 # For Goal Zone figure, "Goal zone" file name in j1/figs/
370 # ax.set_ylim([-4.8, 2.8])
371 # ax.set_xlim([-13, 5])
372 gz_ccr = matplotlib.patches.Arc(
373 (-744206.185356 - MINX, -1044330.294266 - MINY),
374 5.207071 * 2, 5.207071 * 2,
375 theta1=r2d(atan2(-1044325.281765 - -1044330.294266, -744204.775115 - -744206.185356)),
376 theta2=r2d(atan2(-1044325.6618554679 - -1044330.294266, -744208.5632466434 - -744206.185356)),
381 # ax.add_patch(gz_ccr)
382 gz_ccr = matplotlib.patches.Arc(
383 (-744206.185356 - MINX + 3.99, -1044330.294266 - MINY + 2.05),
384 5.207071 * 2, 5.207071 * 2,
385 theta1=r2d(atan2(-1044325.281765 - -1044330.294266, -744204.775115 - -744206.185356)),
386 theta2=r2d(atan2(-1044325.6618554679 - -1044330.294266, -744208.5632466434 - -744206.185356)),
391 # ax.add_patch(gz_ccr)
392 gz_gh = 0.47424360277825361
393 gz_ih = -0.27424360277825361
394 def li(x, y, h, le=10.0):
395 return (x, x + le * cos(h)), (y, y + le * sin(h))
397 # plt.plot(*li(-744204.775115 - MINX, -1044325.281765 - MINY, gz_gh),
398 # color="orange", ls="dotted")
399 # plt.plot(*li(-744204.775115 - MINX, -1044325.281765 - MINY, gz_ih),
400 # color="red", ls="dotted")
403 # *li(-744208.5632466434 - MINX, -1044325.6618554679 - MINY, gz_gh, 4.47),
404 # color="orange", ls="solid")
406 # *li(-744199.2632466434 - MINX, -1044323.6618554679 - MINY, gz_ih, -1.55),
407 # color="red", ls="solid")
409 # -744208.5632466434 - MINX,
410 # -1044325.6618554679 - MINY - 1.5,
413 # fontfamily="serif",
414 # fontstyle="italic",
417 # -744208.5632466434 - MINX + 0.35,
418 # -1044325.6618554679 - MINY - 1.7,
421 # fontfamily="serif",
422 # fontstyle="italic",
426 # -744199.2632466434 - MINX,
427 # -1044323.6618554679 - MINY - 1.5,
430 # fontfamily="serif",
431 # fontstyle="italic",
434 # -744199.2632466434 - MINX + 0.35,
435 # -1044323.6618554679 - MINY - 1.7,
438 # fontfamily="serif",
439 # fontstyle="italic",
443 # -744199.2632466434 - MINX,
444 # -1044323.6618554679 - MINY - 3.9,
447 # fontfamily="serif",
448 # fontstyle="italic",
451 # -744199.2632466434 - MINX + 0.35,
452 # -1044323.6618554679 - MINY - 4.1,
455 # fontfamily="serif",
456 # fontstyle="italic",
460 # -744199.2632466434 - MINX,
461 # -1044323.6618554679 - MINY - 3.18,
469 # -744199.2632466434 - MINX,
470 # -1044323.6618554679 - MINY + 1.9,
473 # fontfamily="serif",
474 # fontstyle="italic",
477 # -744199.2632466434 - MINX + 0.35,
478 # -1044323.6618554679 - MINY + 1.7,
481 # fontfamily="serif",
482 # fontstyle="italic",
486 # -744199.2632466434 - MINX,
487 # -1044323.6618554679 - MINY + 1.22,
495 # -744199.2632466434 - MINX + 2,
496 # -1044323.6618554679 - MINY + -3,
499 # fontfamily="serif",
500 # fontstyle="normal",
502 # backgroundcolor="white",
505 # -MINX -744204.775115,
506 # -MINX -744204.775115 + 15 * cos(0.47424360277825361),
507 # -MINX -744204.775115 + 15 * cos(0.27424360277825361),
508 # -MINX -744204.775115,
510 # -MINY -1044325.281765,
511 # -MINY -1044325.281765 + 15 * sin(0.47424360277825361),
512 # -MINY -1044325.281765 - 15 * sin(0.27424360277825361),
513 # -MINY -1044325.281765,
514 # ), color="gainsboro", fill=False, hatch="x")
515 # # --- End of Goal Zone figure ---
517 # Plot all the nodes (if exists.)
518 if "nodes_x" in scenario and "nodes_y" in scenario:
520 [x - MINX for x in scenario["nodes_x"]],
521 [y - MINY for y in scenario["nodes_y"]],
527 # Plot all the steered2 nodes (if exists.)
528 if "steered2_x" in scenario and "steered2_y" in scenario:
530 [x - MINX for x in scenario["steered2_x"]],
531 [y - MINY for y in scenario["steered2_y"]],
537 # Plot all the steered1 nodes (if exists.)
538 if "steered1_x" in scenario and "steered1_y" in scenario:
540 [x - MINX for x in scenario["steered1_x"]],
541 [y - MINY for y in scenario["steered1_y"]],
547 # Plot obstacles, slot.
548 if ("obst" in scenario and isinstance(scenario["obst"], list)
549 and len(scenario["obst"]) > 0):
550 for o in scenario["obst"]:
553 ax.fill(*plot_nodes(o), color="black", fill=False, hatch="//") #fill=True for stage
554 if "slot" in scenario and len(scenario["slot"]) > 0:
555 plt.plot(*plot_nodes(scenario["slot"]), color="blue", linewidth=1)
556 #for s in scenario["slot"]:
557 # plt.plot(*plot_nodes(s), color="black")
559 # For the Possible Entry Configurations from the paper, use:
560 #ax.set_title("Computed configurations")
563 if False and inits in scenario:
564 max_i = len(scenario[inits]) - 1
566 i = scenario[inits][ii]
567 plt.plot(*plot_car(i), color=inits_c)
568 plt.plot(i[0] - MINX, i[1] - MINY, color=inits_c, marker="+", ms=12)
570 i = scenario[inits][ii]
571 plt.plot(*plot_car(i), color=inits_c)
572 plt.plot(i[0] - MINX, i[1] - MINY, color=inits_c, marker="+", ms=12)
574 i = scenario[inits][ii]
575 plt.plot(*plot_car(i), color=inits_c)
576 plt.plot(i[0] - MINX, i[1] - MINY, color=inits_c, marker="+", ms=12)
577 ii = int(max_i * 3/4)
578 i = scenario[inits][ii]
579 plt.plot(*plot_car(i), color=inits_c)
580 plt.plot(i[0] - MINX, i[1] - MINY, color=inits_c, marker="+", ms=12)
582 i = scenario[inits][ii]
583 plt.plot(*plot_car(i), color=inits_c)
584 plt.plot(i[0] - MINX, i[1] - MINY, color=inits_c, marker="+", ms=12)
587 if True and inits in scenario:
588 max_i = len(scenario[inits]) - 1
590 i = scenario[inits][ii]
591 plt.plot(*plot_car(i), color=inits_c)
592 plt.plot(i[0] - MINX, i[1] - MINY, color=inits_c, marker="+", ms=12)
594 i = scenario[inits][ii]
595 plt.plot(*plot_car(i), color=inits_c)
596 plt.plot(i[0] - MINX, i[1] - MINY, color=inits_c, marker="+", ms=12)
598 i = scenario[inits][ii]
599 plt.plot(*plot_car(i), color=inits_c)
600 plt.plot(i[0] - MINX, i[1] - MINY, color=inits_c, marker="+", ms=12)
601 ii = int(max_i * 3/4)
602 i = scenario[inits][ii]
603 plt.plot(*plot_car(i), color=inits_c)
604 plt.plot(i[0] - MINX, i[1] - MINY, color=inits_c, marker="+", ms=12)
606 i = scenario[inits][ii]
607 plt.plot(*plot_car(i), color=inits_c)
608 plt.plot(i[0] - MINX, i[1] - MINY, color=inits_c, marker="+", ms=12)
609 # Possible/Candidate entries
615 # fontfamily="serif",
616 # fontstyle="italic",
619 # scenario["slot"][-1][0] - MINX,
620 # scenario["slot"][-1][1] - MINY,
628 # scenario["slot"][-1][0] - MINX - 2,
632 # fontfamily="serif",
633 # fontstyle="italic",
636 # Plot `init`, `entry`, and `goal` configurations.
637 if "init" in scenario and len(scenario["init"]) == 3:
638 plt.plot(*plot_car(scenario["init"]), color="red")
640 scenario["init"][0] - MINX,
641 scenario["init"][1] - MINY,
647 #if "init" in scenario and len(scenario["init"]) == 4:
648 # plt.plot(*plot_car(scenario["init"]), color="red")
649 # scenario["init"][2] = scenario["init"][3]
650 # plt.plot(*plot_car(scenario["init"]), color="red")
652 # scenario["init"][0] - MINX,
653 # scenario["init"][1] - MINY,
658 #if "entries" in scenario:
659 # for e in scenario["entries"]:
660 # plt.plot(*plot_car(e), color="orange")
668 if False and "entry" in scenario and len(scenario["entry"]) == 3:
669 plt.plot(*plot_car(scenario["entry"]), color="magenta")
671 scenario["entry"][0] - MINX,
672 scenario["entry"][1] - MINY,
678 if False and "entry" in scenario and len(scenario["entry"]) == 4:
679 esc = scenario["entry"]
680 plt.plot(*plot_car([esc[0], esc[1], esc[2]]), color="magenta")
681 plt.plot(*plot_car([esc[0], esc[1], esc[3]]), color="magenta")
683 scenario["entry"][0] - MINX,
684 scenario["entry"][1] - MINY,
689 if "goal" in scenario:
690 if len(scenario["goal"]) == 3:
691 #plt.plot(*plot_car(scenario["goal"]), color="green")
692 plt.plot(*plot_car(scenario["goal"]), color="orange")
694 scenario["goal"][0] - MINX,
695 scenario["goal"][1] - MINY,
702 # elif len(scenario["goal"]) == 4:
703 # ctp = scenario["goal"]
704 # plt.plot(*plot_car(scenario["goal"]), color="green")
706 # plt.plot(*plot_car(scenario["goal"]), color="green")
708 # scenario["goal"][0] - MINX,
709 # scenario["goal"][1] - MINY,
715 # Plot `path` and `max_path`.
716 if False and (sc2 and "opath" in sc2 and isinstance(sc2["opath"], list)
717 and len(sc2["opath"]) > 0):
718 plt.plot(*plot_nodes(sc2["opath"]), color="orange", linestyle="dotted")
719 if (sc2 and "path" in sc2 and isinstance(sc2["path"], list)
720 and len(sc2["path"]) > 0):
721 plt.plot(*plot_nodes(sc2["path"]), color="orange")
722 if False and ("opath" in scenario and isinstance(scenario["opath"], list)
723 and len(scenario["opath"]) > 0):
725 *plot_nodes(scenario["opath"]),
730 if ("path" in scenario and isinstance(scenario["path"], list)
731 and len(scenario["path"]) > 0):
732 plt.plot(*plot_nodes(scenario["path"]), color="blue")
734 for p in scenario["path"]:
736 pc = {36: "red", 0: "blue", -36: "green"}
737 pm = "o" if p[5] else "+"
738 plt.plot(p[0] - MINX, p[1] - MINY, color=pc[p[4]], marker=pm)
739 #plt.plot(*plot_car(p), color="blue")
741 #cc = plot_car_corners(p)
742 #plt.plot(cc[0][0], cc[1][0], color="red", marker=".", ms=1)
743 #plt.plot(cc[0][1], cc[1][1], color="red", marker=".", ms=1)
744 #plt.plot(cc[0][2], cc[1][2], color="red", marker=".", ms=1)
745 #plt.plot(cc[0][3], cc[1][3], color="red", marker=".", ms=1)
747 plt.plot(p[0] - MINX, p[1] - MINY, color="blue", marker="+")
748 if ("traj" in scenario and isinstance(scenario["traj"], list)
749 and len(scenario["traj"]) > 0):
750 print(len(scenario["traj"]))
751 # print(scenario["traj"])
752 print(len(plot_nodes(scenario["traj"])[0]))
753 # print(plot_nodes(scenario["traj"]))
754 plt.plot(*plot_nodes(scenario["traj"]), color="red")
755 plt.plot(*plot_car(scenario["traj"][-1]), color="red")
756 for p in scenario["traj"]:
759 color = "red" if p[3] == BicycleCar.max_wa else "darkred"
760 plt.plot(p[0] - MINX, p[1] - MINY, color=color, marker="+", markersize=2)
762 color = "green" if -p[3] == BicycleCar.max_wa else "darkgreen"
763 plt.plot(p[0] - MINX, p[1] - MINY, color=color, marker="x", markersize=2)
765 plt.plot(p[0] - MINX, p[1] - MINY, color="blue", marker=".", markersize=2)
767 plt.plot(p[0] - MINX, p[1] - MINY, color="red", marker=".")
768 #plt.plot(*plot_car(p), color="red")
770 #cc = plot_car_corners(p)
771 #plt.plot(cc[0][0], cc[1][0], color="red", marker=".", ms=1)
772 #plt.plot(cc[0][1], cc[1][1], color="red", marker=".", ms=1)
773 #plt.plot(cc[0][2], cc[1][2], color="red", marker=".", ms=1)
774 #plt.plot(cc[0][3], cc[1][3], color="red", marker=".", ms=1)
775 if False and "ispath" in scenario and len(scenario["ispath"]) > 0:
776 plt.plot(*plot_nodes(scenario["ispath"]), color="green")
777 for p in scenario["ispath"]:
778 #plt.plot(*plot_car(p), color="green")
780 #cc = plot_car_corners(p)
781 #plt.plot(cc[0][0], cc[1][0], color="red", marker=".", ms=1)
782 #plt.plot(cc[0][1], cc[1][1], color="red", marker=".", ms=1)
783 #plt.plot(cc[0][2], cc[1][2], color="red", marker=".", ms=1)
784 #plt.plot(cc[0][3], cc[1][3], color="red", marker=".", ms=1)
786 # If there are possible starts specified, you may print and plot them.
787 #if "starts" in scenario and len(scenario["starts"]) > 0:
788 # print("possible starts:")
789 # for p in scenario["starts"]:
790 # plt.plot(*p, color="red", marker="+", ms=12)
791 # print(" {}".format(p))
793 # For the Last Maneuver figure from the paper, use:
794 # - `init2` -- orange
795 #plt.plot(*plot_car(scenario["init2"]), color="orange")
797 # scenario["init2"][0] - MINX,
798 # scenario["init2"][1] - MINY,
803 # - `goal2` -- orange
804 #plt.plot(*plot_car(scenario["goal2"]), color="orange")
806 # scenario["goal2"][0] - MINX,
807 # scenario["goal2"][1] - MINY,
812 # - `goal2` -- middle (orange)
813 #plt.plot(*plot_car(scenario["goals"][0]), color="orange")
815 # scenario["goal2"][0] - MINX,
816 # scenario["goal2"][1] - MINY,
822 #plt.plot(*plot_car(scenario["init1"]), color="green")
824 # scenario["init1"][0] - MINX,
825 # scenario["init1"][1] - MINY,
831 #plt.plot(*plot_car(scenario["goal1"]), color="green")
833 # scenario["goal1"][0] - MINX,
834 # scenario["goal1"][1] - MINY,
840 # The `scenario` may also include:
841 # - `last` -- not sure what this is, see the source code. Maybe overlaps
843 # - `last1` -- used to demonstrate In-Slot Planner (was Parking Slot
845 # - `last2` -- used to demonstrate In-Slot Planner (was Parking Slot
847 # - `max_orig_path` -- maximum original path. I used this when comparing
848 # original paths but I had to copy the `max_orig_path` by hand from
849 # different scenario result.
850 # - `orig_path` -- the path before the optimization.
851 # - `max_path` -- the maximum path after optimization. Must be copied by
853 # - `path` -- optimized path of the scenario.
855 handles, labels = ax.get_legend_handles_labels()
857 # Uncommnent the following line and comment the plt.show() to store to the
859 #plt.savefig("out.pdf", bbox_inches="tight")
860 plt.savefig(argv[1] + ".pdf", bbox_inches="tight")
861 plt.savefig(argv[1] + ".png", bbox_inches="tight")