3 matplotlib.use(
'TkAgg')
4 import matplotlib.pyplot
as plt
14 def create_figures(subfigure_width=480, subfigure_height=600, starting_figure_no=1, starting_col_index = 0, starting_row_index=0, plot_configuration=PLOT_HORIZONTALLY):
15 figure_number = starting_figure_no
16 col_index = starting_col_index
17 row_index = starting_row_index
19 file_path = os.getcwd() +
"/../test_data/" 22 bezier_pos = np.genfromtxt(file_path+
'bezier_pos.txt', delimiter=
None, dtype=(float))
23 bezier_vel = np.genfromtxt(file_path+
'bezier_vel.txt', delimiter=
None, dtype=(float))
24 t = np.genfromtxt(file_path+
'bz_time.txt', delimiter=
'\n', dtype=(float))
26 bspline_pos = np.genfromtxt(file_path+
'bspline_pos.txt', delimiter=
None, dtype=(float))
27 bspline_vel = np.genfromtxt(file_path+
'bspline_vel.txt', delimiter=
None, dtype=(float))
28 bspline_acc = np.genfromtxt(file_path+
'bspline_acc.txt', delimiter=
None, dtype=(float))
29 bs_t = np.genfromtxt(file_path+
'bs_time.txt', delimiter=
'\n', dtype=(float))
31 numeric_bezier_vel = np.copy(bezier_pos)
33 for i
in range(bz_length-1):
34 numeric_bezier_vel[i,:] = (bezier_pos[i+1,:] - bezier_pos[i,:])/(t[i+1]-t[i])
36 numeric_bspline_vel = np.copy(bspline_pos)
37 numeric_bspline_acc = np.copy(bspline_pos)
39 for i
in range(bs_length-1):
40 numeric_bspline_vel[i,:] = (bspline_pos[i+1,:] - bspline_pos[i,:])/(bs_t[i+1]-bs_t[i])
41 numeric_bspline_acc[i,:] = (bspline_vel[i+1,:] - bspline_vel[i,:])/(bs_t[i+1]-bs_t[i])
44 fig = plt.figure(figure_number)
45 plt.get_current_fig_manager().window.wm_geometry(str(subfigure_width) +
"x" + str(subfigure_height) +
"+" + str(subfigure_width*col_index) +
"+" + str(subfigure_height*row_index))
46 fig.canvas.set_window_title(
'bezier_pos')
48 ax1 = plt.subplot(3, 1, i+1)
49 plt.plot(t, bezier_pos[:,i],
"b-")
51 plt.xlabel(
'time (sec)')
54 if plot_configuration == PLOT_HORIZONTALLY:
56 elif plot_configuration == PLOT_VERTICALLY:
60 fig = plt.figure(figure_number)
61 plt.get_current_fig_manager().window.wm_geometry(str(subfigure_width) +
"x" + str(subfigure_height) +
"+" + str(subfigure_width*col_index) +
"+" + str(subfigure_height*row_index))
62 fig.canvas.set_window_title(
'bezier_vel')
64 ax1 = plt.subplot(3, 1, i+1)
65 plt.plot(t, bezier_vel[:,i],
"b-")
66 plt.plot(t[:-1], numeric_bezier_vel[:-1,i],
"r-")
68 plt.xlabel(
'time (sec)')
71 if plot_configuration == PLOT_HORIZONTALLY:
73 elif plot_configuration == PLOT_VERTICALLY:
77 fig = plt.figure(figure_number)
78 plt.get_current_fig_manager().window.wm_geometry(str(subfigure_width) +
"x" + str(subfigure_height) +
"+" + str(subfigure_width*col_index) +
"+" + str(subfigure_height*row_index))
79 fig.canvas.set_window_title(
'bspline_pos')
81 ax1 = plt.subplot(3, 1, i+1)
82 plt.plot(bs_t, bspline_pos[:,i],
"b-")
84 plt.xlabel(
'time (sec)')
87 if plot_configuration == PLOT_HORIZONTALLY:
89 elif plot_configuration == PLOT_VERTICALLY:
93 fig = plt.figure(figure_number)
94 plt.get_current_fig_manager().window.wm_geometry(str(subfigure_width) +
"x" + str(subfigure_height) +
"+" + str(subfigure_width*col_index) +
"+" + str(subfigure_height*row_index))
95 fig.canvas.set_window_title(
'bspline_vel')
97 ax1 = plt.subplot(3, 1, i+1)
98 plt.plot(bs_t, bspline_vel[:,i],
"b-")
99 plt.plot(bs_t[:-1], numeric_bspline_vel[:-1,i],
"r-")
101 plt.xlabel(
'time (sec)')
104 if plot_configuration == PLOT_HORIZONTALLY:
106 elif plot_configuration == PLOT_VERTICALLY:
110 fig = plt.figure(figure_number)
111 plt.get_current_fig_manager().window.wm_geometry(str(subfigure_width) +
"x" + str(subfigure_height) +
"+" + str(subfigure_width*col_index) +
"+" + str(subfigure_height*row_index))
112 fig.canvas.set_window_title(
'bspline_acc')
114 ax1 = plt.subplot(3, 1, i+1)
115 plt.plot(bs_t, bspline_acc[:,i],
"b-")
116 plt.plot(bs_t[:-1], numeric_bspline_acc[:-1,i],
"r-")
118 plt.xlabel(
'time (sec)')
121 if plot_configuration == PLOT_HORIZONTALLY:
123 elif plot_configuration == PLOT_VERTICALLY:
126 if __name__ ==
"__main__":
def create_figures(subfigure_width=480, subfigure_height=600, starting_figure_no=1, starting_col_index=0, starting_row_index=0, plot_configuration=PLOT_HORIZONTALLY)