本文整理汇总了C++中yarp::os::ResourceFinder::check方法的典型用法代码示例。如果您正苦于以下问题:C++ ResourceFinder::check方法的具体用法?C++ ResourceFinder::check怎么用?C++ ResourceFinder::check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yarp::os::ResourceFinder
的用法示例。
在下文中一共展示了ResourceFinder::check方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: l_sMinJoint
bool swTeleop::SWIcubArm::init( yarp::os::ResourceFinder &oRf, bool bLeftArm)
{
if(m_bInitialized)
{
std::cerr << "Icub Arm is already initialized. " << std::endl;
return true;
}
if(bLeftArm)
{
m_sArm = "left";
}
else
{
m_sArm = "right";
}
// gets the module name which will form the stem of all module port names
m_sModuleName = oRf.check("name", yarp::os::Value("teleoperation_iCub"), "Teleoperation/iCub Module name (string)").asString();
m_sRobotName = oRf.check("robot",yarp::os::Value("icubSim"), "Robot name (string)").asString();
// robot parts to control
m_bArmHandActivated = oRf.check(std::string(m_sArm + "ArmHandActivated").c_str(), yarp::os::Value(m_bArmHandActivatedDefault), std::string(m_sArm + " Arm/hand activated (int)").c_str()).asInt() != 0;
m_bFingersActivated = oRf.check(std::string(m_sArm + "FingersActivated").c_str(), yarp::os::Value(m_bFingersActivatedDefault), std::string(m_sArm + " Fingers activated (int)").c_str()).asInt() != 0;
m_i32RateVelocityControl = oRf.check("armsRateVelocityControl", yarp::os::Value(m_i32RateVelocityControlDefault), "Arms rate velocity control (int)").asInt();
if(!m_bArmHandActivated && !m_bFingersActivated)
{
std::cout << m_sArm + " arm/hand and " + m_sArm +" fingers not activated, icub " + m_sArm + " arm initialization aborted. " << std::endl;
return (m_bInitialized = false);
}
// min / max values for iCub Torso joints
for(uint ii = 0; ii < m_vArmJointVelocityAcceleration.size(); ++ii)
{
std::ostringstream l_os;
l_os << ii;
std::string l_sMinJoint(m_sArm + "ArmMinValueJoint" + l_os.str());
std::string l_sMaxJoint(m_sArm + "ArmMaxValueJoint" + l_os.str());
std::string l_sArmResetPosition(m_sArm + "ArmResetPosition" + l_os.str());
std::string l_sArmJointVelocityAcceleration(m_sArm + "ArmJointVelocityAcceleration" + l_os.str());
std::string l_sArmJointVelocityK(m_sArm + "ArmJointVelocityK" + l_os.str());
std::string l_sArmJointPositionAcceleration(m_sArm + "ArmJointPositionAcceleration" + l_os.str());
std::string l_sArmJointPositionSpeed(m_sArm + "ArmJointPositionSpeed" + l_os.str());
std::string l_sMinJointInfo(m_sArm + " arm minimum joint" + l_os.str() + " Value (double)");
std::string l_sMaxJointInfo(m_sArm + " arm maximum joint" + l_os.str() + " Value (double)");
std::string l_sArmResetPositionInfo(m_sArm + " arm reset position " + l_os.str() + " Value (double)");
std::string l_sArmJointVelocityAccelerationInfo(m_sArm + " arm joint velocity acceleration " + l_os.str() + " Value (double)");
std::string l_sArmJointVelocityKInfo(m_sArm + " arm joint velocity K coeff"+ l_os.str() + " Value (double)");
std::string l_sArmJointPositionAccelerationInfo(m_sArm + " arm joint position acceleration " + l_os.str() + " Value (double)");
std::string l_sArmJointPositionSpeedInfo(m_sArm + " arm joint position speed " + l_os.str() + " Value (double)");
m_vArmMinJoint[ii] = oRf.check(l_sMinJoint.c_str(), m_vArmMinJointDefault[ii], l_sMinJointInfo.c_str()).asDouble();
m_vArmMaxJoint[ii] = oRf.check(l_sMaxJoint.c_str(), m_vArmMaxJointDefault[ii], l_sMaxJointInfo.c_str()).asDouble();
m_vArmResetPosition[ii] = oRf.check(l_sArmResetPosition.c_str(), m_vArmResetPositionDefault[ii], l_sArmResetPositionInfo.c_str()).asDouble();
m_vArmJointVelocityAcceleration[ii]= oRf.check(l_sArmJointVelocityAcceleration.c_str(), m_vArmJointVelocityAccelerationDefault[ii], l_sArmJointVelocityAccelerationInfo.c_str()).asDouble();
m_vArmJointPositionAcceleration[ii]= oRf.check(l_sArmJointPositionAcceleration.c_str(), m_vArmJointPositionAccelerationDefault[ii], l_sArmJointPositionAccelerationInfo.c_str()).asDouble();
m_vArmJointPositionSpeed[ii] = oRf.check(l_sArmJointPositionSpeed.c_str(), m_vArmJointPositionSpeedDefault[ii], l_sArmJointPositionSpeedInfo.c_str()).asDouble();
m_vArmJointVelocityK[ii] = oRf.check(l_sArmJointVelocityK.c_str(), m_vArmJointVelocityKDefault[ii], l_sArmJointVelocityKInfo.c_str()).asDouble();
}
// miscellaneous
m_i32TimeoutArmReset = oRf.check(std::string(m_sArm + "ArmTimeoutReset").c_str(), yarp::os::Value(m_i32TimeoutArmResetDefault), std::string(m_sArm + " arm timeout reset iCub (int)").c_str()).asInt();
// set polydriver options
m_oArmOptions.put("robot", m_sRobotName.c_str());
m_oArmOptions.put("device", "remote_controlboard");
m_oArmOptions.put("local", ("/local/" + m_sRobotName + "/" + m_sArm + "_arm").c_str());
m_oArmOptions.put("name", ("/" + m_sRobotName + "/" + m_sArm + "_arm").c_str());
m_oArmOptions.put("remote", ("/" + m_sRobotName + "/" + m_sArm + "_arm").c_str());
// init polydriver
m_oRobotArm.open(m_oArmOptions);
if(!m_oRobotArm.isValid())
{
std::cerr << std::endl <<"-ERROR: " << m_sArm << " robotArm is not valid, escape arm initialization. " << std::endl <<std::endl;
return (m_bInitialized=false);
}
// initializing controllers
if (!m_oRobotArm.view(m_pIArmVelocity) || !m_oRobotArm.view(m_pIArmPosition) || !m_oRobotArm.view(m_pIArmEncoders))
{
std::cerr << std::endl << "-ERROR: " << m_sArm << " while getting required robot Arm interfaces." << std::endl <<std::endl;
m_oRobotArm.close();
return (m_bInitialized=false);
}
// init ports
m_sHandTrackerPortName = "/teleoperation/" + m_sRobotName + "/" + m_sArm + "_arm/hand";
m_sHandFingersTrackerPortName = "/teleoperation/" + m_sRobotName + "/" + m_sArm + "_arm/hand_fingers";
// open ports
bool l_bPortOpeningSuccess = true;
if(m_bArmHandActivated || m_bFingersActivated)
{
//.........这里部分代码省略.........
示例2: configure
bool asvGrabberModule::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("/asvGrabber"),
"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";
/*
* get the device name which will be used to read events
*/
deviceName = rf.check("deviceName",
Value("/dev/aerfx2_0"),
"Device name (string)").asString();
devicePortName = deviceName ;
printf("trying to connect to the device %s \n",devicePortName.c_str());
/*
* 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
bool _save = false;
std::string deviceNum = "0";
/*
* get the file name of binaries when the biases are read from this file
*/
binaryName = rf.check("file",
Value("none"),
"filename of the binary (string)").asString();
printf("trying to read %s for biases \n",binaryName.c_str());
binaryNameComplete = rf.findFile(binaryName.c_str());
/*
* get the file name of binaries when the biases are read from this file
*/
dumpNameComplete = "";
dumpName = rf.check("dumpFile",
Value("none"),
"filename of the binary (string)").asString();
printf("trying to save events in %s \n",dumpName.c_str());
dumpNameComplete = rf.findFile(dumpName.c_str());
dumpPathDirectory = rf.getContextPath();
string pathDirectory = dumpPathDirectory.substr(0, 52);
pathDirectory += "/";
printf("saving directory %s \n",dumpPathDirectory.c_str());
if(!strcmp(binaryName.c_str(),"none")) {
printf("not reading from binary \n");
D2Y=new asvGrabberThread(devicePortName, false,binaryName);
//D2Y->setFromBinary(false);
}
else {
printf("reading from binary \n");
//D2Y->setFromBinary(true);
D2Y=new asvGrabberThread(devicePortName, true, binaryNameComplete);
//D2Y->setBinaryFile(f);
}
printf("dumpEventSet \n");
if (strcmp(dumpNameComplete.c_str(),"" )) {
printf("set dumping event true \n");
D2Y->setDumpEvent(true);
D2Y->setDumpFile(dumpNameComplete);
D2Y->setWorkingDirectory(pathDirectory);
}
else {
printf("set dumping event false \n");
D2Y->setDumpEvent(false);
}
printf("starting the processor \n");
D2Y->start();
return true ; // let the RFModule know everything went well
// so that it will then run the module
//.........这里部分代码省略.........
示例3: configure
bool faceTrackerModule::configure(yarp::os::ResourceFinder &rf) {
moduleName = rf.check("name",
Value("faceTracker"),
"module name (string)").asString();
setName(moduleName.c_str());
opcName = rf.check("opcName",
Value("OPC"),
"Opc name (string)").asString();
string xmlPath = rf.findFileByName("haarcascade_frontalface_default.xml");
// Create an iCub Client and check that all dependencies are here befor starting
opc = new OPCClient(moduleName.c_str());
opc->connect(opcName);
icub = NULL;
handlerPortName = "/";
handlerPortName += getName() + "/rpc";
if (!handlerPort.open(handlerPortName.c_str())) {
cout << getName() << ": Unable to open port " << handlerPortName << endl;
return false;
}
// ==================================================================
// image port open
imagePortLeft.open("/facetracking/image/left/in"); // give the left port a name
// ==================================================================
// robot
// ==================================================================
while(!Network::connect("/icub/camcalib/left/out", "/facetracking/image/left/in"))
{
Time::delay(3);
cout << "try to connect left camera, please wait ..." << endl;
}
Property options;
options.put("device", "remote_controlboard");
options.put("local", "/tutorial/motor/client");
options.put("remote", "/icub/head");
robotHead = new PolyDriver(options);
if(!robotHead->isValid())
{
cout << "Cannot connect to the robot head" << endl;
return false;
}
robotHead->view(pos);
robotHead->view(vel);
robotHead->view(enc);
if(pos==NULL || vel==NULL || enc==NULL)
{
cout << "Cannot get interface to robot head" << endl;
robotHead->close();
return false;
}
jnts = 0;
pos->getAxes(&jnts);
setpoints.resize(jnts);
cur_encoders.resize(jnts);
prev_encoders.resize(jnts);
/* prepare command */
for(int i=0;i<jnts;i++)
{
setpoints[i] = 0;
}
// ==================================================================
//// create a opencv window
cv::namedWindow("cvImage_Left",CV_WINDOW_NORMAL);
// ==================================================================
// face detection configuration
face_classifier_left.load(xmlPath);
attach(handlerPort); // attach to port
// ==================================================================
// Parameters
counter = 0;
x_buf = 0;
y_buf = 0;
mode = 0; // 0: going to a set position, 1: face searching, 2: face tracking, 3: face stuck,
setpos_counter = 0;
panning_counter = 0;
stuck_counter = 0;
tracking_counter = 0;
// ==================================================================
// random motion
//.........这里部分代码省略.........
示例4: 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;
}
示例5: configure
bool skinManager::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_DEFAULT.c_str()), "module name (string)").asString();
robotName = rf.check("robot", Value(ROBOT_NAME_DEFAULT.c_str()), "name of the robot (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 some other values from the configuration file */
int period = (int)rf.check("period", Value(PERIOD_DEFAULT),
"Period of the thread in ms (positive int)").asInt();
float minBaseline = (float)rf.check("minBaseline", Value(MIN_BASELINE_DEFAULT),
"If the baseline reaches this value then, if allowed, a calibration is executed (float in [0,255])").asDouble();
float compGain = (float)rf.check("compensationGain", Value(COMPENSATION_GAIN_DEFAULT),
"Gain of the compensation algorithm (float)").asDouble();
float contCompGain = (float)rf.check("contactCompensationGain", Value(CONTACT_COMPENSATION_GAIN_DEFAULT),
"Gain of the compensation algorithm during contact (float)").asDouble();
int addThreshold = (int)rf.check("addThreshold", Value(ADD_THRESHOLD_DEFAULT),
"Value added to all the touch thresholds (positive int)").asInt();
bool zeroUpRawData = rf.check("zeroUpRawData", ZERO_UP_RAW_DATA_DEFAULT,
"if true the raw data are considered from zero up, otherwise from 255 down (bool)").asBool();
bool smoothFilter = rf.check("smoothFilter", SMOOTH_FILTER_DEFAULT,
"if true then the smoothing filter is active (bool)").asBool();
float smoothFactor = (float) rf.check("smoothFactor", Value(SMOOTH_FACTOR_DEFAULT),
"Determine the smoothing intensity (float in [0,1])").asDouble();
bool binarization = rf.check("binarization", BINARIZATION_DEFAULT,
"if true then the binarization is active (bool)").asBool();
/*
* 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
*/
string handlerPortName = "/";
handlerPortName += getName(rf.check("handlerPort", Value(RPC_PORT_DEFAULT.c_str())).asString());
if (!handlerPort.open(handlerPortName.c_str())) {
cout << getName() << ": Unable to open port " << handlerPortName << endl;
return false;
}
attach(handlerPort); // attach to port
handlerPort.setRpcMode(true);
/* create the thread and pass pointers to the module parameters */
myThread = new CompensationThread(moduleName, &rf, robotName, compGain, contCompGain, addThreshold, minBaseline,
zeroUpRawData, period, binarization, smoothFilter, smoothFactor);
/* now start the thread to do the work */
return myThread->start(); // this calls threadInit() and it if returns true, it then calls run()
// return true ; // let the RFModule know everything went well so that it will then run the module
}
示例6: configure
bool targetFinderModule::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("/targetFinder"),
"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";
configName = rf.check("config",
Value("icubEyes.ini"),
"Config file for intrinsic parameters (string)").asString();
printf("configFile: %s \n", configName.c_str());
if (strcmp(configName.c_str(),"")) {
printf("looking for the config file \n");
configFile=rf.findFile(configName.c_str());
printf("config file %s \n", configFile.c_str());
if (configFile=="") {
printf("ERROR: file not found");
return false;
}
}
else {
configFile.clear();
}
/*
* set the operating mode which correspond as well with the file map saved in conf
*/
mapName = rf.check("mode",
Value("intensity"),
"file map name (string)").asString();
mapName += ".txt";
mapNameComplete = rf.findFile(mapName.c_str());
/*
* 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
tf = new targetFinderThread();
tf->setMapURL(mapNameComplete);
tf->setRobotName(robotName);
tf->setConfigFile(configFile);
tf->setName(getName().c_str());
tf->start();
return true ; // let the RFModule know everything went well
// so that it will then run the module
}
示例7: configure
bool BehaviorManager::configure(yarp::os::ResourceFinder &rf)
{
moduleName = rf.check("name",Value("BehaviorManager")).asString();
setName(moduleName.c_str());
yInfo()<<moduleName<<": finding configuration files...";//<<endl;
period = rf.check("period",Value(1.0)).asDouble();
Bottle grp = rf.findGroup("BEHAVIORS");
behaviorList = *grp.find("behaviors").asList();
rpc_in_port.open("/" + moduleName + "/trigger:i");
yInfo() << "RPC_IN : " << rpc_in_port.getName();
for (int i = 0; i<behaviorList.size(); i++)
{
behavior_name = behaviorList.get(i).asString();
if (behavior_name == "tagging") {
behaviors.push_back(new Tagging(&mut, rf, "tagging"));
} else if (behavior_name == "pointing") {
behaviors.push_back(new Pointing(&mut, rf, "pointing"));
} else if (behavior_name == "dummy") {
behaviors.push_back(new Dummy(&mut, rf, "dummy"));
} else if (behavior_name == "dummy2") {
behaviors.push_back(new Dummy(&mut, rf, "dummy2"));
} else if (behavior_name == "reactions") {
behaviors.push_back(new Reactions(&mut, rf, "reactions"));
} else if (behavior_name == "followingOrder") {
behaviors.push_back(new FollowingOrder(&mut, rf, "followingOrder"));
} else if (behavior_name == "narrate") {
behaviors.push_back(new Narrate(&mut, rf, "narrate"));
} else if (behavior_name == "recognitionOrder") {
behaviors.push_back(new recognitionOrder(&mut, rf, "recognitionOrder"));
// other behaviors here
} else {
yDebug() << "Behavior " + behavior_name + " not implemented";
return false;
}
}
//Create an iCub Client and check that all dependencies are here before starting
bool isRFVerbose = false;
iCub = new ICubClient(moduleName, "behaviorManager","client.ini",isRFVerbose);
if (!iCub->connect())
{
yInfo() << "iCubClient : Some dependencies are not running...";
Time::delay(1.0);
}
while (!Network::connect("/ears/behavior:o", rpc_in_port.getName())) {
yWarning() << "Ears is not reachable";
yarp::os::Time::delay(0.5);
}
// id = 0;
for(auto& beh : behaviors) {
beh->configure();
beh->openPorts(moduleName);
beh->iCub = iCub;
if (beh->from_sensation_port_name != "None") {
while (!Network::connect(beh->from_sensation_port_name, beh->sensation_port_in.getName())) {
yInfo()<<"Connecting "<< beh->from_sensation_port_name << " to " << beh->sensation_port_in.getName();// <<endl;
yarp::os::Time::delay(0.5);
}
}
if (beh->external_port_name != "None") {
while (!Network::connect(beh->rpc_out_port.getName(), beh->external_port_name)) {
yInfo()<<"Connecting "<< beh->rpc_out_port.getName() << " to " << beh->external_port_name;// <<endl;
yarp::os::Time::delay(0.5);
}
}
}
attach(rpc_in_port);
yInfo("Init done");
return true;
}
示例8: configure
bool EndogenousSalience::configure(yarp::os::ResourceFinder &rf)
{
/*
* Process all parameters from
* - command-line
* - endogenousSalience.ini file (or whatever file is specified by the --from argument)
*/
/* get the module name which will form the stem of all module port names */
moduleName = rf.check("name",
Value("endogenousSalience"),
"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();
/* get the name of the input and output ports, automatically prefixing the module name by using getName() */
cartesianInputPortName = "/";
cartesianInputPortName += getName(
rf.check("cartesianImageInPort",
Value("/cartesianImage:i"),
"Input image port (string)").asString()
);
logpolarInputPortName = "/";
logpolarInputPortName += getName(
rf.check("logpolarImageInPort",
Value("/logpolarImage:i"),
"Exemplar image port (string)").asString()
);
salienceOutputPortName = "/";
salienceOutputPortName += getName(
rf.check("salienceImageOutPort",
Value("/salienceImage:o"),
"Left output image port (string)").asString()
);
hueTolerance = rf.check("hueTolerance",
Value(10),
"Tolerance for hue value (int)").asInt();
saturationTolerance = rf.check("saturationTolerance",
Value(10),
"Tolerance for saturation value (int)").asInt();
hueBins = rf.check("hueBins",
Value(32),
"Number of hue bins in HS histogram (int)").asInt();
saturationBins = rf.check("saturationBins",
Value(32),
"Number of saturation bins in HS histogram (int)").asInt();
filterRadius = rf.check("filterRadius",
Value(10),
"Radius of the morphological opening filter (int)").asInt();
if (debug) {
printf("endogenousSalience: module name is %s\n",moduleName.c_str());
printf("endogenousSalience: robot name is %s\n",robotName.c_str());
printf("endogenousSalience: hue and saturation tolerances are %d %d\n",hueTolerance,saturationTolerance);
printf("endogenousSalience: hue and saturation bins are %d %d\n",hueBins,saturationBins);
printf("endogenousSalience: port names are\n%s\n%s\n%s\n\n",cartesianInputPortName.c_str(),
logpolarInputPortName.c_str(),
salienceOutputPortName.c_str());
}
/* do all initialization here */
/* open ports */
if (!cartesianImageIn.open(cartesianInputPortName.c_str())) {
cout << getName() << ": unable to open port " << cartesianInputPortName << endl;
return false; // unable to open; let RFModule know so that it won't run
}
if (!logpolarImageIn.open(logpolarInputPortName.c_str())) {
cout << getName() << ": unable to open port " << logpolarInputPortName << endl;
return false; // unable to open; let RFModule know so that it won't run
}
if (!salienceImageOut.open(salienceOutputPortName.c_str())) {
cout << getName() << ": unable to open port " << salienceOutputPortName << endl;
return false; // unable to open; let RFModule know so that it won't run
//.........这里部分代码省略.........
示例9: configure
bool ImageSource::configure(yarp::os::ResourceFinder &rf)
{
debug = true;
/* 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("imageSource"),
"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());
/* now, get the rest of the parameters */
/*
* get the imageFilename
*/
imageFilename = rf.check("imageFile",
Value("image.bmp"),
"image filename (string)").asString();
imageFilename = (rf.findFile(imageFilename.c_str())).c_str();
/* get the complete name of the image output port */
outputPortName = rf.check("outputPort",
Value("/image:o"),
"Output image port (string)").asString();
/* get the complete name of the gaze output port */
gazePortName = rf.check("gazePort",
Value("/gaze:o"),
"Output gaze port (string)").asString();
/* get the complete name of the encoder state output port */
encoderPortName = rf.check("encoderPort",
Value("/icub/head/state:o"),
"Output encoder port (string)").asString();
/* get the frequency, width, height, standard deviation, horizontalViewAngle, and verticalViewAngle values */
frequency = rf.check("frequency",
Value(10),
"frequency key value (int)").asInt();
width = rf.check("width",
Value(320),
"output width key value (int)").asInt();
height = rf.check("height",
Value(240),
"output height key value (int)").asInt();
noiseLevel = rf.check("noise",
Value(20),
"noise level key value (int)").asInt();
window = rf.check("window",
Value(0),
"window flag key value (int)").asInt();
random = rf.check("random",
Value(0),
"random flag key value (int)").asInt();
xShift = rf.check("xShift",
Value(5),
"horizontal shift key value (int)").asInt();
yShift = rf.check("yShift",
Value(5),
"vertical shift key value (int)").asInt();
horizontalViewAngle = rf.check("horizontalViewAngle",
Value(120.0),
"horizontal field of view angle key value (double)").asDouble();
verticalViewAngle = rf.check("verticalViewAngle",
Value(90.0),
"vertical field of view angle key value (double)").asDouble();
if (debug) {
cout << "imageSource::configure: image file name " << imageFilename << endl;
cout << "imageSource::configure: output port name " << outputPortName << endl;
cout << "imageSource::configure: gaze port name " << gazePortName << endl;
cout << "imageSource::configure: encoder port name " << encoderPortName << endl;
cout << "imageSource::configure: frequency " << frequency << endl;
cout << "imageSource::configure: width " << width << endl;
//.........这里部分代码省略.........
示例10: configure
bool fileFeederModule::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("/fileFeeder"),
"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";
/*
* 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
ffThread=new fileFeederThread();
ffThread->setName(getName().c_str());
ffThread->start();
/* get the filename start which will form the name of the read images */
filenameStart = rf.check("filenameStart",
Value("."),
"module name (string)").asString();
ffThread->setStartFilename(filenameStart);
/* get the filename end which will form the name of the read images */
filenameEnd = rf.check("filenameEnd",
Value(").jpg"),
"module name (string)").asString();
ffThread->setLastFilename(filenameEnd);
/* get the number of images that are going to be read */
numberImages = rf.check("numberImages",
Value(100),
"module name (int)").asInt();
ffThread->setNumberOfImages(numberImages);
ffThread->setStartFilename(filenameStart);
return true ; // let the RFModule know everything went well
// so that it will then run the module
}
示例11: configure
bool TrainModule::configure(yarp::os::ResourceFinder& opt) {
/* Implementation note:
* Calling open() in the base class (i.e. PredictModule) is cumbersome due
* to different ordering and dynamic binding (e.g. it calls
* registerAllPorts()) and because we do bother with an incoming model port.
*/
// read for the general specifiers:
yarp::os::Value* val;
std::string machineName;
// cache resource finder
this->setResourceFinder(&opt);
// check for help request
if(opt.check("help")) {
this->printOptions();
return false;
}
// check for algorithm listing request
if(opt.check("list")) {
this->printMachineList();
return false;
}
// check for port specifier: portSuffix
if(opt.check("port", val)) {
this->portPrefix = val->asString().c_str();
}
// check for filename to load machine from
if(opt.check("load", val)) {
this->getMachinePortable().readFromFile(val->asString().c_str());
} else{
// not loading anything, require machine name
if(opt.check("machine", val)) {
machineName = val->asString().c_str();
} else {
this->printOptions("No machine type specified");
return false;
}
// construct new machine
this->getMachinePortable().setWrapped(machineName);
// send configuration options to the machine
this->getMachine().configure(opt);
}
// add replier for incoming data (prediction requests)
this->predict_inout.setReplier(this->predictProcessor);
// add processor for incoming data (training samples)
this->train_in.useCallback(trainProcessor);
// register ports before connecting
this->registerAllPorts();
// and finally load command file
if(opt.check("commands", val)) {
this->loadCommandFile(val->asString().c_str());
}
// attach to the incoming command port and terminal
this->attach(cmd_in);
this->attachTerminal();
return true;
}
示例12: 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();
}
//.........这里部分代码省略.........
示例13: configure
bool demoModule::configure(yarp::os::ResourceFinder &rf) {
/*
* PLEASE remove useless comments when writing actual code. If needed then use Doxygen comments and tags.
*/
/* 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("demoModule"),
"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());
/* now, get the rest of the parameters */
/*
* 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";
/*
* get the cameraConfig file and read the required parameter values cx, cy
* in both the groups [CAMERA_CALIBRATION_LEFT] and [CAMERA_CALIBRATION_RIGHT]
*/
cameraConfigFilename = rf.check("cameraConfig",
Value("icubEyes.ini"),
"camera configuration filename (string)").asString();
cameraConfigFilename = (rf.findFile(cameraConfigFilename.c_str())).c_str();
Property cameraProperties;
if (cameraProperties.fromConfigFile(cameraConfigFilename.c_str()) == false) {
cout << "myModule: unable to read camera configuration file" << cameraConfigFilename;
return 0;
}
else {
cxLeft = (float) cameraProperties.findGroup("CAMERA_CALIBRATION_LEFT").check("cx", Value(160.0), "cx left").asDouble();
cyLeft = (float) cameraProperties.findGroup("CAMERA_CALIBRATION_LEFT").check("cy", Value(120.0), "cy left").asDouble();
cxRight = (float) cameraProperties.findGroup("CAMERA_CALIBRATION_RIGHT").check("cx", Value(160.0), "cx right").asDouble();
cyRight = (float) cameraProperties.findGroup("CAMERA_CALIBRATION_RIGHT").check("cy", Value(120.0), "cy right").asDouble();
}
/* get the name of the input and output ports, automatically prefixing the module name by using getName() */
inputPortName = "/";
inputPortName += getName(
rf.check("myInputPort",
Value("/demoModule/image:i"),
"Input image port (string)").asString()
);
outputPortName = "/";
outputPortName += getName(
rf.check("myOutputPort",
Value("/demoModule/image:o"),
"Output image port (string)").asString()
);
/* get the threshold value */
thresholdValue = rf.check("threshold",
Value(8),
"Key value (int)").asInt();
/* do all initialization here */
/*
* 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
/* create the thread and pass pointers to the module parameters */
dThread = new demoThread(&thresholdValue);
/* now start the thread to do the work */
dThread->start(); // this calls threadInit() and it if returns true, it then calls run()
return true ; // let the RFModule know everything went well
// so that it will then run the module
}
示例14: configure
bool learnPrimitive::configure(yarp::os::ResourceFinder &rf)
{
string moduleName = rf.check("name", Value("learnPrimitive")).asString().c_str();
setName(moduleName.c_str());
GrammarYesNo = rf.findFileByName(rf.check("GrammarYesNo", Value("nodeYesNo.xml")).toString());
GrammarNameAction = rf.findFileByName(rf.check("GrammarNameAction", Value("GrammarNameAction.xml")).toString());
GrammarTypeAction = rf.findFileByName(rf.check("GrammarTypeAction", Value("GrammarTypeAction.xml")).toString());
yInfo() << "findFileByName " << rf.findFileByName("learnPrimitive.ini") ;
pathToIniFile = rf.findFileByName("learnPrimitive.ini") ;
cout << moduleName << ": finding configuration files..." << endl;
period = rf.check("period", Value(0.1)).asDouble();
//bool bEveryThingisGood = true;
//Create an iCub Client and check that all dependencies are here before starting
bool isRFVerbose = true;
iCub = new ICubClient(moduleName, "learnPrimitive", "client.ini", isRFVerbose);
iCub->opc->isVerbose &= true;
string robot = rf.check("robot", Value("icubSim")).asString().c_str();
string arm = rf.check("arm", Value("left_arm")).asString().c_str();
portToArm.open(("/" + moduleName + "/toArm:rpc").c_str());
string portRobotArmName = "/" + robot + "/" + arm + "/rpc:i";
yInfo() << "================> port controlling the arm : " << portRobotArmName;
if (!Network::connect(portToArm.getName().c_str(),portRobotArmName))
{
yWarning() << "WARNING PORT TO CONTROL ARM (" << portRobotArmName << ") IS NOT CONNECTED";
}
if (!iCub->connect())
{
cout << "iCubClient : Some dependencies are not running..." << endl;
Time::delay(1.0);
}
//rpc port
rpcPort.open(("/" + moduleName + "/rpc").c_str());
attach(rpcPort);
if (!iCub->getRecogClient())
{
yWarning() << "WARNING SPEECH RECOGNIZER NOT CONNECTED";
}
if (!iCub->getABMClient())
{
yWarning() << "WARNING ABM NOT CONNECTED";
}
updateProtoAction(rf);
updatePrimitive(rf);
updateAction(rf);
yInfo() << "\n \n" << "----------------------------------------------" << "\n \n" << moduleName << " ready ! \n \n ";
iCub->say("learn Primitive is ready", false);
return true;
}
示例15: configure
bool lfCollectorModule::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("/logpolarFrameCollector"),
"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";\
/*
* 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
// --------------------------------------------
lfThread=new lfCollectorThread();
lfThread->setName(getName().c_str());
/*
* set the period between two successive synchronisations between viewer and events
*/
synchPeriod = rf.check("synchPeriod",
Value(10000),
"synchronisation period (int)").asInt();
lfThread->setSynchPeriod(synchPeriod);
/*
* set the retinaSize (considering squared retina)
*/
retinalSize = rf.check("retinalSize",
Value(128),
"retinalSize (int)").asInt();
lfThread->setRetinalSize(retinalSize);
/* checking whether the module synchronizes with single camera or stereo camera
*/
if( rf.check("stereo")) {
lfThread->setStereo(true);
}
else {
lfThread->setStereo(false);
}
/* checking whether the module synchronizes with single camera or stereo camera
*/
if( rf.check("em")) {
lfThread->setEM(true);
}
else {
lfThread->setEM(false);
}
/**
* checking whether the viewer represent log-polar information
*/
if( rf.check("logpolar")) {
lfThread->setLogPolar(true);
}
else {
lfThread->setLogPolar(false);
}
lfThread->start();
return true ; // let the RFModule know everything went well
// so that it will then run the module
}