33 import xml.etree.ElementTree
as ET
35 NS=
"{http://www.aldebaran-robotics.com/schema/choregraphe/position.xsd}" 39 for p
in motors.findall(NS +
"Motor"):
40 name = p.find(NS +
'name').text
41 value = float(p.find(NS +
'value').text)
43 value = math.radians(value)
50 """ Parses a Aldebaran Choregraphe posture library (.xap files) 51 into a Python dictionary of postures. 54 if not os.path.exists(xap_file):
55 raise RuntimeError(
"The XAP file %s does not exist." % xap_file)
58 tree = ET.parse(xap_file)
60 raise RuntimeError(
"The XAP file %s is not a valid XML file." % xap_file)
68 positions = [p
for p
in root.iter(NS +
'position')]
71 raise RuntimeError(
"The XAP file %s does not contain any pose." % xap_file)
74 name = p.find(NS +
'name').text
75 version = p.find(NS +
'version')
76 pose =
_makeJointDict(p.find(NS +
"Motors"), version
is not None and version.text==
'2')
82 if __name__ ==
"__main__":
85 if len(sys.argv) != 2:
86 print(
"Usage: python xapparser.py <file.xap>")
def _makeJointDict(motors, use_radians=True)
def getpostures(xap_file)