import numpy as np
import matplotlib.pyplot as plt
import sys

if sys.argc < 2:
    print "Usage ./plot_velocity_based_position_controller.py [File_name]"
    sys.exit(-1)

data = np.genfromtxt(sys.argv[-1], delimiter=',')
# 0 for x, 1 for y  2 for z and 3 for yaw
plot_axis = 3;
ts = (data[:,0] - data[0, 0])/1e9
plt.figure(1+plot_axis)
plt.subplot(2,1,1)
plt.plot(ts, data[:, 1+plot_axis]);
plt.ylabel('Error')
plt.subplot(2,1,2)
plt.plot(ts, data[:, 5+plot_axis]);
plt.ylabel('Cumulative Error')
plt.xlabel('Time (seconds)')
plt.show()
plt.figure(2+plot_axis)
plt.plot(ts, data[:, 9+plot_axis])
plt.ylabel('Control')
plt.xlabel('Time (seconds)')

@@ -1,12 +1,35 @@
+#!/usr/bin/env python2%0A
 import numpy
@@ -78,157 +78,475 @@
 ort 
-sys%0A%0Aif sys.argc %3C 2:%0A    print %22Usage ./plot_velocity_based_position_controller.py %5BFile_name%5D%22%0A    sys.exit(-1)%0A%0Adata = np.genfromtxt(sys.argv%5B-1%5D,
+argparse%0Aimport sys%0Aimport os%0A%0Aparser = argparse.ArgumentParser(%0A    prog='plot_velocity_based_position_controller')%0Aparser.add_argument('directory', type=str, help='Data directory')%0Aparser.add_argument(%0A    '-a', '--axis',%0A    type=int,%0A    default=0,%0A    help=%22Axis to plot can be 0 for x, 1, for y, 2 for z and 3 for yaw%22)%0Aargs = parser.parse_args()%0Adata = np.genfromtxt(%0A    os.path.join(%0A        args.directory,%0A        'velocity_based_position_controller'),%0A   
  del
@@ -555,16 +555,28 @@
 iter=','
+, names=True
 )%0A# 0 fo
@@ -627,10 +627,17 @@
 s = 
-3;
+args.axis
 %0Ats 
@@ -648,11 +648,14 @@
 ata%5B
-:,0
+'Time'
 %5D - 
@@ -663,18 +663,216 @@
 ata%5B
-0, 0%5D)/1e9
+'Time'%5D%5B0%5D) / 1e9%0Aerror_names = %5B'x_diff', 'y_diff', 'z_diff', 'yaw_diff'%5D%0Acumulative_error_names = %5B'xi_diff', 'yi_diff', 'zi_diff', 'yawi_diff'%5D%0Acontrol_names = %5B'cmd_vx', 'cmd_vy', 'cmd_vz', 'cmd_yawrate'%5D
 %0Aplt
@@ -880,26 +880,16 @@
 figure(1
-+plot_axis
 )%0Aplt.su
@@ -896,18 +896,20 @@
 bplot(2,
+ 
 1,
+ 
 1)%0Aplt.p
@@ -925,13 +925,20 @@
 ata%5B
-:, 1+
+error_names%5B
 plot
@@ -935,34 +935,34 @@
 names%5Bplot_axis%5D
+%5D
 )
-;
 %0Aplt.ylabel('Err
@@ -961,15 +961,30 @@
 bel(
-'E
+e
 rror
-'
+_names%5Bplot_axis%5D
 )%0Apl
@@ -995,18 +995,20 @@
 bplot(2,
+ 
 1,
+ 
 2)%0Aplt.p
@@ -1024,13 +1024,31 @@
 ata%5B
-:, 5+
+cumulative_error_names%5B
 plot
@@ -1057,10 +1057,10 @@
 xis%5D
+%5D
 )
-;
 %0Aplt
@@ -1067,18 +1067,17 @@
 .ylabel(
-'C
+c
 umulativ
@@ -1081,15 +1081,31 @@
 tive
- E
+_e
 rror
-'
+_names%5Bplot_axis%5D
 )%0Apl
@@ -1154,26 +1154,16 @@
 figure(2
-+plot_axis
 )%0Aplt.pl
@@ -1178,13 +1178,22 @@
 ata%5B
-:, 9+
+control_names%5B
 plot
@@ -1194,24 +1194,25 @@
 s%5Bplot_axis%5D
+%5D
 )%0Aplt.ylabel
@@ -1216,17 +1216,32 @@
 bel(
-'C
+c
 ontrol
-'
+_names%5Bplot_axis%5D
 )%0Apl

Fix plotting script