fabric_skin_calibration_node.py
Go to the documentation of this file.
00001 #!/usr/bin/python
00002 
00003 import numpy as np
00004 
00005 import roslib; roslib.load_manifest('hrl_fabric_based_tactile_sensor')
00006 roslib.load_manifest('hrl_meka_skin_sensor_darpa_m3')
00007 import rospy
00008 
00009 import hrl_meka_skin_sensor_darpa_m3.skin_patch_calibration as spc
00010 
00011 from std_msgs.msg import Empty
00012 
00013 class Fabric_Skin_Calibration(spc.SkinCalibration):
00014     def __init__(self):
00015         spc.SkinCalibration.__init__(self)
00016 
00017     def raw_data_to_force(self, raw_data):
00018         # this might change depending on the pull-up value (e.g.
00019         # different pullup values on the PR2 and Cody)
00020         try:
00021             d_biased = self.subtract_bias(raw_data, 0)
00022             #calib_data = -d_biased / 50. # calibration!
00023             #calib_data = -d_biased / 30. # calibration!
00024             #calib_data = -d_biased / 15. # calibration!
00025             calib_data = -d_biased / self.calibration_slope # calibration!
00026             idxs = (np.where(calib_data < self.max_ignore_value))[0]
00027             calib_data[idxs] = 0.
00028             return calib_data
00029         except ValueError:
00030             rospy.logerr('raw_data.shape: '+str(raw_data.shape))
00031             rospy.signal_shutdown('Error in the fabric skin driver or calibration node')
00032 
00033 def zero_sensor_cb(msg):
00034     fsc.compute_bias(rdc, 10)
00035 
00036 
00037 if __name__ == '__main__':
00038     import optparse
00039     p = optparse.OptionParser()
00040 
00041     p.add_option('--slope', action='store',
00042                  dest='slope', type='float',
00043                  help='slope of calibration line')
00044 
00045     p.add_option('--max_ignore_value', '--miv', action='store',
00046                  dest='miv', type='float',
00047                  help='max force to ignore (return as zero)')
00048 
00049     opt, args = p.parse_args()
00050 
00051     rospy.init_node('fabric_skin_calibration_node')
00052     
00053     fsc = Fabric_Skin_Calibration()
00054     fsc.precompute_taxel_location_and_normal()
00055     fsc.calibration_slope = opt.slope
00056     fsc.max_ignore_value = opt.miv
00057 
00058     rdc = spc.RawDataClient('taxels/raw_data')
00059     fsc.compute_bias(rdc, 100)
00060 
00061     rospy.Subscriber('zero_sensor', Empty, zero_sensor_cb)
00062 
00063     while not rospy.is_shutdown():
00064         d = rdc.get_raw_data(True)
00065         fsc.publish_taxel_array(d)
00066 


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