bool configure(ResourceFinder &rf) { string name=rf.find("name").asString().c_str(); setName(name.c_str()); Property config; config.fromConfigFile(rf.findFile("from").c_str()); Bottle &bGeneral=config.findGroup("general"); if (bGeneral.isNull()) { cout<<"Error: group general is missing!"<<endl; return false; } // parsing general config options Property option(bGeneral.toString().c_str()); option.put("local",name.c_str()); option.put("part","left_arm"); option.put("grasp_model_type",rf.find("grasp_model_type").asString().c_str()); option.put("grasp_model_file",rf.findFile("grasp_model_file").c_str()); option.put("hand_sequences_file",rf.findFile("hand_sequences_file").c_str()); // parsing arm dependent config options Bottle &bArm=config.findGroup("arm_dependent"); getArmDependentOptions(bArm,graspOrien,graspDisp,dOffs,dLift,home_x); cout<<"***** Instantiating primitives for left arm"<<endl; action=new AFFACTIONPRIMITIVESLAYER(option); if (!action->isValid()) { delete action; return false; } deque<string> q=action->getHandSeqList(); cout<<"***** List of available hand sequence keys:"<<endl; for (size_t i=0; i<q.size(); i++) cout<<q[i]<<endl; string fwslash="/"; inPort.open((fwslash+name+"/in").c_str()); rpcPort.open((fwslash+name+"/rpc").c_str()); attach(rpcPort); // check whether the grasp model is calibrated, // otherwise calibrate it Model *model; action->getGraspModel(model); if (model!=NULL) { if (!model->isCalibrated()) { Property prop; prop.put("finger","all"); model->calibrate(prop); } } return true; }
virtual bool configure(ResourceFinder &rf) { string name=rf.find("name").asString().c_str(); setName(name.c_str()); string partUsed=rf.find("part").asString().c_str(); if ((partUsed!="left_arm") && (partUsed!="right_arm")) { cout<<"Invalid part requested!"<<endl; return false; } Property config; config.fromConfigFile(rf.findFile("from").c_str()); Bottle &bGeneral=config.findGroup("general"); if (bGeneral.isNull()) { cout<<"Error: group general is missing!"<<endl; return false; } // parsing general config options Property option; for (int i=1; i<bGeneral.size(); i++) { Bottle *pB=bGeneral.get(i).asList(); if (pB->size()==2) option.put(pB->get(0).asString().c_str(),pB->get(1)); else { cout<<"Error: invalid option!"<<endl; return false; } } option.put("local",name.c_str()); option.put("part",rf.find("part").asString().c_str()); option.put("grasp_model_type",rf.find("grasp_model_type").asString().c_str()); option.put("grasp_model_file",rf.findFile("grasp_model_file").c_str()); option.put("hand_sequences_file",rf.findFile("hand_sequences_file").c_str()); // parsing arm dependent config options Bottle &bArm=config.findGroup("arm_dependent"); getArmDependentOptions(bArm,graspOrien,graspDisp,dOffs,dLift,home_x); cout<<"***** Instantiating primitives for "<<partUsed<<endl; action=new AFFACTIONPRIMITIVESLAYER(option); if (!action->isValid()) { delete action; return false; } deque<string> q=action->getHandSeqList(); cout<<"***** List of available hand sequence keys:"<<endl; for (size_t i=0; i<q.size(); i++) cout<<q[i]<<endl; string fwslash="/"; inPort.open((fwslash+name+"/in").c_str()); rpcPort.open((fwslash+name+"/rpc").c_str()); attach(rpcPort); openPorts=true; // check whether the grasp model is calibrated, // otherwise calibrate it and save the results Model *model; action->getGraspModel(model); if (!model->isCalibrated()) { Property prop("(finger all)"); model->calibrate(prop); ofstream fout; fout.open(option.find("grasp_model_file").asString().c_str()); model->toStream(fout); fout.close(); } return true; }