本文整理汇总了C++中Searchable::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ Searchable::toString方法的具体用法?C++ Searchable::toString怎么用?C++ Searchable::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Searchable
的用法示例。
在下文中一共展示了Searchable::toString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: open
bool ServerSerial::open(Searchable& prop)
{
verb = (prop.check("verbose",Value(0),"Specifies if the device is in verbose mode (0/1).").asInt())>0;
if (verb)
printf("running with verbose output\n");
Value *name;
if (prop.check("subdevice",name,"name of specific control device to wrap")) {
printf("Subdevice %s\n", name->toString().c_str());
if (name->isString()) {
// maybe user isn't doing nested configuration
Property p;
p.setMonitor(prop.getMonitor(),
"subdevice"); // pass on any monitoring
p.fromString(prop.toString());
p.put("device",name->toString());
poly.open(p);
} else {
Bottle subdevice = prop.findGroup("subdevice").tail();
poly.open(subdevice);
}
if (!poly.isValid()) {
printf("cannot make <%s>\n", name->toString().c_str());
}
} else {
printf("\"--subdevice <name>\" not set for server_serial\n");
return false;
}
if (!poly.isValid()) {
return false;
}
ConstString rootName =
prop.check("name",Value("/serial"),
"prefix for port names").asString().c_str();
command_buffer.attach(toDevice);
reply_buffer.attach(fromDevice);
command_buffer.useCallback(callback_impl);
toDevice.open((rootName+"/in").c_str());
fromDevice.open((rootName+"/out").c_str());
if (poly.isValid())
poly.view(serial);
if(serial != NULL) {
start();
return true;
}
printf("subdevice <%s> doesn't look like a serial port (no appropriate interfaces were acquired)\n",
name->toString().c_str());
return false;
}
示例2: openAndAttachSubDevice
bool JoypadControlServer::openAndAttachSubDevice(Searchable& prop)
{
Property p;
m_subDeviceOwned = new PolyDriver;
p.fromString(prop.toString().c_str());
p.setMonitor(prop.getMonitor(), "subdevice"); // pass on any monitoring
p.unput("device");
p.put("device",prop.find("subdevice").asString()); // subdevice was already checked before
// if error occour during open, quit here.
m_subDeviceOwned->open(p);
if (!m_subDeviceOwned->isValid())
{
yError("JoypadControlServer: opening subdevice... FAILED\n");
return false;
}
m_isSubdeviceOwned = true;
if(!attach(m_subDeviceOwned))
return false;
if(!m_parser.configure(m_device) )
{
yError() << "JoypadControlServer: error configuring interfaces for parsers";
return false;
}
openPorts();
PeriodicThread::setPeriod(m_period);
return PeriodicThread::start();
}
示例3: openAndAttachSubDevice
bool RGBDSensorWrapper::openAndAttachSubDevice(Searchable& prop)
{
Property p;
subDeviceOwned = new PolyDriver;
p.fromString(prop.toString().c_str());
p.setMonitor(prop.getMonitor(), "subdevice"); // pass on any monitoring
p.unput("device");
p.put("device",prop.find("subdevice").asString()); // subdevice was already checked before
// if error occour during open, quit here.
yDebug("opening IRGBDSensor subdevice\n");
subDeviceOwned->open(p);
if (!subDeviceOwned->isValid())
{
yError("opening controlBoardWrapper2 subdevice... FAILED\n");
return false;
}
isSubdeviceOwned = true;
if(!attach(subDeviceOwned))
return false;
RateThread::setRate(rate);
RateThread::start();
return true;
}
示例4: open
bool HapticDeviceWrapper::open(Searchable &config)
{
portStemName=config.check("name",
Value(HAPTICDEVICE_WRAPPER_DEFAULT_NAME)).asString().c_str();
verbosity=config.check("verbosity",Value(0)).asInt();
int period=config.check("period",
Value(HAPTICDEVICE_WRAPPER_DEFAULT_PERIOD)).asInt();
setRate(period);
if (config.check("subdevice"))
{
Property p(config.toString().c_str());
p.setMonitor(config.getMonitor(),"subdevice");
p.unput("device");
p.put("device",config.find("subdevice").asString());
if (driver.open(p))
{
IHapticDevice *d;
driver.view(d);
attach(d);
}
else
{
yError("*** Haptic Device Wrapper: failed to open the driver!");
return false;
}
}
if (verbosity>0)
yInfo("*** Haptic Device Wrapper: opened");
return true;
}
示例5:
ResourceFinder::ResourceFinder(Searchable& data, void *implementation) {
this->implementation = implementation;
if (!data.isNull()) {
config.fromString(data.toString());
}
nullConfig = data.isNull();
owned = false;
isConfiguredFlag = true;
}
示例6: openAndAttachSubDevice
bool RGBDSensorWrapper::openAndAttachSubDevice(Searchable& prop)
{
Property p;
subDeviceOwned = new PolyDriver;
p.fromString(prop.toString().c_str());
p.setMonitor(prop.getMonitor(), "subdevice"); // pass on any monitoring
p.unput("device");
p.put("device",prop.find("subdevice").asString()); // subdevice was already checked before
// if error occour during open, quit here.
yDebug("opening IRGBDSensor subdevice\n");
subDeviceOwned->open(p);
if (!subDeviceOwned->isValid())
{
yError("opening controlBoardWrapper2 subdevice... FAILED\n");
return false;
}
isSubdeviceOwned = true;
if(!attach(subDeviceOwned))
return false;
// Configuring parsers
IRgbVisualParams * rgbVis_p;
IDepthVisualParams * depthVis_p;
subDeviceOwned->view(rgbVis_p);
subDeviceOwned->view(depthVis_p);
if(!parser.configure(sensor_p) )
{
yError() << "RGBD wrapper: error configuring interfaces for parsers";
return false;
}
/*
bool conf = rgbParser.configure(rgbVis_p);
conf &= depthParser.configure(depthVis_p);
if(!conf)
{
yError() << "RGBD wrapper: error configuring interfaces for parsers";
return false;
}
*/
RateThread::setRate(rate);
RateThread::start();
return true;
}
示例7: open
bool ReachManager::open(Searchable& config)
{
cout << "config : " << config.toString() << endl;
parameters["input_port"] = new Value(GetValueFromConfig(config, "input_port"));
parameters["output_port"] = new Value(GetValueFromConfig(config, "output_port"));
parameters["robot"] = new Value(GetValueFromConfig(config, "robot"));
parameters["num_dof"] = new Value(GetValueFromConfig(config, "num_dof"));
parameters["reach_command_code"] = new Value(GetValueFromConfig(config, "reach_command_code"));
parameters["max_error"] = new Value(GetValueFromConfig(config, "max_error"));
parameters["solver_name"] = new Value(GetValueFromConfig(config, "solver_name"));
parameters["enabled_arm"] = new Value(GetValueFromConfig(config, "enabled_arm"));
parameters["pos_vel_cont"] = new Value(GetValueFromConfig(config, "pos_vel_cont"));
parameters["min_reach_dist"] = new Value(GetValueFromConfig(config, "min_reach_dist"));
cout << "min reach dist : " << parameters["min_reach_dist"]->asDouble() << endl;
parameters["reach_mode_dist"] = new Value(GetValueFromConfig(config, "reach_mode_dist"));
cout << "reach mode dist : " << parameters["reach_mode_dist"]->asDouble() << endl;
parameters["object_ID"] = new Value(GetValueFromConfig(config, "object_ID"));
//cout << "cool !" << endl;
inPort.open(parameters["input_port"]->asString().c_str());
outPort.open(parameters["output_port"]->asString().c_str());
//Network::connect(outPort.getName().c_str(), "/manager");
outFile.open("reaching.dat");
if(parameters["enabled_arm"]->asString() == "left")
{
OpenIKSolver("left");
}
else if(parameters["enabled_arm"]->asString() == "right")
{
OpenIKSolver("right");
}
else if(parameters["enabled_arm"]->asString() == "both")
{
OpenIKSolver("left");
OpenIKSolver("right");
}
if(parameters["pos_vel_cont"]->asInt())
{
InitPositionControl("right");
InitPositionControl("left");
}
return true;
}
示例8: openAndAttachSubDevice
bool AnalogWrapper::openAndAttachSubDevice(Searchable &prop)
{
Property p;
subDeviceOwned = new PolyDriver;
p.fromString(prop.toString().c_str());
// p.setMonitor(prop.getMonitor(), "subdevice"); // pass on any monitoring
p.unput("device");
p.put("device", prop.find("subdevice").asString()); // subdevice was already checked before
// if error occour during open, quit here.
yDebug("opening analogServer subdevice...");
subDeviceOwned->open(p);
if (!subDeviceOwned->isValid())
{
yError("opening analogServer subdevice... FAILED\n");
return false;
}
subDeviceOwned->view(analogSensor_p);
if (analogSensor_p == 0)
{
yError("Opening IAnalogSensor interface of analogServer subdevice... FAILED\n");
return false;
}
int chNum = analogSensor_p->getChannels();
if (chNum <= 0)
{
yError("Calling analog sensor has invalid channels number %d.\n", chNum);
return false;
}
attach(analogSensor_p);
RateThread::setRate(_rate);
RateThread::start();
return true;
}
示例9: open
bool AcousticMap::open(Searchable& config) {
bool ok = true;
if(!config.check("name")) {
std::cout << "AuditoryMap: Error, module base name not found in configuration. Start the module with the --name option.." << std::endl;
return false;
}
// module base name
std::string strModuleName = std::string(config.find("name").asString().c_str());
// look for group EGO_SPHERE_ACOUSTIC_MAP
Bottle botConfigAcoustic(config.toString().c_str());
botConfigAcoustic.setMonitor(config.getMonitor());
if (!config.findGroup("EGO_SPHERE_ACOUSTIC_MAP").isNull()) {
botConfigAcoustic.clear();
botConfigAcoustic.fromString(config.findGroup("EGO_SPHERE_ACOUSTIC_MAP", "Loading visual map configuration from group EGO_SPHERE_ACOUSTIC_MAP.").toString());
}
_salienceDecayRate = botConfigAcoustic.check("decayAcoustic",
Value(0.95),
"Decay for the acoustic saliency map (double).").asDouble();
_resXAcoustic = botConfigAcoustic.check("resXAcoustic",
Value(80),
"Width of internal acoustic map (int)").asInt();
_resYAcoustic = botConfigAcoustic.check("resYAcoustic",
Value(60),
"Height of internal acoustic map (int)").asInt();
_imgCart.resize(_resXAcoustic,_resYAcoustic);
_imgRemapX.resize(_resXAcoustic,_resYAcoustic);
_imgRemapY.resize(_resXAcoustic,_resYAcoustic);
_imgSpher.resize(_resXAcoustic,_resYAcoustic);
_imgMapResA.resize(_resXAcoustic,_resYAcoustic);
ok = ok && _prtVctSound.open(std::string(strModuleName + std::string("/mapAuditory/vct_in")).c_str());
return ok;
}
示例10: open
virtual bool open(Searchable &s)
{
Time::turboBoost();
// get command line options
options.fromString(s.toString());
if (!options.check("robot") || !options.check("part"))
{
printf("Missing either --robot or --part options. Quitting!\n");
return false;
}
std::string dumpername;
// get dumepr name
if (options.check("name"))
{
dumpername = options.find("name").asString();
dumpername += "/";
}
else
{
dumpername = "/controlBoardDumper/";
}
Value& robot = options.find("robot");
Value& part = options.find("part");
configFileRobotPart = "config_";
configFileRobotPart = configFileRobotPart + robot.asString();
configFileRobotPart = configFileRobotPart + "_";
configFileRobotPart = configFileRobotPart + part.asString();
configFileRobotPart = configFileRobotPart + ".ini";
//get the joints to be dumped
getRate(options, rate);
if (getNumberUsedJoints(options, nJoints) == 0)
return false;
thetaMap = new int[nJoints];
if (getUsedJointsMap(options, nJoints, thetaMap) == 0)
return false;
//get the type of data to be dumped
if (getNumberDataToDump(options, nData) == 0)
return false;
dataToDump = new std::string[nData];
if (getDataToDump(options, dataToDump, nData, &useDebugClient) == 0)
return false;
// Printing configuration to the user
yInfo("Running with the following configuration:\n");
yInfo("Selected rate is: %d\n", rate);
yInfo("Data selected to be dumped are:\n");
for (int i = 0; i < nData; i++)
yInfo("\t%s \n", dataToDump[i].c_str());
//open remote control board
ddBoardOptions.put("device", "remote_controlboard");
ddDebugOptions.put("device", "debugInterfaceClient");
ConstString localPortName = name;
ConstString localDebugPortName = name;
localPortName = localPortName + dumpername.c_str();
localDebugPortName = localPortName + "debug/";
//localPortName = localPortName + robot.asString();
localPortName = localPortName + part.asString();
localDebugPortName = localDebugPortName + part.asString();
ddBoardOptions.put("local", localPortName.c_str());
ddDebugOptions.put("local", localDebugPortName.c_str());
ConstString remotePortName = "/";
ConstString remoteDebugPortName;
remotePortName = remotePortName + robot.asString();
remotePortName = remotePortName + "/";
remotePortName = remotePortName + part.asString();
ddBoardOptions.put("remote", remotePortName.c_str());
remoteDebugPortName = remotePortName + "/debug";
ddDebugOptions.put("remote", remoteDebugPortName.c_str());
// create a device
ddBoard.open(ddBoardOptions);
if (!ddBoard.isValid()) {
printf("Device not available.\n");
Network::fini();
return false;
}
if (useDebugClient )
{
ddDebug.open(ddDebugOptions);
if (!ddDebug.isValid())
{
yError("\n-----------------------------------------\n");
yError("Debug Interface is mandatory to run this module with the '--dataToDumpAll' option or to dump any of the getRotorxxx data.\n");
yError("Please Verify the following 2 conditions are satisfied:\n\n");
yError("1) Check 'debugInterfaceClient' is available using 'yarpdev --list' command\n");
//.........这里部分代码省略.........
示例11: QWidget
QWidgetModuleDefault::QWidgetModuleDefault(Searchable& config, QWidget* parent, const char* name, bool modal, WFlags fl)
: QWidget(parent, name, fl),
_qwViewer(NULL),
_qwOutput(NULL),
_qwRPC(NULL),
_qwConnections(NULL){
Property prop;
prop.fromString(config.toString());
if(!prop.check("name")){
prop.put("name", "/moduleGui");
}
this->setCaption("Yarp Default Module Interface");
// main layout (vbox)
QVBoxLayout *mainLayout = new QVBoxLayout( this, 3, 3, "QWidgetModuleDefaultBaseLayout");
// add a vertical split as first entry to main layout
QSplitter *splitMain = new QSplitter(this);
mainLayout->addWidget(splitMain);
// add horizontal splitter to left part of main splitter
QSplitter *splitLeft = new QSplitter(Qt::Vertical, splitMain);
Property propViewer; propViewer.fromString(prop.toString());
propViewer.put("name", std::string(std::string(propViewer.find("name").asString().c_str()) + std::string("/viewer")).c_str());
_qwViewer = new QWidgetViewer(propViewer, splitLeft); // the viewer widget
_qwConnections = new QWidgetConnections(prop, splitLeft); // the connection widget
// add horizontal splitter to right part of main splitter
QSplitter *splitRight = new QSplitter(Qt::Vertical, splitMain);
Property propOutput; propOutput.fromString(prop.toString());
propOutput.put("name", std::string(std::string(propOutput.find("name").asString().c_str()) + std::string("/stdout")).c_str());
_qwOutput = new QWidgetOutput(propOutput, splitRight); // the output widget
Property propRPC; propRPC.fromString(prop.toString());
propRPC.put("name", std::string(std::string(propRPC.find("name").asString().c_str()) + std::string("/rpc")).c_str());
_qwRPC = new QWidgetRPC(propRPC, splitRight); // the RPC widget
// add a frame as second entry in main layout
QFrame *frmBottom = new QFrame(this);
frmBottom->setMaximumHeight(35);
mainLayout->addWidget(frmBottom);
// add a layout to the bottom frame
QHBoxLayout *frmBottomLayout = new QHBoxLayout(frmBottom, 0, -1, "frmBottomLayout");
frmBottomLayout->setSpacing(3);
frmBottomLayout->setMargin(3);
// add a button to the bottom frame
QPushButton *btnCheckAll = new QPushButton(frmBottom);
btnCheckAll->setText("check all ports and connections");
frmBottomLayout->addWidget(btnCheckAll);
connect( btnCheckAll, SIGNAL( clicked() ), this, SLOT( btnCheckAll_clicked() ) );
this->resize(850,650);
QValueList<int> valsSplitMain;
valsSplitMain.append(400);
valsSplitMain.append(450);
splitMain->setSizes(valsSplitMain);
QValueList<int> valsSplitLeft;
valsSplitLeft.append(400);
valsSplitLeft.append(250);
splitLeft->setSizes(valsSplitLeft);
QValueList<int> valsSplitRight;
valsSplitRight.append(400);
valsSplitRight.append(250);
splitRight->setSizes(valsSplitRight);
// position screen center
QWidget* desk = QApplication::desktop();
this->move(desk->width()/2 - this->width()/2,desk->height()/2 - this->height()/2);
}
示例12: open
virtual bool open(Searchable &s)
{
Time::turboBoost();
// get command line options
options.fromString(s.toString());
if (!options.check("robot") || !options.check("part"))
{
printf("Missing either --robot or --part options. Quitting!\n");
return false;
}
// get command file options
Value& robot = options.find("robot");
Value& part = options.find("part");
configFileRobotPart = "config_";
configFileRobotPart = configFileRobotPart + robot.asString();
configFileRobotPart = configFileRobotPart + "_";
configFileRobotPart = configFileRobotPart + part.asString();
configFileRobotPart = configFileRobotPart + ".ini";
//get the joints to be dumped
getRate(options, rate);
fprintf(stderr, "Selected rate is: %d\n", rate);
if (getNumberUsedJoints(options, nJoints) == 0)
return false;
thetaMap = new int[nJoints];
if (getUsedJointsMap(options, nJoints, thetaMap) == 0)
return false;
//get the type of data to be dumped
if (getNumberDataToDump(options, nData) == 0)
return false;
dataToDump = new ConstString[nData];
if (getDataToDump(options, dataToDump, nData) == 0)
return false;
for (int i = 0; i < nData; i++)
fprintf(stderr, "%s \n", dataToDump[i].c_str());
//if (!fileOptions.check("d"))
// {
// fprintf(stderr, "Missing option 'd' in given config file\n");
// return 1;
// }
//Value& d = fileOptions.find("d");
//open remote control board
ddBoardOptions.put("device", "remote_controlboard");
ddDebugOptions.put("device", "debugInterfaceClient");
ConstString localPortName = name;
ConstString localDebugPortName = name;
localPortName = localPortName + "/controlBoardDumper/";
localDebugPortName = localPortName + "debug/";
//localPortName = localPortName + robot.asString();
localPortName = localPortName + part.asString();
localDebugPortName = localDebugPortName + part.asString();
ddBoardOptions.put("local", localPortName.c_str());
ddDebugOptions.put("local", localDebugPortName.c_str());
ConstString remotePortName = "/";
remotePortName = remotePortName + robot.asString();
remotePortName = remotePortName + "/";
remotePortName = remotePortName + part.asString();
ddBoardOptions.put("remote", remotePortName.c_str());
ddDebugOptions.put("remote", remotePortName.c_str());
fprintf(stderr, "%s", ddBoardOptions.toString().c_str());
// create a device
ddBoard.open(ddBoardOptions);
if (!ddBoard.isValid()) {
printf("Device not available. Here are the known devices:\n");
printf("%s", Drivers::factory().toString().c_str());
Network::fini();
return false;
}
ddDebug.open(ddDebugOptions);
if (!ddDebug.isValid()) {
printf("Debug Interface is mandatary to run this module. Here are the known devices:\n");
printf("%s", Drivers::factory().toString().c_str());
Network::fini();
return false;
}
bool logToFile = false;
if (options.check("logToFile")) logToFile = true;
portPrefix = "/";
portPrefix= portPrefix + "controlBoardDumper/" + part.asString() + "/";
//boardDumperThread *myDumper = new boardDumperThread(&dd, rate, portPrefix, dataToDump[0]);
//myDumper->setThetaMap(thetaMap, nJoints);
//.........这里部分代码省略.........
示例13: open
bool OpenCVGrabber::open(Searchable & config) {
// Release any previously allocated resources, just in case
close();
m_saidSize = false;
m_saidResize = false;
m_transpose = false;
m_flip_x = false;
m_flip_y = false;
// Are we capturing from a file or a camera ?
ConstString file = config.check("movie", Value(""),
"if present, read from specified file rather than camera").asString();
fromFile = (file!="");
if (fromFile) {
// Try to open a capture object for the file
m_capture = (void*)cvCaptureFromAVI(file.c_str());
if (0 == m_capture) {
yError("Unable to open file '%s' for capture!", file.c_str());
return false;
}
// Should we loop?
m_loop = config.check("loop","if present, loop movie");
} else {
m_loop = false;
int camera_idx =
config.check("camera",
Value(CV_CAP_ANY),
"if present, read from camera identified by this index").asInt();
// Try to open a capture object for the first camera
m_capture = (void*)cvCaptureFromCAM(camera_idx);
if (0 == m_capture) {
yError("Unable to open camera for capture!");
return false;
}
if ( config.check("framerate","if present, specifies desired camera device framerate") ) {
double m_fps = config.check("framerate", Value(-1)).asDouble();
cvSetCaptureProperty((CvCapture*)m_capture,
CV_CAP_PROP_FPS,m_fps);
}
if (config.check("flip_x", "if present, flip the image along the x-axis")) m_flip_x = true;
if (config.check("flip_y", "if present, flip the image along the y-axis")) m_flip_y = true;
if (config.check("transpose", "if present, rotate the image along of 90 degrees")) m_transpose = true;
}
// Extract the desired image size from the configuration if
// present, otherwise query the capture device
if (config.check("width","if present, specifies desired image width")) {
m_w = config.check("width", Value(-1)).asInt();
if (!fromFile && m_w>0) {
cvSetCaptureProperty((CvCapture*)m_capture,
CV_CAP_PROP_FRAME_WIDTH, m_w);
}
} else {
m_w = (int)cvGetCaptureProperty((CvCapture*)m_capture,
CV_CAP_PROP_FRAME_WIDTH);
}
if (config.check("height","if present, specifies desired image height")) {
m_h = config.check("height", Value(-1)).asInt();
if (!fromFile && m_h>0) {
cvSetCaptureProperty((CvCapture*)m_capture,
CV_CAP_PROP_FRAME_HEIGHT, m_h);
}
} else {
m_h = (int)cvGetCaptureProperty((CvCapture*)m_capture,
CV_CAP_PROP_FRAME_HEIGHT);
}
// Ignore capture properties - they are unreliable
// yDebug("Capture properties: %ld x %ld pixels @ %lf frames/sec.", m_w, m_h, cvGetCaptureProperty(m_capture, CV_CAP_PROP_FPS));
yInfo("OpenCVGrabber opened");
// Success!
// save our configuration for future reference
m_config.fromString(config.toString());
return true;
}
示例14: open
bool VirtualAnalogWrapper::open(Searchable& config)
{
cout << config.toString().c_str() << endl << endl;
mIsVerbose = (config.check("verbose","if present, give detailed output"));
if (mIsVerbose) cout << "running with verbose output\n";
//thus thread period is useful for output port... this input port has callback so maybe can skip it (?)
//thread_period = prop.check("threadrate", 20, "thread rate in ms. for streaming encoder data").asInt();
std::cout << "Using VirtualAnalogServer\n";
if (!config.check("networks", "list of networks merged by this wrapper"))
{
cerr << "Error: missing networks parameters" << endl;
return false;
}
Bottle *networks=config.find("networks").asList();
mNSubdevs=networks->size();
mSubdevices.resize(mNSubdevs);
mChan2Board.resize(MAX_ENTRIES);
mChan2BAddr.resize(MAX_ENTRIES);
for (int i=0; i< MAX_ENTRIES; i++)
{
mChan2Board[i]=-1;
mChan2BAddr[i]=-1;
}
int totalJ=0;
for (int k=0; k<networks->size(); ++k)
{
Bottle parameters=config.findGroup(networks->get(k).asString().c_str());
if (parameters.size()!=5) // mapping joints using the paradigm: part from - to / network from - to
{
cerr << "Error: check network parameters in part description" << endl;
cerr << "--> I was expecting " << networks->get(k).asString().c_str() << " followed by four integers" << endl;
return false;
}
int map0=parameters.get(1).asInt();
int map1=parameters.get(2).asInt();
int map2=parameters.get(3).asInt();
int map3=parameters.get(4).asInt();
if (map0 >= MAX_ENTRIES || map1 >= MAX_ENTRIES || map2>= MAX_ENTRIES || map3>= MAX_ENTRIES ||
map0 <0 || map1 <0 || map2<0 || map3<0)
{
cerr << "Error: invalid map entries in networks section, failed initial check" << endl;
return false;
}
for (int j=map0; j<=map1; ++j)
{
mChan2Board[j]=k;
mChan2BAddr[j]=j-map0+map2;
}
if (!mSubdevices[k].configure(map2,map3,networks->get(k).asString().c_str()))
{
cerr << "configure of subdevice ret false" << endl;
return false;
}
totalJ+=map1-map0+1;
}
// Verify minimum set of parameters required
if(!config.check("robotName") ) // ?? qui dentro, da dove lo pesco ??
{
cout << "VirtualAnalogServer missing robot Name, check your configuration file!! Quitting\n";
return false;
}
std::string root_name;
std::string port_name = config.check("name",Value("controlboard"),"prefix for port names").asString().c_str();
std::string robot_name = config.find("robotName").asString().c_str();
root_name+="/";
root_name+=robot_name;
root_name+= "/joint_vsens" + port_name + ":i";
if (!mPortInputTorques.open(root_name.c_str()))
{
cerr << "can't open port " << root_name.c_str() << endl;
return false;
}
return true;
}
示例15: open
bool VirtualAnalogClient::open(Searchable& config)
{
yarp::os::Property prop;
prop.fromString(config.toString());
if( !( prop.check("local") && prop.find("local").isString() ) )
{
yError("VirtualAnalogClient: Missing required local string parameter");
return false;
}
m_local = prop.find("local").asString();
if( !( prop.check("remote") && prop.find("remote").isString() ) )
{
yError("VirtualAnalogClient: Missing required remote string parameter");
return false;
}
m_remote = prop.find("remote").asString();
yarp::os::ConstString carrier;
if( ( prop.check("carrier") && prop.find("carrier").isString() ) )
{
carrier = prop.find("carrier").asString();
}
else
{
carrier = "tcp";
}
if( !( prop.check("AxisName") && prop.find("AxisName").isList() ) )
{
yError("VirtualAnalogClient: Missing required AxisName list parameter");
return false;
}
Bottle * AxisNameBot = prop.find("AxisName").asList();
m_axisName.resize(AxisNameBot->size());
for(int jnt=0; jnt < AxisNameBot->size(); jnt++)
{
m_axisName[jnt] = AxisNameBot->get(jnt).asString();
}
// Handle type
m_axisType.resize(m_axisName.size());
if( ( prop.check("AxisType") && prop.find("AxisType").isList() ) )
{
Bottle * AxisTypeBot = prop.find("AxisType").asList();
for(int jnt=0; jnt < AxisTypeBot->size(); jnt++)
{
ConstString type = AxisTypeBot->get(jnt).asString();
if (type == "revolute")
{
m_axisType[jnt] = VOCAB_JOINTTYPE_REVOLUTE;
}
else if (type == "prismatic")
{
m_axisType[jnt] = VOCAB_JOINTTYPE_UNKNOWN;
}
else
{
yError() << "VirtualAnalogClient: unknown joint type " << type;
return false;
}
}
}
else
{
for(size_t jnt=0; jnt < m_axisType.size(); jnt++)
{
m_axisType[jnt] = VOCAB_JOINTTYPE_REVOLUTE;
}
}
if( !( prop.check("virtualAnalogSensorInteger") && prop.find("virtualAnalogSensorInteger").isInt() ) )
{
yError("VirtualAnalogClient: Missing required virtualAnalogSensorInteger int parameter");
return false;
}
m_virtualAnalogSensorInteger = prop.find("virtualAnalogSensorInteger").isInt();
// Resize buffer
measureBuffer.resize(m_axisName.size(),0.0);
// Open the port
bool ok = m_outputPort.open(m_local);
if( !ok )
{
yError() << "VirtualAnalogClient: impossible to open port " << m_local;
}
// Connect the port
bool autoconnect = true;
if( prop.check("autoconnect") )
//.........这里部分代码省略.........