本文整理汇总了C++中yarp::os::Bottle类的典型用法代码示例。如果您正苦于以下问题:C++ Bottle类的具体用法?C++ Bottle怎么用?C++ Bottle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Bottle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: convertList
/*! @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
开发者ID:MovementAndMeaning,项目名称:Core_MPlusM,代码行数:34,代码来源:m+mJavaScriptFilterService.cpp
示例2: 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
开发者ID:MovementAndMeaning,项目名称:Core_MPlusM,代码行数:60,代码来源:m+mRandomRequestHandler.cpp
示例3: encode
void GaussianAE::encode(yarp::os::Bottle &b) const
{
LabelledAE::encode(b);
b.addInt32(_gaei[0]);
b.addInt32(_gaei[1]);
b.addInt32(_gaei[2]);
}
开发者ID:robotology-playground,项目名称:event-driven,代码行数:7,代码来源:codec_GaussianAE.cpp
示例4: parse_respond_string
/**
* Parser for string commands. It is called by virtual bool respond().
* @param command the bottle containing the user command
* @param reply the bottle which will be returned to the RPC client
* @return true if the command was successfully parsed
*/
bool parse_respond_string(const yarp::os::Bottle& command, yarp::os::Bottle& reply)
{
if (command.get(0).isString() && command.get(0).asString() == "getLoc")
{
std::string s = std::string("Current Location is: ") + m_localization_data.toString();
reply.addString(s);
}
else if (command.get(0).isString() && command.get(0).asString() == "initLoc")
{
yarp::dev::Map2DLocation loc;
loc.map_id = command.get(1).asString();
loc.x = command.get(2).asDouble();
loc.y = command.get(3).asDouble();
loc.theta = command.get(4).asDouble();
initializeLocalization(loc);
std::string s = std::string("Localization initialized to: ") + loc.toString();
reply.addString(s);
}
else
{
reply.addString("Unknown command.");
}
return true;
}
开发者ID:robotology,项目名称:navigation,代码行数:31,代码来源:main.cpp
示例5: parse_respond_vocab
/**
* Parser for VOCAB commands. It is called by virtual bool respond().
* @param command the bottle containing the user command
* @param reply the bottle which will be returned to the RPC client
* @return true if the command was successfully parsed
*/
bool parse_respond_vocab(const yarp::os::Bottle& command, yarp::os::Bottle& reply)
{
int request = command.get(1).asVocab();
if (request == VOCAB_NAV_GET_CURRENT_POS)
{
//plannerThread->setNewAbsTarget(loc);
reply.addVocab(VOCAB_OK);
reply.addString(m_localization_data.map_id);
reply.addDouble(m_localization_data.x);
reply.addDouble(m_localization_data.y);
reply.addDouble(m_localization_data.theta);
}
else if (request == VOCAB_NAV_SET_INITIAL_POS)
{
yarp::dev::Map2DLocation loc;
loc.map_id = command.get(2).asString();
loc.x = command.get(3).asDouble();
loc.y = command.get(4).asDouble();
loc.theta = command.get(5).asDouble();
initializeLocalization(loc);
reply.addVocab(VOCAB_OK);
}
else
{
reply.addVocab(VOCAB_ERR);
}
return true;
}
开发者ID:robotology,项目名称:navigation,代码行数:34,代码来源:main.cpp
示例6: worked
bool yarp::dev::ServerInertial::getInertial(yarp::os::Bottle &bot)
{
if (IMU==NULL)
{
return false;
}
else
{
int nchannels;
IMU->getChannels (&nchannels);
yarp::sig::Vector indata(nchannels);
bool worked(false);
worked=IMU->read(indata);
if (worked)
{
bot.clear();
// Euler+accel+gyro+magn orientation values
for (int i = 0; i < nchannels; i++)
bot.addDouble (indata[i]);
}
else
{
bot.clear(); //dummy info.
}
return(worked);
}
}
开发者ID:giuliavezzani,项目名称:yarp,代码行数:31,代码来源:ServerInertial.cpp
示例7: listSubscriptions
bool SubscriberOnSql::listSubscriptions(const ConstString& port,
yarp::os::Bottle& reply) {
mutex.wait();
sqlite3_stmt *statement = NULL;
char *query = NULL;
if (ConstString(port)!="") {
query = sqlite3_mprintf("SELECT s.srcFull, s.DestFull, EXISTS(SELECT topic FROM topics WHERE topic = s.src), EXISTS(SELECT topic FROM topics WHERE topic = s.dest), s.mode FROM subscriptions s WHERE s.src = %Q OR s.dest= %Q ORDER BY s.src, s.dest",port.c_str(),port.c_str());
} else {
query = sqlite3_mprintf("SELECT s.srcFull, s.destFull, EXISTS(SELECT topic FROM topics WHERE topic = s.src), EXISTS(SELECT topic FROM topics WHERE topic = s.dest), s.mode FROM subscriptions s ORDER BY s.src, s.dest");
}
if (verbose) {
printf("Query: %s\n", query);
}
int result = sqlite3_prepare_v2(SQLDB(implementation),query,-1,&statement,
NULL);
if (result!=SQLITE_OK) {
const char *msg = sqlite3_errmsg(SQLDB(implementation));
if (msg!=NULL) {
fprintf(stderr,"Error: %s\n", msg);
}
}
reply.addString("subscriptions");
while (result == SQLITE_OK && sqlite3_step(statement) == SQLITE_ROW) {
char *src = (char *)sqlite3_column_text(statement,0);
char *dest = (char *)sqlite3_column_text(statement,1);
int srcTopic = sqlite3_column_int(statement,2);
int destTopic = sqlite3_column_int(statement,3);
char *mode = (char *)sqlite3_column_text(statement,4);
Bottle& b = reply.addList();
b.addString("subscription");
Bottle bsrc;
bsrc.addString("src");
bsrc.addString(src);
Bottle bdest;
bdest.addString("dest");
bdest.addString(dest);
b.addList() = bsrc;
b.addList() = bdest;
if (mode!=NULL) {
if (mode[0]!='\0') {
Bottle bmode;
bmode.addString("mode");
bmode.addString(mode);
b.addList() = bmode;
}
}
if (srcTopic||destTopic) {
Bottle btopic;
btopic.addString("topic");
btopic.addInt(srcTopic);
btopic.addInt(destTopic);
b.addList() = btopic;
}
}
sqlite3_finalize(statement);
sqlite3_free(query);
mutex.post();
return true;
}
开发者ID:JoErNanO,项目名称:yarp,代码行数:60,代码来源:SubscriberOnSql.cpp
示例8: 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;
}
开发者ID:apaikan,项目名称:icub-main,代码行数:8,代码来源:skinManager.cpp
示例9:
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);
}
开发者ID:caomw,项目名称:wysiwyd,代码行数:9,代码来源:subSystem_reactable.cpp
示例10: respClass
void WorldRpcInterface::respClass( const yarp::os::Bottle& command, yarp::os::Bottle& reply, int& n )
{
KinematicModel::CompositeObject* object = getObject( command, reply, n );
if ( object )
{
//model->clearWorldObject(object);
model->removeWorldObject(object);
int type = command.get(n).asVocab();
QColor collidingColor,freeColor;
switch (type)
{
case VOCAB_OBSTACLE:
freeColor = Qt::blue;
freeColor = freeColor.lighter();
collidingColor = freeColor;
freeColor.setAlphaF(0.5);
collidingColor.setAlphaF(0.5);
object->setResponseClass(model->OBSTACLE());
object->setFreeColor( freeColor );
object->setCollidingColor( collidingColor );
reply.addString("Changed object type to 'obstacle'.");
break;
case VOCAB_TARGET:
freeColor = Qt::green;
freeColor = freeColor.lighter();
collidingColor = freeColor;
freeColor.setAlphaF(1.0);
collidingColor.setAlphaF(0.5);
object->setResponseClass(model->TARGET());
object->setFreeColor( freeColor );
object->setCollidingColor( collidingColor );
reply.addString("Changed object type to 'target'.");
break;
default:
reply.addString("Unknown definition, use 'obs' or 'tgt'.");
}
model->appendObject( object );
}
}
开发者ID:xufango,项目名称:contrib_bk,代码行数:56,代码来源:worldRpcInterface.cpp
示例11: onRead
void YarpManager::onRead(yarp::os::Bottle& b) {
std::string name = b.get(0).asString().c_str();
int value = b.get(1).asInt();
if(name == "acuity") setAcuity(value);
else if(name == "fov") setFov(value);
else if(name == "brightness") setBrightness(value);
else if(name == "threshold") setTreshold(value);
else std::cout<<"Bottle message incorrect"<<std::endl;
}
开发者ID:ChrisdAutume,项目名称:MoDelVi,代码行数:10,代码来源:YarpManager.cpp
示例12: 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);
}
}
}
开发者ID:johnty,项目名称:libYARP_OS,代码行数:54,代码来源:ResourceFinder.cpp
示例13: cmdQuery
virtual bool cmdQuery(yarp::os::Bottle& cmd,
yarp::os::Bottle& reply,
yarp::os::Contact& remote) {
reply.addString("old");
ConstString name = cmd.get(1).asString();
Contact c = Network::queryName(name);
if (c.isValid()) {
appendEntry(reply,c);
}
return true;
}
开发者ID:jgvictores,项目名称:yarp,代码行数:11,代码来源:main.cpp
示例14: 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;
}
开发者ID:SibghatullahSheikh,项目名称:yarp,代码行数:53,代码来源:yarpcontextutils.cpp
示例15: defined
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
开发者ID:MovementAndMeaning,项目名称:Core_MPlusM,代码行数:53,代码来源:m+mTruncateFloatFilterInputHandler.cpp
示例16: 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;
}
开发者ID:robotology-playground,项目名称:event-driven,代码行数:12,代码来源:codec_GaussianAE.cpp
示例17: set
void WorldRpcInterface::set( const yarp::os::Bottle& command, yarp::os::Bottle& reply, int& n )
{
KinematicModel::CompositeObject* object = getObject( command, reply, n );
if ( object )
{
double x = command.get(n).asDouble(); n++; //std::cout << x << std::endl; // x position
double y = command.get(n).asDouble(); n++; //std::cout << y << std::endl; // y position
double z = command.get(n).asDouble(); n++; //std::cout << z << std::endl; // z position
object->setPosition( QVector3D(x,y,z) );
reply.addString("Set Cartesian position of object.");
}
}
开发者ID:xufango,项目名称:contrib_bk,代码行数:13,代码来源:worldRpcInterface.cpp
示例18: cmdQuery
virtual bool cmdQuery(yarp::os::Bottle& cmd,
yarp::os::Bottle& reply,
yarp::os::Contact& remote) {
reply.addString("old");
string name = cmd.get(1).asString().c_str();
map<string,Entry>::iterator it = names.find(name);
if (it==names.end()) {
return true;
}
Entry& e = it->second;
appendEntry(reply,e);
return true;
}
开发者ID:AbuMussabRaja,项目名称:yarp,代码行数:13,代码来源:main.cpp
示例19: 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");
}
开发者ID:xufango,项目名称:contrib_bk,代码行数:13,代码来源:worldRpcInterface.cpp
示例20: getEnvelope
void Rangefinder2DInputPortProcessor::onRead(yarp::os::Bottle &b)
{
now=SystemClock::nowSystem();
mutex.wait();
if (count>0)
{
double tmpDT=now-prev;
deltaT+=tmpDT;
if (tmpDT>deltaTMax)
deltaTMax=tmpDT;
if (tmpDT<deltaTMin)
deltaTMin=tmpDT;
//compare network time
if (tmpDT*1000<LASER_TIMEOUT)
{
state = b.get(1).asInt();
}
else
{
state = IRangefinder2D::DEVICE_TIMEOUT;
}
}
prev=now;
count++;
lastBottle=b;
Stamp newStamp;
getEnvelope(newStamp);
//initialialization (first received data)
if (lastStamp.isValid()==false)
{
lastStamp = newStamp;
}
//now compare timestamps
if ((1000*(newStamp.getTime()-lastStamp.getTime()))<LASER_TIMEOUT)
{
state = b.get(1).asInt();
}
else
{
state = IRangefinder2D::DEVICE_TIMEOUT;
}
lastStamp = newStamp;
mutex.post();
}
开发者ID:jgvictores,项目名称:yarp,代码行数:51,代码来源:Rangefinder2DClient.cpp
注:本文中的yarp::os::Bottle类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论