sensor_model.py
Go to the documentation of this file.
00001 
00002 
00003 import matplotlib.pyplot as pp
00004 import numpy as np, math
00005 
00006 import roslib; roslib.load_manifest('sandbox_advait_darpa_m3')
00007 
00008 
00009 def one_over_x(x):
00010     return 1/x
00011 
00012 def one_over_x_square(x):
00013     return 1./(x**2.5)
00014 
00015 def compute_rho(p):
00016     return 300. * one_over_x_square(p/1000.)
00017 
00018 
00019 def compute_sensor_output(rho, r1, a):
00020     l = 1.
00021     rv = rho * l / a
00022     adc = rv/(r1+rv) * 1023
00023     return adc
00024 
00025 
00026 if __name__ == '__main__':
00027 
00028     if False:
00029         # testing the rho function
00030         p_arr = np.arange(10, 200, 2.) * 1000.
00031         #rho_list = map(one_over_x, p_arr)
00032         #rho_list = map(one_over_x_square, p_arr)
00033         rho_list = map(compute_rho, p_arr)
00034         pp.plot(p_arr / 1000., rho_list)
00035         pp.xlabel('pressure (kPa)')
00036         pp.ylabel('resistivity')
00037         pp.show()
00038     
00039 
00040     if True:
00041         f_arr = np.arange(1, 50, 0.1)
00042         a_list = [0.01**2, 0.02**2, 0.04**2]
00043         color_list = ['c', 'g', 'r']
00044 
00045         r1 = 470.
00046 
00047         pp.figure()
00048         for i in range(3):
00049             a = a_list[i]
00050             c = color_list[i]
00051             p_arr = f_arr/a
00052             rho_list = map(compute_rho, p_arr)
00053             adc_l = [compute_sensor_output(rho, r1, a) for rho in rho_list]
00054             lab = '%d cm'%(int(math.sqrt(a)*100))
00055             pp.scatter(adc_l, (p_arr/1000.).tolist(), marker='x', s=4, color=c,
00056                        label=lab)
00057 
00058         pp.xlabel('Tactile sensor output')
00059         pp.ylabel('Pressure (kPa)')
00060         pp.legend()
00061 
00062         pp.figure()
00063         for i in range(3):
00064             a = a_list[i]
00065             c = color_list[i]
00066             p_arr = f_arr/a
00067             rho_list = map(compute_rho, p_arr)
00068             adc_l = [compute_sensor_output(rho, r1, a) for rho in rho_list]
00069             lab = '%d cm'%(int(math.sqrt(a)*100))
00070             pp.scatter(adc_l, f_arr, marker='x', s=4, color=c,
00071                        label=lab)
00072 
00073         pp.xlabel('Tactile sensor output')
00074         pp.ylabel('Force (N)')
00075         pp.legend()
00076 
00077         pp.show()
00078 
00079 
00080 
00081 
00082 
00083 
00084 
00085 
00086 
00087 


hrl_fabric_based_tactile_sensor
Author(s): Advait Jain, Advisor: Prof. Charles C. Kemp. Healthcare Robotics Lab, Georgia Tech
autogenerated on Wed Nov 27 2013 12:02:33