convert_xml.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 #
00004 # Convert the old style XML grasps file to new style YAML.
00005 #
00006 # rosrun sr_grasp convert_xml.py sr_hand/scripts/sr_hand/grasps.xml > converted.yaml
00007 #
00008 
00009 import sys
00010 import genpy
00011 from sr_hand.grasps_parser import GraspParser
00012 import sr_grasp
00013 from sr_robot_msgs.msg import GraspArray
00014 
00015 parser = GraspParser()
00016 parser.parse_tree(xml_filename=sys.argv[1])
00017 
00018 grasps = GraspArray()
00019 for name, g in parser.grasps.iteritems():
00020     ng = sr_grasp.Grasp()
00021     ng.id = name
00022     ng.set_grasp_point(positions=g.joints_and_positions)
00023     grasps.grasps.append(ng)
00024 
00025 # print grasps # oddly fails, but this works.
00026 print genpy.message.strify_message(grasps.grasps)


sr_grasp
Author(s): Mark Pitchless
autogenerated on Fri Aug 21 2015 12:26:28