本文整理汇总了C++中yarp::os::Bottle::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Bottle::size方法的具体用法?C++ Bottle::size怎么用?C++ Bottle::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yarp::os::Bottle
的用法示例。
在下文中一共展示了Bottle::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: merge
int merge(yarp::os::Bottle& mergeArg, folderType fType, bool verbose)
{
ConstString contextName;
if (mergeArg.size() >1 )
contextName=mergeArg.get(1).asString().c_str();
if (contextName=="")
{
printf("No %s name provided\n", fType==CONTEXTS ? "context" : "robot");
return 0;
}
yarp::os::ResourceFinder rf;
rf.setVerbose(verbose);
if (mergeArg.size() >2 )
{
for (int i=2; i<mergeArg.size(); ++i)
{
ConstString fileName=mergeArg.get(i).asString();
if(fileName != "")
{
ResourceFinderOptions opts;
opts.searchLocations=ResourceFinderOptions::User;
ConstString userFileName=rf.findPath((getFolderStringName(fType) + PATH_SEPARATOR +contextName + PATH_SEPARATOR + fileName).c_str(), opts);
ConstString hiddenFileName=rf.findPath((getFolderStringNameHidden(fType) + PATH_SEPARATOR +contextName+ PATH_SEPARATOR + fileName).c_str(), opts);
opts.searchLocations=ResourceFinderOptions::Installed;
ConstString installedFileName=rf.findPath((getFolderStringName(fType) + PATH_SEPARATOR +contextName+ PATH_SEPARATOR + fileName).c_str(), opts);
if (userFileName!="" && hiddenFileName != "" && installedFileName !="")
fileMerge(installedFileName, userFileName, hiddenFileName);
else if (userFileName!="" && installedFileName !="")
printf("Need to use mergetool\n");
else
printf("Could not merge file %s\n", fileName.c_str());
}
}
}
else
{
ResourceFinderOptions opts;
opts.searchLocations=ResourceFinderOptions::User;
ConstString userPath=rf.findPath((getFolderStringName(fType) + PATH_SEPARATOR +contextName).c_str(), opts);
ConstString hiddenUserPath=rf.findPath((getFolderStringNameHidden(fType) + PATH_SEPARATOR +contextName).c_str(), opts);
opts.searchLocations=ResourceFinderOptions::Installed;
ConstString installedPath=rf.findPath((getFolderStringName(fType) + PATH_SEPARATOR +contextName).c_str(), opts);
recursiveMerge(installedPath, userPath, hiddenUserPath);
}
return 0;
}
示例2: arrayRooted
/*! @brief Convert a YARP list into a %JavaScript object.
@param[in] jct The %JavaScript engine context.
@param[in,out] theData The output object.
@param[in] inputValue The value to be processed. */
static void
convertList(JSContext * jct,
JS::MutableHandleValue theData,
const yarp::os::Bottle & inputValue)
{
ODL_ENTER(); //####
ODL_P2("jct = ", jct, "inputValue = ", &inputValue); //####
JSObject * valueArray = JS_NewArrayObject(jct, 0);
if (valueArray)
{
JS::RootedObject arrayRooted(jct);
JS::RootedValue anElement(jct);
JS::RootedId aRootedId(jct);
arrayRooted = valueArray;
for (int ii = 0, mm = inputValue.size(); mm > ii; ++ii)
{
yarp::os::Value aValue(inputValue.get(ii));
convertValue(jct, &anElement, aValue);
if (JS_IndexToId(jct, ii, &aRootedId))
{
JS_SetPropertyById(jct, arrayRooted, aRootedId, anElement);
}
}
theData.setObject(*valueArray);
}
ODL_EXIT(); //####
} // convertList
示例3: defined
bool
RandomRequestHandler::processRequest(const YarpString & request,
const yarp::os::Bottle & restOfInput,
const YarpString & senderChannel,
yarp::os::ConnectionWriter * replyMechanism)
{
#if (! defined(ODL_ENABLE_LOGGING_))
# if MAC_OR_LINUX_
# pragma unused(request,senderChannel)
# endif // MAC_OR_LINUX_
#endif // ! defined(ODL_ENABLE_LOGGING_)
ODL_OBJENTER(); //####
ODL_S3s("request = ", request, "restOfInput = ", restOfInput.toString(), //####
"senderChannel = ", senderChannel); //####
ODL_P1("replyMechanism = ", replyMechanism); //####
bool result = true;
try
{
int count;
_response.clear();
if (0 < restOfInput.size())
{
yarp::os::Value number(restOfInput.get(0));
if (number.isInt())
{
count = number.asInt();
}
else
{
count = -1;
}
}
else
{
count = 1;
}
if (count > 0)
{
for (int ii = 0; ii < count; ++ii)
{
_response.addDouble(yarp::os::Random::uniform());
}
}
else
{
ODL_LOG("! (count > 0)"); //####
}
sendResponse(replyMechanism);
}
catch (...)
{
ODL_LOG("Exception caught"); //####
throw;
}
ODL_OBJEXIT_B(result); //####
return result;
} // RandomRequestHandler::processRequest
示例4: setRot
void WorldRpcInterface::setRot( const yarp::os::Bottle& command, yarp::os::Bottle& reply, int& n )
{
KinematicModel::CompositeObject* object = getObject( command, reply, n );
if ( object )
{
if ((command.size() - n) == 3) {
double x = command.get(n).asDouble()*M_PI/180.; n++; //std::cout << x << std::endl; // x position
double y = command.get(n).asDouble()*M_PI/180.; n++; //std::cout << y << std::endl; // y position
double z = command.get(n).asDouble()*M_PI/180.; n++; //std::cout << z << std::endl; // z position
object->setCartesianOrientation( QVector3D(x,y,z) );
reply.addString("Set rotation (about x,y,z in degrees).");
} else {
// replace rotation part of object's T matrix
QMatrix4x4 rt = object->getT();
for (int i = 0; i<3; i++) {
for (int j = 0; j<3; j++) {
rt(i, j) = command.get(n).asDouble(); n++;
}
}
object->setT(rt);
reply.addString("Set full rotation matrix.");
}
}
}
示例5: bottleToVector
bool skinManager::bottleToVector(const yarp::os::Bottle& b, yarp::sig::Vector& v){
for(int i=0; i<b.size(); i++)
if(b.get(i).isDouble() || b.get(i).isInt())
v.push_back(b.get(i).asDouble());
else
return false;
return true;
}
示例6:
void wysiwyd::wrdac::SubSystem_Reactable::SendOSC(yarp::os::Bottle &oscMsg)
{
yarp::os::Bottle cmd;
cmd.addString("osc");
for(int i=0; i<oscMsg.size(); i++)
cmd.add(oscMsg.get(i));
std::cout<<"OSC>>"<<cmd.toString().c_str()<<std::endl;
portRTrpc.write(cmd);
}
示例7: findFileBase
void findFileBase(Property& config, const char *name,
bool isDir,
Bottle& output, bool justTop) {
ConstString cap =
config.check("capability_directory",Value("app")).asString();
Bottle defCaps =
config.findGroup("default_capability").tail();
// check current directory
if (ConstString(name)==""&&isDir) {
output.addString(getPwd());
if (justTop) return;
}
ConstString str = check(getPwd(),"","",name,isDir);
if (str!="") {
output.addString(str);
if (justTop) return;
}
if (configFilePath!="") {
ConstString str = check(configFilePath.c_str(),"","",name,isDir);
if (str!="") {
output.addString(str);
if (justTop) return;
}
}
// check app dirs
for (int i=0; i<apps.size(); i++) {
str = check(root.c_str(),cap,apps.get(i).asString().c_str(),
name,isDir);
if (str!="") {
output.addString(str);
if (justTop) return;
}
}
// check ROOT/app/default/
for (int i=0; i<defCaps.size(); i++) {
str = check(root.c_str(),cap,defCaps.get(i).asString().c_str(),
name,isDir);
if (str!="") {
output.addString(str);
if (justTop) return;
}
}
if (justTop) {
if (!quiet) {
fprintf(RTARGET,"||| did not find %s\n", name);
}
}
}
示例8: if
bool
TruncateFloatFilterInputHandler::handleInput(const yarp::os::Bottle & input,
const YarpString & senderChannel,
yarp::os::ConnectionWriter * replyMechanism,
const size_t numBytes)
{
#if (! defined(ODL_ENABLE_LOGGING_))
# if MAC_OR_LINUX_
# pragma unused(senderChannel,replyMechanism,numBytes)
# endif // MAC_OR_LINUX_
#endif // ! defined(ODL_ENABLE_LOGGING_)
ODL_OBJENTER(); //####
ODL_S2s("senderChannel = ", senderChannel, "got ", input.toString()); //####
ODL_P1("replyMechanism = ", replyMechanism); //####
ODL_I1("numBytes = ", numBytes); //####
bool result = true;
try
{
yarp::os::Bottle outBottle;
for (int ii = 0, mm = input.size(); mm > ii; ++ii)
{
yarp::os::Value aValue(input.get(ii));
if (aValue.isInt())
{
outBottle.addInt(aValue.asInt());
}
else if (aValue.isDouble())
{
outBottle.addInt(static_cast<int>(aValue.asDouble()));
}
}
if ((0 < outBottle.size()) && _outChannel)
{
if (! _outChannel->write(outBottle))
{
ODL_LOG("(! _outChannel->write(message))"); //####
#if defined(MpM_StallOnSendProblem)
Stall();
#endif // defined(MpM_StallOnSendProblem)
}
}
}
catch (...)
{
ODL_LOG("Exception caught"); //####
throw;
}
ODL_OBJEXIT_B(result); //####
return result;
} // TruncateFloatFilterInputHandler::handleInput
示例9: respond
/* Respond function */
bool opcManager::respond(const yarp::os::Bottle& bCommand, yarp::os::Bottle& bReply)
{
string helpMessage = string(getName().c_str()) +
" commands are: \n" +
"help \n" +
"connect + name\n" +
"quit \n";
bReply.clear();
string keyWord = bCommand.get(0).asString().c_str();
if (keyWord == "quit") {
bReply.addString("quitting");
return false;
}
else if (keyWord == "help") {
cout << helpMessage;
bReply.addString("ok");
}
else if (keyWord == "connect") {
bReply = connect(bCommand);
}
else if (keyWord == "updateBeliefs") {
bReply.addString("nack");
if (bCommand.size() == 2)
{
if (bCommand.get(1).isString())
{
bReply.addList() = updateBelief(bCommand.get(1).toString().c_str());
}
}
}
else if (keyWord == "synchronise")
{
bReply.addString("ack");
bReply.addList() = synchoniseOPCs();
}
else if (keyWord == "executeActivity")
{
bReply.addString("ack");
bReply.addList() = simulateActivity(bCommand);
}
else if (keyWord == "diffOPC")
{
bReply.addString("ack");
bReply.addList() = diffOPC();
}
return true;
}
示例10: decode
bool GaussianAE::decode(const yarp::os::Bottle &packet, size_t &pos)
{
if (LabelledAE::decode(packet, pos) && pos + 3 <= packet.size())
{
_gaei[0] = packet.get(pos++).asInt();
_gaei[1] = packet.get(pos++).asInt();
_gaei[2] = packet.get(pos++).asInt();
return true;
}
return false;
}
示例11: startSimSyncer
void WorldRpcInterface::startSimSyncer(const yarp::os::Bottle& command, yarp::os::Bottle& reply, int& n) {
if ((command.size() - n) != 1) {
reply.addString("Please provide the refresh period for the synchronization thread in seconds");
return;
}
double period = command.get(n).asDouble(); n++;
if (model->getSimSyncer().isRunning()) {
model->getSimSyncer().stop();
}
model->getSimSyncer().setRefreshPeriod(period);
model->getSimSyncer().start();
reply.addString("ok");
}
示例12: fromBottle
bool FTCalibrationDataset::fromBottle(const yarp::os::Bottle &bot)
{
if( bot.size() != 2
|| !(bot.get(0).isString())
|| !(bot.get(1).isList())
|| !(bot.get(1).asList()->size() == 2)
|| !(bot.get(1).asList()->get(0).isString())
|| !(bot.get(1).asList()->get(0).asString() == "mass")
|| !(bot.get(1).asList()->get(1).isDouble())
)
{
return false;
}
dataset_name = bot.get(0).asString();
added_mass = bot.get(1).asList()->get(1).asDouble();
return true;
}
示例13: parseSimRTBottle
bool WorldRpcInterface::parseSimRTBottle(const std::string name, const yarp::os::Bottle& command, int& n, QMatrix4x4 &rt) {
if ( (command.size()-n) != 6) {
return false;
}
//position
double px = command.get(n).asDouble(); n++;
double py = command.get(n).asDouble(); n++;
double pz = command.get(n).asDouble(); n++;
// rotation
double rx = command.get(n).asDouble(); n++;
double ry = command.get(n).asDouble(); n++;
double rz = command.get(n).asDouble(); n++;
// special simulator rotation:
QQuaternion qrx = QQuaternion::fromAxisAndAngle( QVector3D(1, 0, 0), -rz);
QQuaternion qry = QQuaternion::fromAxisAndAngle( QVector3D(0, 1, 0), -rx);
QQuaternion qrz = QQuaternion::fromAxisAndAngle( QVector3D(0, 0, 1), ry);
rt.setToIdentity();
rt.rotate(qry * (qrz*qrx));
// cylinders are rotated 90 degrees on the z-axis with respect to iCubSIM:
QRegExp rxtype("([^\\d]+)(?:\\s*\\d+)"); // check for: {[one or more non-numeric characters]: return as part 1} {[zero or more whitespace characters followed by one or more numeric characters]: do not return}
int pos = rxtype.indexIn(QString(name.c_str()));
if (pos > -1) {
yarp::os::Value type(rxtype.cap(1).toStdString().c_str());
int vtype = type.asVocab();
if (vtype == VOCAB_CYL || vtype == VOCAB_SCYL) {
rt.rotate( QQuaternion::fromAxisAndAngle( QVector3D(0, 0, 1), 90));
}
}
// position translation
rt(0, 3) = -(pz + 0.026);
rt(1, 3) = -px;
rt(2, 3) = py-0.5976;
return true;
}
示例14: _handleIAnalog
bool AnalogServerHandler::_handleIAnalog(yarp::os::Bottle &cmd, yarp::os::Bottle &reply)
{
yTrace();
if (is==0)
return false;
int msgsize=cmd.size();
int code=cmd.get(1).asVocab();
switch (code)
{
case VOCAB_CALIBRATE:
if (msgsize==2)
is->calibrateSensor();
else
{
//read Vector of values and pass to is->calibrate();
}
return true;
break;
case VOCAB_CALIBRATE_CHANNEL:
if (msgsize==3)
{
int ch=cmd.get(2).asInt();
is->calibrateChannel(ch);
}
if (msgsize==4)
{
int ch=cmd.get(2).asInt();
double v=cmd.get(3).asDouble();
is->calibrateChannel(ch, v);
}
return true;
break;
default:
return false;
}
}
示例15: fromTemplate
std::string WireTwiddler::fromTemplate(const yarp::os::Bottle& msg) {
string result = "";
// assume we want to remove any meta-information
int len = msg.size();
int code = -1;
for (int i=0; i<len; i++) {
Value&v = msg.get(i);
int icode = v.getCode();
if (i==0) code = icode;
if (icode!=code) code = -1;
}
string codeName = nameThatCode(code);
if (code == -1) {
result += "list ";
} else {
result += "vector ";
result += codeName;
result += " ";
}
result += NetType::toString(len).c_str();
result += " ";
for (int i=0; i<len; i++) {
Value&v = msg.get(i);
if (!v.isList()) {
if (code == -1) {
result += nameThatCode(v.getCode());
result += " ";
}
result += "* ";
} else {
result += fromTemplate(*v.asList());
}
}
return result;
}