Go to the documentation of this file.00001
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
00019
00020 try:
00021 d_biased = self.subtract_bias(raw_data, 0)
00022
00023
00024
00025 calib_data = -d_biased / self.calibration_slope
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