Cheetah Software  1.0
plot_spline_opt.py
Go to the documentation of this file.
1 import numpy as np
2 import matplotlib
3 matplotlib.use('TkAgg')
4 import matplotlib.pyplot as plt
5 import os
6 
7 # Plot configuration
8 PLOT_VERTICALLY = 0
9 PLOT_HORIZONTALLY = 1
10 
11 # number of figures in this plot
12 num_figures = 5
13 
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
18 
19  file_path = os.getcwd() + "/../test_data/"
20 
21  ## read files
22  dim = 2
23  pos = np.genfromtxt(file_path+'opt_spline_pos.txt', delimiter=None, dtype=(float))
24  vel = np.genfromtxt(file_path+'opt_spline_vel.txt', delimiter=None, dtype=(float))
25  acc = np.genfromtxt(file_path+'opt_spline_acc.txt', delimiter=None, dtype=(float))
26  t = np.genfromtxt(file_path+'opt_spline_time.txt', delimiter='\n', dtype=(float))
27 
28  ## plot bspline
29  fig = plt.figure(figure_number)
30  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))
31  fig.canvas.set_window_title('pos')
32  for i in range(dim):
33  ax1 = plt.subplot(dim, 1, i+1)
34  plt.plot(t, pos[:,i], "b-")
35  plt.grid(True)
36  plt.xlabel('time (sec)')
37  ## increment figure number and index
38  figure_number += 1
39  if plot_configuration == PLOT_HORIZONTALLY:
40  col_index += 1
41  elif plot_configuration == PLOT_VERTICALLY:
42  row_index +=1
43 
44  ## plot vel
45  fig = plt.figure(figure_number)
46  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))
47  fig.canvas.set_window_title('vel')
48  for i in range(dim):
49  ax1 = plt.subplot(dim, 1, i+1)
50  plt.plot(t, vel[:,i], "b-")
51  plt.grid(True)
52  plt.xlabel('time (sec)')
53  ## increment figure number and index
54  figure_number += 1
55  if plot_configuration == PLOT_HORIZONTALLY:
56  col_index += 1
57  elif plot_configuration == PLOT_VERTICALLY:
58  row_index +=1
59 
60  ## plot bspline
61  fig = plt.figure(figure_number)
62  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))
63  fig.canvas.set_window_title('acc')
64  for i in range(dim):
65  ax1 = plt.subplot(dim, 1, i+1)
66  plt.plot(t, acc[:,i], "b-")
67  plt.grid(True)
68  plt.xlabel('time (sec)')
69  ## increment figure number and index
70  figure_number += 1
71  if plot_configuration == PLOT_HORIZONTALLY:
72  col_index += 1
73  elif plot_configuration == PLOT_VERTICALLY:
74  row_index +=1
75 
76 if __name__ == "__main__":
78  plt.show()
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)