00001 #!/usr/bin/python 00002 ################################################################# 00003 ##\file 00004 # 00005 # \note 00006 # Copyright (c) 2012 \n 00007 # Robotnik Automation SLL \n\n 00008 # 00009 ################################################################# 00010 # 00011 # \note 00012 # Project name: srs 00013 # \note 00014 # ROS stack name: srs_public 00015 # \note 00016 # ROS package name: srs_grasping 00017 # 00018 # \author 00019 # Author: Manuel Rodriguez, email:mrodriguez@robotnik.es 00020 # \author 00021 # Supervised by: Manuel Rodriguez, email:mrodriguez@robotnik.es 00022 # 00023 # \date Date of creation: March 2012 00024 # 00025 # \brief 00026 # Implements the simulation for the precomputed grasps. 00027 # 00028 ################################################################# 00029 # 00030 # Redistribution and use in source and binary forms, with or without 00031 # modification, are permitted provided that the following conditions are met: 00032 # 00033 # - Redistributions of source code must retain the above copyright 00034 # notice, this list of conditions and the following disclaimer. \n 00035 # - Redistributions in binary form must reproduce the above copyright 00036 # notice, this list of conditions and the following disclaimer in the 00037 # documentation and/or other materials provided with the distribution. \n 00038 # - Neither the name of the Robotnik Automation SLL nor the names of its 00039 # contributors may be used to endorse or promote products derived from 00040 # this software without specific prior written permission. \n 00041 # 00042 # This program is free software: you can redistribute it and/or modify 00043 # it under the terms of the GNU Lesser General Public License LGPL as 00044 # published by the Free Software Foundation, either version 3 of the 00045 # License, or (at your option) any later version. 00046 # 00047 # This program is distributed in the hope that it will be useful, 00048 # but WITHOUT ANY WARRANTY; without even the implied warranty of 00049 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00050 # GNU Lesser General Public License LGPL for more details. 00051 # 00052 # You should have received a copy of the GNU Lesser General Public 00053 # License LGPL along with this program. 00054 # If not, see <http://www.gnu.org/licenses/>. 00055 # 00056 ################################################################# 00057 00058 import roslib; 00059 roslib.load_manifest('srs_grasping') 00060 import rospy 00061 import sys 00062 import grasping_functions 00063 00064 from srs_grasping.srv import * 00065 00066 00067 00068 class grasp_simulation(): 00069 00070 def __init__(self): 00071 00072 self.get_grasp_configurations_service = rospy.ServiceProxy('get_db_grasps', GetDBGrasps) 00073 00074 00075 def run(self, object_id): 00076 00077 req = GetDBGraspsRequest(object_id=object_id) 00078 res = self.get_grasp_configurations_service(req) 00079 grasps = res.grasp_configuration 00080 grasping_functions.openraveutils.show_all_grasps(object_id, grasps); 00081 00082 00083 00084 if __name__ == "__main__": 00085 00086 rospy.init_node('grasp_simulation') 00087 s = grasp_simulation() 00088 00089 if len(sys.argv) == 1: 00090 print "---------------------------------------------------------------------------------------" 00091 print "usage:\t\trosrun srs_grasping test_simulation [object_id]\ndefault:\tobject_id: 9 (Milkbox)" 00092 print "---------------------------------------------------------------------------------------" 00093 s.run(9) 00094 else: 00095 s.run(int(sys.argv[1]))