def localizeOrderBin(self): order_bin_xform = (so3.identity(),[0.57,0,-0.87]) resource.setDirectory("resources/") return resource.get("calibrated_order_bin.xform",type="RigidTransform",default=order_bin_xform,doedit=False) T = numpy.array([[ 1, 0, 0, 0.57 ], [ 0, 1, 0, 0 ], [ 0, 0, 1, -0.87 ], [ 0, 0, 0, 1 ]]) return (list(T[:3, :3].T.flat), list(T[:3, 3].flat))
def localizeShelf(self): #distance away shelf_xform = ([0,1,0,-1,0,0,0,0,1],[1.1,-0.055,-.9]) resource.setDirectory("resources/") return resource.get("calibrated_shelf.xform",type="RigidTransform",default=shelf_xform,doedit=False) T = numpy.array([[ 0, -1, 0, 1.1 ], # distance from front of robot [ 1, 0, 0, -0.055 ], # left/right [ 0, 0, 1, -0.9 ], # height [ 0, 0, 0, 1 ]]) return (list(T[:3, :3].T.flat), list(T[:3, 3].flat))
left_gripper_link_name = 'left_gripper' right_gripper_link_name = 'right_gripper' left_arm_geometry_indices = [15,16,17,18,19,21,22,23,30,31] right_arm_geometry_indices = [35,36,37,38,39,41,42,43,50,51] left_hand_link_start = 54 right_hand_link_start = 54+gripper.numDofs left_hand_geometry_indices = range(54,54+gripper.numDofs) right_hand_geometry_indices = range(54+gripper.numDofs,54+gripper.numDofs*2) #indices of the left and right arms in the Baxter robot file left_arm_link_names = ['left_upper_shoulder','left_lower_shoulder','left_upper_elbow','left_lower_elbow','left_upper_forearm','left_lower_forearm','left_wrist'] right_arm_link_names = ['right_upper_shoulder','right_lower_shoulder','right_upper_elbow','right_lower_elbow','right_upper_forearm','right_lower_forearm','right_wrist'] #local transformations (rotation, translation pairs) of the grasp center resource.setDirectory("resources/reflex") left_gripper_center_xform = resource.get("left_gripper_center.xform", type='RigidTransform', description="Left gripper center", world="klampt_models/"+klampt_model_name, frame=left_gripper_link_name) right_gripper_center_xform = resource.get("right_gripper_center.xform", type='RigidTransform', default=left_gripper_center_xform, description="Right gripper center", world="klampt_models/"+klampt_model_name, frame=right_gripper_link_name) #resting configuration rest_config = resource.get("baxter_rest.config",type="Config",description="Rest configuration",world="klampt_models/"+klampt_model_name)
world = WorldModel() world.readFile(os.path.join('../klampt_models/',grippermodule.klampt_model_name)) robot = world.robot(0) #load the items and spawn one in the world apc.load_item(objectname,gripper=grippername) item = apc.item_info[objectname] item.geometry = apc.load_item_geometry(item) itemposed = apc.ItemInBin(item,'blah') itemposed.xform = se3.identity() apc.spawn_item_in_world(itemposed,world) #set the directory print "Resouce directory is",os.path.join('../resources/',os.path.splitext(grippermodule.klampt_model_name)[0]) resource.setDirectory(os.path.join('../resources/',os.path.splitext(grippermodule.klampt_model_name)[0])) #edit the default configurations default_open_config = resource.get('default_open.config', description='Default hand open configuration', doedit='auto', world=world) default_closed_config = resource.get('default_closed.config', description='Default hand closed configuration', doedit='auto', world=world) def editNewGrasp(item,object,name=None,openClose=1): global world,robot global default_open_config,default_close_config
from klampt import resource from klampt import * print """resourcetest.py: This program gives an example of how to use the resource module.""" worldfile = "../../data/athlete_plane.xml" robotname = 'athlete' world = WorldModel() world.readFile(worldfile) #look in resources/athlete/ resource.setDirectory('resources/' + robotname) config = resource.get("resourcetest1.config", description="First config, always edited", doedit=True, editor='visual', world=world) print "Config 1:", config config = resource.get("resourcetest1.config", description="Trying this again...", editor='visual', world=world) print "Config 2:", config config = resource.get("resourcetest2.config", description="Another configuration", editor='visual', world=world)
#indices of the left and right grippers in the Baxter robot file left_gripper_link_name = 'left_gripper' right_gripper_link_name = 'right_gripper' left_arm_geometry_indices = [15,16,17,18,19,21,22,23,30,31] right_arm_geometry_indices = [35,36,37,38,39,41,42,43,50,51] left_hand_geometry_indices = [54,55,56] right_hand_geometry_indices = [57,58,59] #indices of the left and right arms in the Baxter robot file left_arm_link_names = ['left_upper_shoulder','left_lower_shoulder','left_upper_elbow','left_lower_elbow','left_upper_forearm','left_lower_forearm','left_wrist'] right_arm_link_names = ['right_upper_shoulder','right_lower_shoulder','right_upper_elbow','right_lower_elbow','right_upper_forearm','right_lower_forearm','right_wrist'] #local transformations (rotation, translation pairs) of the grasp center resource.setDirectory("../resources/rethink_electric_gripper") left_gripper_center_xform = resource.get("left_gripper_center.xform", type='RigidTransform', description="Left gripper center", world="../klampt_models/"+klampt_model_name, frame=left_gripper_link_name) right_gripper_center_xform = resource.get("right_gripper_center.xform", type='RigidTransform', default=left_gripper_center_xform, description="Right gripper center", world="../klampt_models/"+klampt_model_name, frame=right_gripper_link_name) #resting configuration rest_config = resource.get("baxter_rest.config",type="Config",description="Rest configuration",world="../klampt_models/"+klampt_model_name)
from klampt import resource from klampt import * print """resourcetest.py: This program gives an example of how to use the resource module.""" worldfile = "../../data/athlete_plane.xml" robotname = 'athlete' world = WorldModel() world.readFile(worldfile) #look in resources/athlete/ resource.setDirectory('resources/'+robotname) config = resource.get("resourcetest1.config",description="First config, always edited",doedit=True,editor='visual',world=world) print "Config 1:",config config = resource.get("resourcetest1.config",description="Trying this again...",editor='visual',world=world) print "Config 2:",config config = resource.get("resourcetest2.config",description="Another configuration",editor='visual',world=world) print "Config 3:",config if config != None: config[3] += 1.0 resource.set("resourcetest3_high.config",config) world.robot(0).setConfig(config) #testing transform editor xform = resource.get(name=None,type='RigidTransform',frame=world.robot(0).getLink(5).getTransform(),world=world)
if not visualization.shown(): break visualization.lock() q = world.robot(0).getConfig() q[9] = -1.0 world.robot(0).setConfig(q) visualization.unlock() time.sleep(1.0) if not visualization.shown(): break print "Hiding visualization window" visualization.show(False) """ # look in resources/athlete/ resource.setDirectory("resources/" + robotname) config1 = resource.get( "resourcetest1.config", description="First config, always edited", doedit=True, editor="visual", world=world ) print "Config 1:", config1 config2 = resource.get("resourcetest1.config", description="Trying this again...", editor="visual", world=world) print "Config 2:", config2 config3 = resource.get("resourcetest2.config", description="Another configuration", editor="visual", world=world) print "Config 3:", config3 if config3 != None: config3hi = config3[:] config3hi[3] += 1.0 resource.set("resourcetest3_high.config", config3hi)
"left_upper_forearm", "left_lower_forearm", "left_wrist", ] right_arm_link_names = [ "right_upper_shoulder", "right_lower_shoulder", "right_upper_elbow", "right_lower_elbow", "right_upper_forearm", "right_lower_forearm", "right_wrist", ] # local transformations (rotation, translation pairs) of the grasp center resource.setDirectory("resources/reflex") left_gripper_center_xform = resource.get( "left_gripper_center.xform", type="RigidTransform", description="Left gripper center", world="klampt_models/" + klampt_model_name, frame=left_gripper_link_name, ) right_gripper_center_xform = resource.get( "right_gripper_center.xform", type="RigidTransform", description="Right gripper center", world="klampt_models/" + klampt_model_name, frame=right_gripper_link_name, )
54 + gripper.numDofs * 2) #indices of the left and right arms in the Baxter robot file left_arm_link_names = [ 'left_upper_shoulder', 'left_lower_shoulder', 'left_upper_elbow', 'left_lower_elbow', 'left_upper_forearm', 'left_lower_forearm', 'left_wrist' ] right_arm_link_names = [ 'right_upper_shoulder', 'right_lower_shoulder', 'right_upper_elbow', 'right_lower_elbow', 'right_upper_forearm', 'right_lower_forearm', 'right_wrist' ] #local transformations (rotation, translation pairs) of the grasp center resource.setDirectory("resources/reflex") left_gripper_center_xform = resource.get("left_gripper_center.xform", type='RigidTransform', description="Left gripper center", world="klampt_models/" + klampt_model_name, frame=left_gripper_link_name) right_gripper_center_xform = resource.get("right_gripper_center.xform", type='RigidTransform', default=left_gripper_center_xform, description="Right gripper center", world="klampt_models/" + klampt_model_name, frame=right_gripper_link_name) #resting configuration
#indices of the left and right grippers in the Baxter robot file left_gripper_link_name = 'left_gripper' right_gripper_link_name = 'right_gripper' left_arm_geometry_indices = [15,16,17,18,19,21,22,23,30,31] right_arm_geometry_indices = [35,36,37,38,39,41,42,43,50,51] left_hand_geometry_indices = [54,55,56] right_hand_geometry_indices = [57,58,59] #indices of the left and right arms in the Baxter robot file left_arm_link_names = ['left_upper_shoulder','left_lower_shoulder','left_upper_elbow','left_lower_elbow','left_upper_forearm','left_lower_forearm','left_wrist'] right_arm_link_names = ['right_upper_shoulder','right_lower_shoulder','right_upper_elbow','right_lower_elbow','right_upper_forearm','right_lower_forearm','right_wrist'] #local transformations (rotation, translation pairs) of the grasp center resource.setDirectory("resources/rethink_electric_gripper") package_root = os.path.join(os.path.expanduser("~"),"ece590-s2015") klampt_model_path = os.path.join(package_root,"klampt_models") resource.setDirectory(package_root) left_gripper_center_xform = resource.get("left_gripper_center.xform", type='RigidTransform', description="Left gripper center", world=os.path.join(klampt_model_path,klampt_model_name), frame=left_gripper_link_name) right_gripper_center_xform = resource.get("right_gripper_center.xform", type='RigidTransform', default=left_gripper_center_xform, description="Right gripper center", world=os.path.join(klampt_model_path,klampt_model_name), frame=right_gripper_link_name)