00001 #!/usr/bin/env python 00002 # 00003 # Copyright 2011 Shadow Robot Company Ltd. 00004 # 00005 # This program is free software: you can redistribute it and/or modify it 00006 # under the terms of the GNU General Public License as published by the Free 00007 # Software Foundation, either version 2 of the License, or (at your option) 00008 # any later version. 00009 # 00010 # This program is distributed in the hope that it will be useful, but WITHOUT 00011 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 00013 # more details. 00014 # 00015 # You should have received a copy of the GNU General Public License along 00016 # with this program. If not, see <http://www.gnu.org/licenses/>. 00017 # 00018 00019 VERBOSE = 1 00020 00021 class Grasp: 00022 def __init__(self): 00023 self.grasp_name = "" 00024 self.joints_and_positions = {} 00025 00026 def display_grasp(self): 00027 print self.grasp_name 00028 print self.joints_and_positions 00029 00030 def convert_to_xml(self): 00031 grasp = ' <grasp name="'+self.grasp_name+'">'+'\n' 00032 for key, value in self.joints_and_positions.items(): 00033 grasp = grasp + ' <joint name="'+str(key)+'">'+str(value)+'</joint>\n' 00034 grasp = grasp + ' </grasp>'+'\n' 00035 return grasp