3 from argparse
import ArgumentParser
5 import matplotlib.pyplot
as plt
6 from matplotlib.backends.backend_pdf
import PdfPages
14 if data_filename
is None:
15 data_filename =title+
'.dat' 16 data = np.genfromtxt(args.data_dirname+
'/'+data_filename,
17 dtype=np.float32, delimiter=
' ', names=
True)
19 for name
in data.dtype.names[1:]:
21 ax.plot(t, d, linewidth=2, label=name)
24 ax.set_title(title, fontsize=18)
26 ax.legend(loc=
'upper center', bbox_to_anchor=(0.5, -0.05), ncol=4)
27 ax.set_xlim(t[0], t[-1])
30 if time_list
is not None:
32 ax.axvline(x=t, linewidth=0.8, color=
'k', linestyle=
'--')
35 if __name__ ==
'__main__':
38 parser = ArgumentParser()
40 parser.add_argument(
'--data-dirname', type=str, dest=
"data_dirname", required=
True)
41 parser.add_argument(
'--output-filename', type=str, dest=
"output_filename", required=
True)
43 parser.add_argument(
'--kin-task-time-list', nargs=
"*", type=float, dest=
"kin_task_time_list", default=
None)
44 parser.add_argument(
'--eom-task-time-list', nargs=
"*", type=float, dest=
"eom_task_time_list", default=
None)
45 parser.add_argument(
'--centroid-task-time-list', nargs=
"*", type=float, dest=
"centroid_task_time_list", default=
None)
46 parser.add_argument(
'--posture-task-time-list', nargs=
"*", type=float, dest=
"posture_task_time_list", default=
None)
48 args = parser.parse_args()
50 fig,axes = plt.subplots(nrows=10,ncols=1,figsize=(10,100))
52 plot_data(axes[0], title=
'theta', ylabel=
'joint position [rad] [m]')
53 plot_data(axes[1], title=
'cog', ylabel=
'position [m]')
54 plot_data(axes[2], title=
'angular_momentum', ylabel=
'angular momentum [kg m^2 / s]')
55 plot_data(axes[3], title=
'wrench', ylabel=
'force [N] / moment [Nm]')
57 plot_data(axes[4], title=
"kinematics_task", ylabel=
'position [m] / orientation [rad]', time_list=args.kin_task_time_list)
58 plot_data(axes[5], title=
"translational_eom_task", ylabel=
'force [N]', time_list=args.eom_task_time_list)
59 plot_data(axes[6], title=
"rotational_eom_task", ylabel=
'moment [Nm]', time_list=args.eom_task_time_list)
60 plot_data(axes[7], title=
"cog_task", ylabel=
'position [m]', time_list=args.centroid_task_time_list)
61 plot_data(axes[8], title=
"angular_momentum_task", ylabel=
'angular momentum [kg m^2 / s]', time_list=args.centroid_task_time_list)
62 plot_data(axes[9], title=
"posture_task", ylabel=
'joint position [rad] [m]', time_list=args.posture_task_time_list)
67 pdf = PdfPages(args.output_filename)
def plot_data(ax, title, ylabel, data_filename=None, time_list=None)