18 """Analyze Grasp 3D - own module: a collection of several function for analyzing the grasps 21 from openravepy
import poseFromMatrix
22 import numpy, time, scipy, csv, os
23 import roslib.packages
29 meta_info = validgrasps[0]
30 object_name = meta_info[0]
31 gripper_type = meta_info[1]
34 directory = roslib.packages.get_pkg_dir(
'cob_grasp_generation')+
'/files/database/'+object_name
35 if not os.path.exists(directory):
36 os.makedirs(directory)
37 pathname_out = directory+
'/'+gripper_type+
'_'+object_name+
'.csv' 38 f_out = open(pathname_out,
'w+')
40 wr = csv.writer(f_out, delimiter=
',', quotechar=
'"', quoting=csv.QUOTE_ALL)
41 wr.writerow([
'id',
'object',
'sdh_knuckle_joint',
'sdh_finger_12_joint',
'sdh_finger_13_joint',
'sdh_finger_22_joint',
'sdh_finger_23_joint',
'sdh_thumb_2_joint',
'sdh_thumb_3_joint',
'direction',
'qw',
'qx',
'qy',
'qz',
'pos-x',
'pos-y',
'pos-z',
'eps_l1',
'vol_l1'])
44 for i
in range (1,len(validgrasps)):
46 actual_grasp = validgrasps[i]
47 row.append(str(actual_grasp[0]))
48 row.append(object_name)
53 joint_values = actual_grasp[1]
57 if joint_values[0] < 0:
61 joint_values_sorted = [joint_values[0], joint_values[3], joint_values[4], joint_values[1], joint_values[2], joint_values[5], joint_values[6]]
62 for i
in range(0,len(joint_values)):
63 row.append(joint_values_sorted[i])
66 globApproach = actual_grasp[7]
67 if globApproach[2] < -0.7:
73 trafo4x4 = actual_grasp[2]
75 pose = poseFromMatrix(trafo4x4)
76 pose[4] = m_in_mm * pose[4]
77 pose[5] = m_in_mm * pose[5]
78 pose[6] = m_in_mm * pose[6]
79 for i
in range(0,len(pose)):
83 row.append(
"%.9f" % actual_grasp[3])
84 row.append(
"%.9f" % actual_grasp[4])
87 row.append(actual_grasp[6])
90 if (
not actual_grasp[3] == 0.0)
and (
not actual_grasp[4] == 0.0):
def or_to_csv(validgrasps)