genikfast.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00004 #
00005 # Licensed under the Apache License, Version 2.0 (the "License");
00006 # you may not use this file except in compliance with the License.
00007 # You may obtain a copy of the License at
00008 #
00009 #   http://www.apache.org/licenses/LICENSE-2.0
00010 #
00011 # Unless required by applicable law or agreed to in writing, software
00012 # distributed under the License is distributed on an "AS IS" BASIS,
00013 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014 # See the License for the specific language governing permissions and
00015 # limitations under the License.
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)


cob_kinematics
Author(s): Mathias Lüdtke
autogenerated on Thu Jun 6 2019 21:22:51