-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathanalys_plot.py
61 lines (52 loc) · 1.69 KB
/
analys_plot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import time
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import pickle
import glob
from utils import *
scenario = 1
index = 1
methods = ["rrt", "jianyou", "our"]
colors = ["green", "red", "blue"]
names = ["Theta-RRT", "FN-RRT", "Our"]
file_name = "reduce"
if scenario == 1:
from CreateModel1 import *
## Plot paths
fig = plt.figure()
ax = fig.add_subplot(111)
# Plot Model
if OBS_RECTANGLE is not None:
for (ox, oy, w, h) in OBS_RECTANGLE:
ax.add_patch(patches.Rectangle((ox, oy), w, h,
edgecolor='black',
facecolor='black',
fill=True))
if OBS_CIRCLE is not None:
for (ox, oy, r) in OBS_CIRCLE:
ax.add_patch(patches.Circle((ox, oy), r,
edgecolor='black',
facecolor='black',
fill=True))
# Plot path
for i, method in enumerate(methods):
print(method)
file = open("data/scen{}_{}_{}.txt".format(scenario, method, index), "rb")
d = pickle.load(file)
paths = d["paths"]
for path in paths:
ax.plot(np.array(path)[:,0], np.array(path)[:,1], colors[i], linewidth=2)
ax.plot([], [], colors[i], label=names[i])
# Plot start and goals
plt.plot(START[0], START[1], "bs", linewidth=5)
plt.plot(np.array(GOALS)[:,0], np.array(GOALS)[:,1], "rs", linewidth=5)
ax.legend()
ax.set_xlabel("x [m]")
ax.set_ylabel("y [m]")
ax.axis("scaled")
ax.set_xlim(X_RANGE)
ax.set_ylim(Y_RANGE)
plt.tight_layout()
plt.savefig("result/{}_scen{}_plot.pdf".format(file_name, scenario), format="pdf", bbox_inches="tight")
plt.show()