forked from krishauser/pyOptimalMotionPlanning
-
Notifications
You must be signed in to change notification settings - Fork 1
/
viewsummary.py
executable file
·150 lines (141 loc) · 5.19 KB
/
viewsummary.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/usr/bin/env python
import sys
import numpy as np
import matplotlib.pyplot as plt
import csv
import math
from collections import defaultdict
if len(sys.argv) < 3:
print "Usage: viewsummary.py csvfile item"
exit(0)
successFraction = 0.5
labelmap = {"lazy_rrgstar":"Lazy-RRG*",
"lazy_birrgstar":"Lazy-BiRRG*",
"prmstar":"PRM*",
"fmmstar":"FMM*",
"lazy_prmstar":"Lazy-PRM*",
"lazy_rrgstar_subopt_0.1":"Lazy LBT-RRG*, eps=0.1",
"lazy_rrgstar_subopt_0.2":"Lazy LBT-RRG*, eps=0.2",
"fmtstar":"FMT*",
#"rrtstar":"RRT*",
"birrtstar":"RRT*",
"rrtstar_subopt_0.1":"LBT-RRT*(0.1)",
"rrtstar_subopt_0.2":"LBT-RRT*(0.2)",
}
#labelorder = ["restart_rrt_shortcut","prmstar","fmmstar","rrtstar","birrtstar","rrtstar_subopt_0.1","rrtstar_subopt_0.2","lazy_prmstar","lazy_rrgstar","lazy_birrgstar"]
labelorder = ["ao_rrt","ao_est","repeated_rrt","repeated_est","repeated_rrt_prune","repeated_est_prune","stable_sparse_rrt","anytime_rrt","rrtstar"]
dashes = [[],[8,8],[4,4],[2,2],[1,1],[12,6],[4,2,2,2],[8,2,2,2,2,2],[6,2],[2,6]]
ylabelmap = {"best cost":"Path length",
"numEdgeChecks":"# edge checks",
}
timevarname = 'time'
#timevarname = 'numMilestones'
item = sys.argv[2]
with open(sys.argv[1],'r') as f:
reader = csv.DictReader(f)
items = defaultdict(list)
for row in reader:
time = dict()
vmean = dict()
vstd = dict()
vmin = dict()
vmax = dict()
skip = dict()
for (k,v) in row.iteritems():
v = float(v) if len(v) > 0 else None
words = k.split(None,1)
label = words[0]
if len(words) >= 2 and words[1] == timevarname:
time[label] = v
for (k,v) in row.iteritems():
v = float(v) if len(v) > 0 else None
words = k.split(None,1)
label = words[0]
if item == 'best cost' and len(words) >= 2 and words[1] == 'success fraction':
if v < successFraction:
skip[label] = True
else:
skip[label] = False
if len(words) >= 2 and words[1].startswith(item):
suffix = words[1][len(item)+1:]
if suffix=='mean': #will have min,max,mean,etc
vmean[label] = v
elif suffix=='std':
vstd[label] = v
elif suffix=='max':
vmax[label] = v
elif suffix=='min':
vmin[label] = v
elif suffix=='':
vmean[label] = v
else:
print "Warning, unknown suffix",suffix
for label,t in time.iteritems():
if label in skip and skip[label]:
items[label].append((t,None))
elif label in vmean:
items[label].append((t,vmean[label]))
else:
print "Warning, no item",item,"for planner",label,"read"
print "Available planners:",items.keys()
#small, good for printing
#fig = plt.figure(figsize=(4,2.7))
fig = plt.figure(figsize=(7,5))
ax1 = fig.add_subplot(111)
if timevarname=='time':
ax1.set_xlabel("Time (s)")
else:
ax1.set_xlabel("Iterations")
minx = 0
maxx = 0
ax1.set_ylabel(ylabelmap.get(item,item))
for n,label in enumerate(labelorder):
if label not in items: continue
plot = items[label]
if len(items[label])==0:
print "Skipping item",label
x,y = zip(*plot)
minx = min(minx,*[v for v in x if v is not None])
maxx = max(maxx,*[v for v in x if v is not None])
plannername = labelmap[label] if label in labelmap else label
print "Plotting",plannername
line = ax1.plot(x,y,label=plannername,dashes=dashes[n])
plt.setp(line,linewidth=1.5)
#plt.legend(loc='upper right');
plt.legend();
#good for bugtrap cost
#plt.ylim([2,3])
#good for other cost
#plt.ylim([1,2])
#good for edge checks
if item=="numEdgeChecks":
plt.ylim([0,800])
else:
#plt.ylim([2,2.8])
pass
if timevarname=='time':
if sys.argv[1].startswith('tx90'):
plt.xlim([0,20])
elif sys.argv[1].startswith('baxter'):
plt.xlim([0,60])
elif sys.argv[1].startswith('bar_25'):
plt.xlim([0,20])
else:
plt.xlim([math.floor(minx),math.ceil(maxx)])
else:
plt.xlim([0,5000])
# The frame is matplotlib.patches.Rectangle instance surrounding the legend
#frame = legend.get_frame()
#frame.set_facecolor('0.97')
# Set the fontsize
#legend = ax1.legend(loc='upper center', bbox_to_anchor=(0.5, 1.4),
# ncol=3, fancybox=True, columnspacing=0, handletextpad=0, shadow=False)
#for label in legend.get_texts():
# label.set_fontsize(9)
#box = ax1.get_position()
#ax1.set_position([box.x0, box.y0, box.width, box.height* 0.8])
#plt.setp(ax1.get_xticklabels(),fontsize=12)
#plt.setp(ax1.get_yticklabels(),fontsize=12)
#start,end = ax1.get_ylim()
#ax1.yaxis.set_ticks(np.arange(start, end, 0.1))
plt.show()