Commit e7ba1a73 authored by gxiang's avatar gxiang
Browse files

Merge branch 'openloop' of https://gitlab.eecs.umich.edu/gxiang/mobilebot into openloop

parents 511847b6 c8a2cabb
import sys
import os
import numpy as np
#import matplotlib.pyplot as plt
import matplotlib.pyplot as plt
if len(sys.argv) < 2:
if len(sys.argv) < 3:
sys.stderr.write("usage: plot_calibration.py <datafile>")
sys.exit(1)
file = sys.argv[1]
f = open(file, "r");
lines = f.readlines();
data = numpy.asarray([[float(val) for val in line.split()] for line in lines[1:]])
print(data)
data = np.asarray([[float(val) for val in line.split()] for line in lines[1:]])
init = 0
p2 = plt.plot(data[:,0], data[:,0], 'r', label="pwm cmd")
p3 = plt.plot(data[:,0], data[:,1], 'b', label="velocity")
plt.legend(loc="upper right")
filename, file_extension = os.path.splitext(file)
plt.savefig(filename + '.png')
plt.show()
coef = np.polyfit(data[:,0],data[:,1],1)
poly1d_fn = np.poly1d(coef)
p2 = plt.plot(data[:,0], data[:,1], 'bo', label="pwm vs velocity(m/s)")
plt.plot(data[:,0], data[:,1], 'yo', data[:,0], poly1d_fn(data[:,0]), '--k')
plt.legend(loc="upper right")
filename = sys.argv[2]
plt.savefig( filename+ '.png')
plt.show()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment