2 from collections 
import namedtuple
     7 Pose = namedtuple(
'Pose', [
'xyz', 
'rpy'], verbose=
True)
    12         for i 
in range(len(filter_array)):
    13                 loc_string = filter_array[i][
'@params'].split(
',')
    14                 loc = np.array(loc_string, dtype=float)
    16                 xyz = np.mean(loc.reshape((2,3)),0)/1000
    20                         xyz = [xyz[0], xyz[1], 0.075]
    22                         xyz = [xyz[1], xyz[0], xyz[2]]
    24                 pa.append(
Pose(xyz=xyz, rpy=rpy))
    29     resources = roslib.packages.find_resource(package_name, resource_name)
    30     if len(resources) == 0:
    31         rospy.logerr(
"Failed to find resource %s in package %s"%(resource_name, package_name))
    36 tactile_filename = 
get_path(
'graspit', 
'BarrettBH8_280_Tactile.xml')
    38 with open(tactile_filename) 
as fd:
    39     doc = xmltodict.parse(fd.read())
    44 barrett_sensors[
'palm'] = palm_sensors
    46 for index, chain_num 
in enumerate(range(len(doc[
'robot'][
'chain'])), 1):
    48         finger_sensors = 
get_pose_array(doc[
'robot'][
'chain'][chain_num][
'filter'], 
False)
    49         barrett_sensors[
'link{}'.format(index)] = finger_sensors
    53 for i, pose 
in enumerate(barrett_sensors[
'palm'], 1):
    54         text_poses += 
'<joint name="${{name}}_palm_sensor{}_joint" type="fixed">\n'.format(i)
    55         text_poses += 
'\t<origin xyz="{} {} {}" rpy="{} {} {}"/>\n'.format(pose.xyz[0], pose.xyz[1], pose.xyz[2], pose.rpy[0], pose.rpy[1], pose.rpy[2])
    56         text_poses += 
'\t<parent link="${name}_base_link"/>\n'    57         text_poses += 
'\t<child link="${{name}}_palm_sensor_{}_link"/>\n'.format(i)
    58         text_poses += 
'</joint>\n'    59         text_poses += 
'<link name="${{name}}_palm_sensor_{}_link"/>\n'.format(i)
    61 for link_num 
in range(1, 4):
    62         for i, pose 
in enumerate(barrett_sensors[
'link{}'.format(link_num)], 1):        
    63                 text_poses += 
'<joint name="${{name}}_link{}_sensor{}_joint" type="fixed">\n'.format(link_num, i)
    64                 text_poses += 
'\t<origin xyz="{} {} {}" rpy="{} {} {}"/>\n'.format(pose.xyz[0], pose.xyz[1], pose.xyz[2], pose.rpy[0], pose.rpy[1], pose.rpy[2])
    65                 text_poses += 
'\t<parent link="bh_finger_{}4_link"/>\n'.format(link_num)
    66                 text_poses += 
'\t<child link="${{name}}_link{}_sensor{}_link"/>\n'.format(link_num, i)
    67                 text_poses += 
'</joint>\n'    68                 text_poses += 
'<link name="${{name}}_link{}_sensor{}_link"/>\n'.format(link_num, i)
    72 pyperclip.copy(text_poses)
 
def get_path(package_name, resource_name)
def get_pose_array(filter_array, palm, rpy=[0)