3 import matplotlib.pyplot, numpy, mpl_toolkits.mplot3d.axes3d
4 from BayesianCurveFitting
import *
8 parser = argparse.ArgumentParser(description=
'plot data from rosbag')
9 parser.add_argument(
'inbag', type=str, help=
'input bag file', metavar=
'bagfile')
10 parser.add_argument(
'-t', type=int, help=
'1 or 2', metavar=
'graph type', choices=[1, 2], default=2)
11 parser.add_argument(
'-u', type=int, help=
'step in u', default=80)
12 parser.add_argument(
'-v', type=int, help=
'step in v', default=80)
13 parser.add_argument(
'-d', type=float, help=
'step in depth', default=0.1)
14 parser.add_argument(
'--max_depth', type=float, help=
'maximum depth', default=1.5)
15 parser.add_argument(
'-D', type=int, help=
'D degree polynomial', default=2)
16 parser.add_argument(
'-a', type=float, help=
'ALPHA', default=0.005)
17 parser.add_argument(
'-b', type=float, help=
'BETA', default=11.1)
18 return parser.parse_args()
22 for v_i
in range(0, v_num):
24 for u_i
in range(0, u_num):
25 data_list[v_i].append([])
34 f, (axes_array) = matplotlib.pyplot.subplots(len(data_list), len(data_list[0]), sharex=
'col', sharey=
'row')
36 for topic, msg, t
in b.read_messages():
39 if abs((msg.observed_depth - msg.true_depth) * 1000) < 1000:
40 data_list[v_i][u_i].append([msg.observed_depth,
41 (msg.observed_depth - msg.true_depth) * 1000])
42 for x
in range(0, len(axes_array[0])):
43 for y
in range(0, len(axes_array)):
44 xlist = [tmp[0]
for tmp
in data_list[y][x]]
45 ylist = [tmp[1]
for tmp
in data_list[y][x]]
47 axes_array[y][x].plot(xlist, ylist,
'.')
48 axes_array[y][x].plot(bcf[0], bcf[1],
'r-')
49 axes_array[y][x].plot(bcf[0], bcf[2],
'g--')
50 axes_array[y][x].plot(bcf[0], bcf[3],
'g--')
51 axes_array[y][x].set_title(
'u : %d~%d, v : %d~%d' % (x*step_u, (x+1)*step_u, y*step_v, (y+1)*step_v))
52 matplotlib.pyplot.show()
57 for d_i
in range(d_num):
62 max_depth = args.max_depth
65 fig = matplotlib.pyplot.figure(figsize=matplotlib.pyplot.figaspect(0.5))
67 for i
in range(len(data_list)):
68 axes_array.append(fig.add_subplot(int(sqrt(len(data_list))) + 1, int(sqrt(len(data_list))) + 1, i+1, projection=
'3d'))
70 for topic, msg, t
in b.read_messages():
71 if msg.true_depth < step_d * len(data_list):
72 d_i = int(msg.true_depth / step_d)
73 if abs((msg.observed_depth - msg.true_depth) * 1000) < 1000:
74 data_list[d_i].append([msg.u, msg.v,
75 (msg.observed_depth - msg.true_depth) * 1000])
76 for d
in range(len(axes_array)):
77 xlist = numpy.array([tmp[0]
for tmp
in data_list[d]])
78 ylist = numpy.array([tmp[1]
for tmp
in data_list[d]])
79 X, Y = numpy.meshgrid(xlist, ylist)
80 zlist = numpy.array([tmp[2]
for tmp
in data_list[d]])
81 axes_array[d].scatter3D(xlist, ylist, zlist, c=
'b', marker=
'o')
84 axes_array[d].set_title(
'd : %.2f~%.2f[m]' % (d*step_d, (d+1)*step_d))
85 matplotlib.pyplot.show()
96 if __name__ ==
'__main__':
def setup_data_list2(d_num)
def setup_data_list(v_num, u_num)