本文整理汇总了C++中yarp::os::ResourceFinder::find方法的典型用法代码示例。如果您正苦于以下问题:C++ ResourceFinder::find方法的具体用法?C++ ResourceFinder::find怎么用?C++ ResourceFinder::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yarp::os::ResourceFinder
的用法示例。
在下文中一共展示了ResourceFinder::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: configure
/*
* Configure function. Receive a previously initialized
* resource finder object. Use it to configure your module.
* Open port and attach it to message handler.
*/
bool configure(yarp::os::ResourceFinder &rf)
{
imp.controlled_part = rf.find("part").asString();
imp.robotname = rf.find("robot").asString();
if(imp.controlled_part == "right_arm")
{
imp.limb = new iCubArm("right");
imp.gcomp_port = GCOMP_PORT_RIGHT_ARM;
}
else if(imp.controlled_part == "left_arm")
{
imp.limb = new iCubArm("left");
imp.gcomp_port = GCOMP_PORT_LEFT_ARM;
}
else
{
fprintf(stderr, "part not recognised\n");
return false;
}
if (!imp.open())
{
fprintf(stderr, "Error opening detector\n");
return false;
}
fflush(stdout);
return true;
}
示例2: QMainWindow
qavimator::qavimator(yarp::os::ResourceFinder &config, QWidget *parent) :
QMainWindow(parent),
ui(new Ui::qavimator)
{
ui->setupUi(this);
setupToolBar();
ui->animationView->init(config);
nFPS=10;
width=850;
height=600;
readSettings();
// default size
if (config.check("name")) {
GUI_NAME=std::string(config.find("name").asString().c_str());
}
if (GUI_NAME[0]!='/') {
GUI_NAME=std::string("/")+GUI_NAME;
}
if (config.check("width")) {
width=config.find("width").asInt();
}
if (config.check("height")) {
height=config.find("height").asInt();
}
//sanity check
if(width<100) {
width=100;
}
if(height<100) {
height=100;
}
this->resize(width, height);
int xpos=32,ypos=32;
if (config.check("xpos")) {
xpos=config.find("xpos").asInt();
}
if (config.check("ypos")) {
ypos=config.find("ypos").asInt();
}
this->move(xpos,ypos);
setWindowTitle(GUI_NAME.c_str());
connect(ui->animationView,SIGNAL(backgroundClicked()),this,SLOT(backgroundClicked()));
connect(this,SIGNAL(resetCamera()),ui->animationView,SLOT(resetCamera()));
ui->animationView->startTimer(1000/nFPS);
}
示例3: configure
bool ShowModule::configure(yarp::os::ResourceFinder &rf)
{
//Ports
string name=rf.check("name",Value("show3D")).asString().c_str();
string robot = rf.check("robot",Value("icub")).asString().c_str();
string cloudpath_file = rf.check("from",Value("cloudsPath.ini")).asString().c_str();
rf.findFile(cloudpath_file.c_str());
ResourceFinder cloudsRF;
cloudsRF.setDefaultConfigFile(cloudpath_file.c_str());
cloudsRF.configure(0,NULL);
// Set the path that contains previously saved pointclouds
if (rf.check("clouds_path")){
cloudpath = rf.find("clouds_path").asString().c_str();
}else{
string defPathFrom = "/share/ICUBcontrib/contexts/toolIncorporation/sampleClouds/";
string localModelsPath = rf.check("local_path")?rf.find("local_path").asString().c_str():defPathFrom; //cloudsRF.find("clouds_path").asString();
string icubContribEnvPath = yarp::os::getenv("ICUBcontrib_DIR");
cloudpath = icubContribEnvPath + localModelsPath;
}
handlerPort.open("/"+name+"/rpc:i");
attach(handlerPort);
cloudsInPort.open("/"+name+"/clouds:i");
// Module rpc parameters
closing = false;
// Init variables
cloudfile = "cloud.ply";
cloud = pcl::PointCloud<pcl::PointXYZRGB>::Ptr (new pcl::PointCloud<pcl::PointXYZRGB>);
//Threads
visThrd = new VisThread(50, "Cloud");
if (!visThrd->start())
{
delete visThrd;
visThrd = 0;
cout << "\nERROR!!! visThread wasn't instantiated!!\n";
return false;
}
cout << "PCL visualizer Thread istantiated...\n";
cout << endl << "Configuring done."<<endl;
printf("Base path: %s \n \n",cloudpath.c_str());
return true;
}
示例4: configure
bool AudioPowerMapModule::configure(yarp::os::ResourceFinder &rf) {
yInfo("Configuring the module");
// get the module name which will form the stem of all module port names
moduleName = rf.check("name", Value("/AudioPowerMap"), "module name (string)").asString();
// before continuing, set the module name before getting any other parameters,
// specifically the port names which are dependent on the module name
setName(moduleName.c_str());
// get the robot name which will form the stem of the robot ports names
// and append the specific part and device required
robotName = rf.check("robot", Value("icub"), "Robot name (string)").asString();
robotPortName = "/" + robotName + "/head";
inputPortName = rf.check("inputPortName", Value(":i"), "Input port name (string)").asString();
// attach a port of the same name as the module (prefixed with a /) to the module
// so that messages received from the port are redirected to the respond method
handlerPortName = "";
handlerPortName += getName();
if (!handlerPort.open(handlerPortName.c_str())) {
std::cout << getName() << ": Unable to open port " << handlerPortName << std::endl;
return false;
}
// attach to port
attach(handlerPort);
if (rf.check("config")) {
configFile=rf.findFile(rf.find("config").asString().c_str());
if (configFile=="") {
return false;
}
}
else {
configFile.clear();
}
// create the thread and pass pointers to the module parameters
apr = new AudioPowerMapRatethread(robotName, configFile, rf);
apr->setName(moduleName);
// now start the thread to do the work
// this calls threadInit() and it if returns true, it then calls run()
bool ret = apr->start();
// let the RFModule know everything went well
// so that it will then run the module
return ret;
}
示例5: configure
bool Module::configure(yarp::os::ResourceFinder &rf)
{
// Parse the configuration file.
controller_options.robotName = rf.check("robot") ? rf.find("robot").asString().c_str() : "icub";
controller_options.threadPeriod = rf.check("threadPeriod") ? rf.find("threadPeriod").asInt() : DEFAULT_THREAD_PERIOD;
dangerPeriodLoopTime = 1.3 * controller_options.threadPeriod;
controller_options.serverName = rf.check("local") ? rf.find("local").asString().c_str() : "OcraControllerServer";
controller_options.runInDebugMode = rf.check("debug");
controller_options.noOutputMode = rf.check("noOutput");
controller_options.isFloatingBase = rf.check("floatingBase");
controller_options.useOdometry = rf.check("useOdometry");
controller_options.idleAnkles = rf.check("idleAnkles");
if ( controller_options.idleAnkles ) {
if ( !rf.find("idleAnkles").isNull() ) {
controller_options.idleAnkleTime = rf.find("idleAnkles").asDouble();
if ( controller_options.idleAnkleTime < 0.0 ) {
controller_options.idleAnkleTime = 0.0;
OCRA_WARNING("Ankle idling time must be > 0. Setting to 0.0s.")
}
}
示例6: configureSpeech
void AdaptiveLayer::configureSpeech(yarp::os::ResourceFinder &rf)
{
//Port for broadcasting recognized keywords to other modules
//pSpeechRecognizerKeywordOut.open("/"+getName()+"/speechGrammar/keyword:o");
//Set the tts options
string ttsOptions = rf.check("ttsOptions",Value("iCub")).asString().c_str();
iCub->getSpeechClient()->SetOptions(ttsOptions);
//Populate the speech reco if needed
bool shouldPopulateGrammar = rf.find("shouldPopulateGrammar").asInt() == 1;
if (shouldPopulateGrammar)
populateSpeechRecognizerVocabulary();
}
示例7: configure
bool configure(yarp::os::ResourceFinder &rf)
{
path = rf.find("clouds_path").asString();
printf("Path: %s",path.c_str());
handlerPort.open("/mergeModule");
attach(handlerPort);
/* Module rpc parameters */
visualizing = false;
saving = true;
closing = false;
/*Init variables*/
initF = true;
filesScanned = 0;
cout<<"Configuring done."<<endl;
return true;
}
示例8: Value
bool SimToolLoaderModule::configure(yarp::os::ResourceFinder &rf) {
Bottle table;
Bottle temp;
string objectName = "obj";
/* module name */
moduleName = rf.check("name", Value("simtoolloader"),
"Module name (string)").asString();
setName(moduleName.c_str());
/* Hand used */
hand=rf.find("hand").asString().c_str();
if ((hand!="left") && (hand!="right"))
hand="right";
/* port names */
simToolLoaderSimOutputPortName = "/";
simToolLoaderSimOutputPortName += getName( rf.check("simToolLoaderSimOutputPort",
Value("/sim:rpc"),
"Loader output port(string)")
.asString() );
simToolLoaderCmdInputPortName = "/";
simToolLoaderCmdInputPortName += getName( rf.check("simToolLoaderCmdInputPort",
Value("/cmd:i"),
"Loader input port(string)")
.asString() );
/* open ports */
if (!simToolLoaderSimOutputPort.open(
simToolLoaderSimOutputPortName.c_str())) {
cout << getName() << ": unable to open port"
<< simToolLoaderSimOutputPortName << endl;
return false;
}
if (!simToolLoaderCmdInputPort.open(
simToolLoaderCmdInputPortName.c_str())) {
cout << getName() << ": unable to open port"
<< simToolLoaderCmdInputPortName << endl;
return false;
}
/* Rate thread period */
threadPeriod = rf.check("threadPeriod", Value(0.5),
"Control rate thread period key value(double) in seconds ").asDouble();
/* Read Table Configuration */
table = rf.findGroup("table");
/* Read the Objects configurations */
vector<Bottle> object;
cout << "Loading objects to buffer" << endl;
bool noMoreModels = false;
int n =0;
while (!noMoreModels){ // read until there are no more objects.
stringstream s;
s.str("");
s << objectName << n;
string objNameNum = s.str();
temp = rf.findGroup("objects").findGroup(objNameNum);
if(!temp.isNull()) {
cout << "object" << n << ", id: " << objNameNum;
cout << ", model: " << temp.get(2).asString() << endl;
object.push_back(temp);
temp.clear();
n++;
}else {
noMoreModels = true;
}
}
numberObjs = n;
cout << "Loaded " << object.size() << " objects " << endl;
/* Create the control rate thread */
ctrlThread = new CtrlThread(&simToolLoaderSimOutputPort,
&simToolLoaderCmdInputPort,
threadPeriod,
table, object,hand);
/* Starts the thread */
if (!ctrlThread->start()) {
delete ctrlThread;
return false;
}
return true;
}
示例9: configure
bool TorqueBalancingReferencesGenerator::configure (yarp::os::ResourceFinder &rf)
{
using namespace yarp::os;
using namespace yarp::sig;
using namespace Eigen;
if (!rf.check("wbi_config_file", "Checking wbi configuration file")) {
std::cout << "No WBI configuration file found.\n";
return false;
}
Property wbiProperties;
if (!wbiProperties.fromConfigFile(rf.findFile("wbi_config_file"))) {
std::cout << "Not possible to load WBI properties from file.\n";
return false;
}
wbiProperties.fromString(rf.toString(), false);
//retrieve the joint list
std::string wbiList = rf.find("wbi_joint_list").asString();
wbi::IDList iCubMainJoints;
if (!yarpWbi::loadIdListFromConfig(wbiList, wbiProperties, iCubMainJoints)) {
std::cout << "Cannot find joint list\n";
return false;
}
size_t actuatedDOFs = iCubMainJoints.size();
//create an instance of wbi
m_robot = new yarpWbi::yarpWholeBodyInterface("torqueBalancingReferencesGenerator", wbiProperties);
if (!m_robot) {
std::cout << "Could not create wbi object.\n";
return false;
}
m_robot->addJoints(iCubMainJoints);
if (!m_robot->init()) {
std::cout << "Could not initialize wbi object.\n";
return false;
}
robotName = rf.check("robot", Value("icubSim"), "Looking for robot name").asString();
// numberOfPostures = rf.check("numberOfPostures", Value(0), "Looking for numberOfPostures").asInt();
directionOfOscillation.resize(3,0.0);
frequencyOfOscillation = 0;
amplitudeOfOscillation = 0;
if (!loadReferences(rf,postures,comTimeAndSetPoints,actuatedDOFs,changePostural, changeComWithSetPoints,amplitudeOfOscillation,frequencyOfOscillation, directionOfOscillation ))
{
return false;
}
loadReferences(rf,postures,comTimeAndSetPoints,actuatedDOFs,changePostural, changeComWithSetPoints,amplitudeOfOscillation,frequencyOfOscillation, directionOfOscillation);
for(int i=0; i < postures.size(); i++ )
{
std::cerr << "[INFO] time_" << i << " = " << postures[i].time << std::endl;
std::cerr << "[INFO] posture_" << i << " = " << postures[i].qDes.toString()<< std::endl;
}
for(int i=0; i < comTimeAndSetPoints.size(); i++ )
{
std::cerr << "[INFO] time_" << i << " = " << comTimeAndSetPoints[i].time << std::endl;
std::cerr << "[INFO] com_" << i << " = " << comTimeAndSetPoints[i].comDes.toString()<< std::endl;
}
//
std::cout << "[INFO] Number of DOFs: " << actuatedDOFs << std::endl;
std::cerr << "[INFO] changePostural: " << changePostural << std::endl;
std::cerr << "[INFO] changeComWithSetPoints: " << changeComWithSetPoints << std::endl;
std::cerr << "[INFO] amplitudeOfOscillation: " << amplitudeOfOscillation << std::endl;
std::cout << "[INFO] frequencyOfOscillation " << frequencyOfOscillation << std::endl;
std::cerr << "[INFO] directionOfOscillation: " << directionOfOscillation.toString() << std::endl;
q0.resize(actuatedDOFs, 0.0);
com0.resize(3, 0.0);
comDes.resize(3, 0.0);
DcomDes.resize(3, 0.0);
DDcomDes.resize(3, 0.0);
m_robot->getEstimates(wbi::ESTIMATE_JOINT_POS, q0.data());
double world2BaseFrameSerialization[16];
double rotoTranslationVector[7];
wbi::Frame world2BaseFrame;
m_robot->getEstimates(wbi::ESTIMATE_BASE_POS, world2BaseFrameSerialization);
wbi::frameFromSerialization(world2BaseFrameSerialization, world2BaseFrame);
m_robot->forwardKinematics(q0.data(), world2BaseFrame, wbi::wholeBodyInterface::COM_LINK_ID, rotoTranslationVector);
com0[0] = rotoTranslationVector[0];
com0[1] = rotoTranslationVector[1];
com0[2] = rotoTranslationVector[2];
timeoutBeforeStreamingRefs = rf.check("timeoutBeforeStreamingRefs", Value(20), "Looking for robot name").asDouble();
period = rf.check("period", Value(0.01), "Looking for module period").asDouble();
std::cout << "timeoutBeforeStreamingRefs: " << timeoutBeforeStreamingRefs << "\n";
//.........这里部分代码省略.........
示例10: configure
bool GBSegmModule::configure (yarp::os::ResourceFinder &rf)
{
if (rf.check("help","if present, display usage message")) {
printf("Call with --from configfile.ini\n");
return false;
}
if (rf.check("name"))
setName(rf.find("name").asString().c_str());
else setName("GBSeg");
//override defaults if specified - TODO: range checking
if(rf.check("sigma")) sigma = (float)rf.find("sigma").asDouble();
if(rf.check("k")) k = (float)rf.find("k").asDouble();
if(rf.check("minRegion")) min_size = rf.find("minRegion").asInt();
std::string slash="/";
_imgPort.open((slash + getName("/rawImg:i").c_str()).c_str());
_configPort.open((slash + getName("/conf").c_str()).c_str());
_viewPort.open((slash +getName("/viewImg:o").c_str()).c_str());
attach(_configPort);
//read an image to get the dimensions
ImageOf<PixelRgb> *yrpImgIn;
yrpImgIn = _imgPort.read();
if (yrpImgIn == NULL) // this is the case if module is requested to quit while waiting for image
return true;
input=new image<rgb>(yrpImgIn->width(), yrpImgIn->height(), true);
//
// //THIS IS NOT REQUIRED - INPUT IMAGES ARE ALWAYS RGB
// //IF DIM == 3 THEN THE PROCESSING CLASS CONVERTS TO LUV
// //IF DIM == 1 THEN THE PROCESSING CLASS ONLY USES THE FIRST CHANNEL
// //WE USE HUE CHANNEL, SO MUST CONVERT FROM RGB TO HSV
// //check compatibility of image depth
// /*if (yrpImgIn->getPixelSize() != dim_)
// {
// cout << endl << "Incompatible image depth" << endl;
// return false;
// }*/
//
// //override internal image dimension if necessary
// if( width_ > orig_width_ )
// width_ = orig_width_;
// if( height_ > orig_height_ )
// height_ = orig_height_;
//
// //allocate memory for image buffers and get the pointers
//
// inputImage.resize(width_, height_); inputImage_ = inputImage.getRawImage();
// inputHsv.resize(width_, height_); inputHsv_ = inputHsv.getRawImage();
// inputHue.resize(width_, height_); inputHue_ = inputHue.getRawImage();
// filtImage.resize(width_, height_); filtImage_ = filtImage.getRawImage();
// segmImage.resize(width_, height_); segmImage_ = segmImage.getRawImage();
// gradMap.resize(width_, height_); gradMap_ = (float*)gradMap.getRawImage();
// confMap.resize(width_, height_); confMap_ = (float*)confMap.getRawImage();
// weightMap.resize(width_, height_); weightMap_ = (float*)weightMap.getRawImage();
// labelImage.resize(width_, height_);
// labelView.resize(width_, height_);
return true;
}
示例11: configure
bool CamCalibModule::configure(yarp::os::ResourceFinder &rf)
{
ConstString str = rf.check("name", Value("/camCalib"), "module name (string)").asString();
verboseExecTime = rf.check("verboseExecTime");
if (rf.check("w_align")) align=ALIGN_WIDTH;
else if (rf.check("h_align")) align=ALIGN_HEIGHT;
if (rf.check("fps"))
{
requested_fps=rf.find("fps").asDouble();
yInfo() << "Module will run at " << requested_fps;
}
else
{
yInfo() << "Module will run at max fps";
}
setName(str.c_str()); // modulePortName
Bottle botLeftConfig(rf.toString().c_str());
Bottle botRightConfig(rf.toString().c_str());
botLeftConfig.setMonitor(rf.getMonitor());
botRightConfig.setMonitor(rf.getMonitor());
string strLeftGroup = "CAMERA_CALIBRATION_LEFT";
if (botLeftConfig.check(strLeftGroup.c_str()))
{
Bottle &group=botLeftConfig.findGroup(strLeftGroup.c_str(),string("Loading configuration from group " + strLeftGroup).c_str());
botLeftConfig.fromString(group.toString());
}
else
{
yError() << "Group " << strLeftGroup << " not found.";
return false;
}
string strRightGroup = "CAMERA_CALIBRATION_RIGHT";
if (botRightConfig.check(strRightGroup.c_str()))
{
Bottle &group=botRightConfig.findGroup(strRightGroup.c_str(),string("Loading configuration from group " + strRightGroup).c_str());
botRightConfig.fromString(group.toString());
}
else
{
yError() << "Group " << strRightGroup << " not found.";
return false;
}
string calibToolLeftName = botLeftConfig.check("projection", Value("pinhole"), "Projection/mapping applied to calibrated image [projection|spherical] (string).").asString().c_str();
string calibToolRightName = botRightConfig.check("projection", Value("pinhole"), "Projection/mapping applied to calibrated image [projection|spherical] (string).").asString().c_str();
calibToolLeft = CalibToolFactories::getPool().get(calibToolLeftName.c_str());
if (calibToolLeft!=NULL)
{
bool ok = calibToolLeft->open(botLeftConfig);
if (!ok)
{
delete calibToolLeft;
calibToolLeft = NULL;
return false;
}
}
calibToolRight = CalibToolFactories::getPool().get(calibToolRightName.c_str());
if (calibToolRight!=NULL)
{
bool ok = calibToolRight->open(botRightConfig);
if (!ok)
{
delete calibToolRight;
calibToolRight = NULL;
return false;
}
}
if(rf.check("dual"))
{
dualImage_mode = true;
yInfo() << "Dual mode activate!!";
}
if(dualImage_mode)
{
leftImage = new yarp::sig::ImageOf<yarp::sig::PixelRgb>;
rightImage = new yarp::sig::ImageOf<yarp::sig::PixelRgb>;
// open a single port with name /dual:i
if (yarp::os::Network::exists(getName("/dual:i")))
{
yWarning() << "port " << getName("/dual:i") << " already in use";
}
if(! imageInLeft.open(getName("/dual:i")) )
return false;
imageInLeft.setStrict(false);
}
else
{
if (yarp::os::Network::exists(getName("/left:i")))
{
//.........这里部分代码省略.........
示例12: printf
bool rd::RobotDevastation::configure(yarp::os::ResourceFinder &rf)
{
//-- Show help
//printf("--------------------------------------------------------------\n");
if (rf.check("help")) {
printf("RobotDevastation options:\n");
printf("\t--help (this help)\t--from [file.ini]\t--context [path]\n");
printf("\t--id integer\n");
printf("\t--name string\n");
printf("\t--team integer\n");
printf("\t--robotName string\n");
// Do not exit: let last layer exit so we get help from the complete chain.
}
printf("RobotDevastation using no additional special options.\n");
//-- Get player data
//-----------------------------------------------------------------------------
if( ! rf.check("id") )
{
RD_ERROR("No id!\n");
return false;
}
RD_INFO("id: %d\n",rf.find("id").asInt());
if( ! rf.check("name") )
{
RD_ERROR("No name!\n");
return false;
}
RD_INFO("name: %s\n",rf.find("name").asString().c_str());
if( ! rf.check("team") )
{
RD_ERROR("No team!\n");
return false;
}
RD_INFO("team: %d\n",rf.find("team").asInt());
if( ! rf.check("robotName") )
{
RD_ERROR("No robotName!\n");
return false;
}
RD_INFO("robotName: %s\n",rf.find("robotName").asString().c_str());
//-- Init mentalMap
mentalMap = RdMentalMap::getMentalMap();
mentalMap->configure( rf.find("id").asInt() );
std::vector< RdPlayer > players;
players.push_back( RdPlayer(rf.find("id").asInt(),std::string(rf.find("name").asString()),100,100,rf.find("team").asInt(),0) );
mentalMap->updatePlayers(players);
mentalMap->addWeapon(RdWeapon("Default gun", 10, 5));
//-- Init input manager
RdSDLInputManager::RegisterManager();
inputManager = RdInputManager::getInputManager("SDL");
inputManager->addInputEventListener(this);
if (!inputManager->start() )
{
RD_ERROR("Could not init inputManager!\n");
return false;
}
//-- Init sound
if( ! initSound( rf ) )
return false;
if( ! rf.check("noMusic") )
audioManager->play("bso", -1);
//-- Init robot
if( rf.check("mockupRobotManager") ) {
robotManager = new RdMockupRobotManager(rf.find("robotName").asString());
} else {
robotManager = new RdYarpRobotManager(rf.find("robotName").asString());
}
if( ! robotManager->connect() ) {
RD_ERROR("Could not connect to robotName \"%s\"!\n",rf.find("robotName").asString().c_str());
RD_ERROR("Use syntax: robotDevastation --robotName %s\n",rf.find("robotName").asString().c_str());
return false;
}
//-- Init network manager
RdYarpNetworkManager::RegisterManager();
networkManager = RdYarpNetworkManager::getNetworkManager(RdYarpNetworkManager::id);
networkManager->addNetworkEventListener(mentalMap);
mentalMap->addMentalMapEventListener((RdYarpNetworkManager *)networkManager);
networkManager->login(mentalMap->getMyself());
//-- Init image manager
if( rf.check("mockupImageManager") ) {
RdMockupImageManager::RegisterManager();
imageManager = RdImageManager::getImageManager(RdMockupImageManager::id);
} else {
RdYarpImageManager::RegisterManager();
imageManager = RdImageManager::getImageManager(RdYarpImageManager::id);
}
//-- Add the image processing listener to the image manager
//.........这里部分代码省略.........
示例13: rf
/**
* @brief constructor of the generic thread.
*
* @param module_prefix module name.
* @param thread_period period of the run thread in millisecond.
* @param rf resource finder.
**/
generic_thread( std::string module_prefix,
yarp::os::ResourceFinder rf,
std::shared_ptr<paramHelp::ParamHelperServer> ph ): module_prefix( module_prefix ),
thread_period( rf.find("thread_period").asInt() ),
robot_name( rf.find("robot_name").asString() ),
rf( rf ),
ph( ph ),
RateThread( rf.find("thread_period").asInt() )
{
}
示例14: configure
bool ObserverModule::configure(yarp::os::ResourceFinder &rf) {
/* Process all parameters from both command-line and .ini file */
/* get the module name which will form the stem of all module port names */
moduleName = rf.check("name",
Value(""),
"module name (string)").asString();
/*
* before continuing, set the module name before getting any other parameters,
* specifically the port names which are dependent on the module name
*/
// setName(moduleName.c_str());
/*
* get the robot name which will form the stem of the robot ports names
* and append the specific part and device required
*/
robotName = rf.check("robot",
Value("icub"),
"Robot name (string)").asString();
//robotPortName = "/" + robotName + "/head";
inputPortName = rf.check("inputPortName",
Value(":i"),
"Input port name (string)").asString();
/*
* attach a port of the same name as the module (prefixed with a /) to the module
* so that messages received from the port are redirected to the respond method
*/
handlerPortName = "";
handlerPortName += getName(); // use getName() rather than a literal
if (!handlerPort.open(handlerPortName.c_str())) {
cout << getName() << ": Unable to open port " << handlerPortName << endl;
return false;
}
attach(handlerPort); // attach to port
if (rf.check("config")) {
configFile=rf.findFile(rf.find("config").asString().c_str());
if (configFile=="") {
return false;
}
}
else {
configFile.clear();
}
bool returnval = true;
//create the thread and configure it using the ResourceFinder
_effectorThread = new EffectorThread();
returnval &= _effectorThread->configure(rf);
_affordanceAccess = new darwin::observer::AffordanceAccessImpl();
if (returnval) {
returnval &= _affordanceAccess->configure(rf);
}
_attentionAccess = new darwin::observer::AttentionAccessImpl();
if (returnval) {
returnval &= _attentionAccess->configure(rf);
}
_workspace = new darwin::observer::WorkspaceCalculationsImpl();
if (returnval) {
returnval &= _workspace->configure(rf);
}
/* create the thread and pass pointers to the module parameters */
rThread = new ObserverThread(robotName, configFile);
rThread->setName(getName().c_str());
rThread->setEffectorAccess(_effectorThread);
rThread->setAffordanceAccess(_affordanceAccess);
rThread->setAttentionAccess(_attentionAccess);
rThread->setWorkspaceAccess(_workspace);
const string pt = rf.findPath("observerConfig.ini");
unsigned pos = pt.find("observerConfig.ini");
pathPrefix = pt.substr(0,pos);
printf("observer configuraion file in %s \n", pathPrefix.c_str());
//////////////////////// find file paths
///////////input files
rThread->setPath(pathPrefix);
// rThread->setColorPath(colormapFile);
// rThread->setModelPath(modelFile);
//=======================================================================
//
//rThread->setInputPortName(inputPortName.c_str());
if (returnval) {
returnval &= _effectorThread->start();
}
//.........这里部分代码省略.........
示例15: configure
bool ImageSplitter::configure(yarp::os::ResourceFinder &rf)
{
// Check input parameters
if(rf.check("align"))
{
yarp::os::ConstString align = rf.find("align").asString();
if(align == "vertical")
{
horizontal = false;
}
else if(align == "horizontal")
{
horizontal = true;
}
else
{
yError() << " Incorrect parameter. Supported values for alignment are 'horizontal' or 'vertical'";
return false;
}
}
yarp::os::ConstString inputPortName = "/imageSplitter/input:i";
yarp::os::ConstString outLeftPortName = "/imageSplitter/left:o";
yarp::os::ConstString outRightPortName = "/imageSplitter/right:o";
if(rf.check("nameLeft"))
{
outLeftPortName = rf.find("nameLeft").asString();
}
if(rf.check("nameRight"))
{
outRightPortName = rf.find("nameRight").asString();
}
if(!rf.check("remote"))
{
yError() << "Missing 'remote' parameter. Please insert the name of the port to connect to.";
return false;
}
yarp::os::ConstString remotePortName = rf.find("remote").asString();
// opening ports
bool ret=true;
ret &= inputPort.open(inputPortName);
ret &= outLeftPort.open(outLeftPortName);
ret &= outRightPort.open(outRightPortName);
if(!ret)
{
yError() << " Cannot open ports";
return false;
}
// Connections
if(! yarp::os::Network::connect(remotePortName, inputPortName))
{
yError() << "Cannot connect to remote port " << remotePortName;
return false;
}
// choose filling method
if(rf.check("m"))
{
yarp::os::ConstString align = rf.find("m").asString();
if(align == "pixel")
{
method = 0;
}
else if(align == "pixel2")
{
method = 1;
}
else if(align == "line")
{
method = 2;
}
else if(align == "whole")
{
if(horizontal)
yError() << "Cannot use 'whole' method for input image horizontally aligned";
method = 3;
}
else
{
yError() << "Methods are pixel, line, whole; got " << align;
return false;
}
}
yInfo() << "using method " << method;
return true;
}