00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 import roslib
00038 roslib.load_manifest('fingertip_pressure')
00039
00040 from fingertip_pressure.msg import PressureInfoElement
00041 from geometry_msgs.msg import Vector3
00042
00043 force_per_unit_table = [
00044 600,
00045 400,
00046 600,
00047 600,
00048 600,
00049 600,
00050 400,
00051 1600, 1600, 1600,
00052 1600, 1600, 1600,
00053 1600, 1600, 1600,
00054 1600, 1600, 1600,
00055 1600, 1600, 1600,
00056 ]
00057
00058
00059 coordinates = [
00060
00061 [ 29.3, 11.0, 0.0, 0.0, 0.0, 10.0, 2.8, 0.0, 0.0 ],
00062 [ 16.5, 5.2, 11.5, 12.0, 0.0, 0.0, 0.0, 3.0, 0.0 ],
00063 [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ],
00064 [ 35.0, 4.7, 3.5, 0.0, 0.0, 3.5, 0.0, -2.5, 0.0 ],
00065 [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ],
00066 [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ],
00067 [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ],
00068 [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ],
00069 [ 30.5, 0.0, 0.0, 0.0, 0.0, -2.8, 3.0, 0.0, 0.0 ],
00070 [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ],
00071 [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ],
00072 [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ],
00073 [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ],
00074 [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ],
00075 [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ],
00076 [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ],
00077 [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ],
00078 [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ],
00079 [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ],
00080 [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ],
00081 [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ],
00082 [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ],
00083 ]
00084
00085
00086 coordinates[2][0] = (coordinates[1][0] + coordinates[1][3] + coordinates[3][0]) / 2
00087 coordinates[2][1] = coordinates[3][1]
00088 coordinates[2][2] = (coordinates[1][2] + coordinates[3][2] + coordinates[3][5]) / 2
00089 coordinates[2][3] = (coordinates[1][0] + coordinates[1][3] - coordinates[3][0]) / 2
00090 coordinates[2][4] = 0
00091 coordinates[2][5] = (coordinates[1][2] - coordinates[3][2] - coordinates[3][5]) / 2
00092 for i in range(6,9):
00093 coordinates[2][i] = coordinates[3][i]
00094
00095
00096 def mirror(src, dest):
00097 coordinates[dest] = list(coordinates[src])
00098 coordinates[dest][2] = -coordinates[dest][2]
00099 coordinates[dest][5] = -coordinates[dest][5]
00100
00101 coordinates[dest][6] = -coordinates[dest][6]
00102 coordinates[dest][7] = -coordinates[dest][7]
00103
00104
00105 mirror(1, 6)
00106 mirror(2, 5)
00107 mirror(3, 4)
00108
00109
00110 def translate(src, dest, dir, k):
00111 coordinates[dest] = list(coordinates[src])
00112 for i in range(0,3):
00113 coordinates[dest][i] = coordinates[dest][i] + 2 * dir * coordinates[dest][i + 3 * k]
00114
00115
00116 translate(8, 7, 1, 1)
00117 translate(8, 9, -1, 1)
00118 for i in range(10, 22):
00119 translate(i-3, i, -1, 2)
00120
00121
00122 for i in range(0,22):
00123
00124 coordinates[i][0] = coordinates[i][0] - 4
00125 coordinates[i][1] = coordinates[i][1] - 15
00126
00127 coordinates[i][2] = -coordinates[i][2]
00128 coordinates[i][5] = -coordinates[i][5]
00129 coordinates[i][6] = -coordinates[i][6]
00130 coordinates[i][7] = -coordinates[i][7]
00131
00132 def multorientation(data, ori):
00133 for i in range(0, len(data)):
00134 data[i].y = data[i].y * ori
00135 data[i].z = data[i].z * ori
00136
00137 def extractvec(i):
00138 out = [];
00139 for j in range(0,len(coordinates)):
00140 v = Vector3()
00141 v.x = coordinates[j][i] / 1000.;
00142 v.y = coordinates[j][i+1] / 1000.;
00143 v.z = coordinates[j][i+2] / 1000.;
00144 out.append(v)
00145 return out
00146
00147 def pressureInformation(frame_id, orientation):
00148 msg = PressureInfoElement()
00149 msg.frame_id = frame_id
00150 msg.force_per_unit = force_per_unit_table
00151 msg.center = extractvec(0)
00152 msg.halfside1 = extractvec(3)
00153 msg.halfside2 = extractvec(6)
00154 multorientation(msg.center, orientation)
00155 multorientation(msg.halfside1, orientation)
00156 multorientation(msg.halfside2, orientation)
00157
00158
00159
00160
00161 return msg