Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 import openravepy
00019 from openravepy.ikfast import *
00020 import sys
00021 import os
00022 import logging
00023 import yaml
00024 import subprocess
00025 import roslib
00026
00027 if __name__ == '__main__':
00028 settings = yaml.load(open(sys.argv[1]))
00029 print settings
00030 format = logging.Formatter('%(levelname)s: %(message)s')
00031 handler = logging.StreamHandler(sys.stdout)
00032 handler.setFormatter(format)
00033 log.addHandler(handler)
00034 log.setLevel(logging.INFO)
00035
00036 convpath = os.path.join(os.path.dirname(sys.argv[0]),'urdf_openrave')
00037 xml = subprocess.check_output(convpath+" --urdf %s %s %s %s "% (settings['urdf_path'],settings['name'],settings['base_link'],settings['tip_link']),shell=True)
00038 try:
00039 env=openravepy.Environment()
00040 kinbody=env.ReadRobotXMLData(xml)
00041 env.Add(kinbody)
00042 links = [str(l.GetName()) for l in kinbody.GetLinks()]
00043 print links
00044 joints = [str(j.GetName()) for j in kinbody.GetJoints()]
00045 print joints
00046 solver = IKFastSolver(kinbody,kinbody)
00047 chaintree = solver.generateIkSolver(links.index(settings['base_link']),links.index(settings['tip_link']),[joints.index(f) for f in settings['free_joints']])
00048 code=solver.writeIkSolver(chaintree,lang='cpp')
00049 finally:
00050 openravepy.RaveDestroy()
00051 open(sys.argv[2],'w').write(code)