本文整理汇总了C++中Bottle::addList方法的典型用法代码示例。如果您正苦于以下问题:C++ Bottle::addList方法的具体用法?C++ Bottle::addList怎么用?C++ Bottle::addList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bottle
的用法示例。
在下文中一共展示了Bottle::addList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sendOPC
void AwareTouch::sendOPC(const string &partTouch, int &typeTouch, const Vector& posTouch, double sizeTouched)
{
Vector dimensions;
dimensions.clear();
dimensions.push_back(0.05);
dimensions.push_back(0.05);
dimensions.push_back(0.05);
cout<<"Touch Pos:"<<posTouch.toString().c_str()<<endl;
(touchLocation ->m_ego_position) = posTouch;
(touchLocation ->m_dimensions) = dimensions;
touchLocation->m_present = 1.0;
world->commit(touchLocation); // add position of touching
world->addRelation(Relation("icub","is",gestureSet[typeTouch], "touchLocation"), recordingPeriod); // add the relation with gesture
Bottle outEvent;
Bottle &what=outEvent.addList();
what.addString(partTouch.c_str());
what.addString(gestureSet[typeTouch].c_str());
Bottle &where=outEvent.addList();
where.read(const_cast<Vector&>(posTouch));
eventsPort.write(outEvent);
cout<<"icub is being "<< gestureSet[typeTouch]<<" at:"<< posTouch.toString().c_str() <<endl;
lastAutoSnapshotTime = Time::now();
}
示例2: actionCommand
Bottle learnPrimitive::actionCommand(string sActionName, string sArg){
Bottle bOutput;
//1. check if primitive is known
// vPrimitiveActionBottle =
// open (hand) ( (unfold thumb) (unfold index) (unfold middle) (unfold ring) )
// close (hand) ( (fold thumb) (fold index) (fold middle) (fold ring) )
// b.get(1) b.get(2) b.get(3)
// name arg list of proto-action
Bottle bSubActionList;
for(std::vector<yarp::os::Bottle>::iterator it = vActionBottle.begin(); it < vActionBottle.end(); it++){
string currentName = it->get(0).toString();
//yInfo() << "Current name of the knwon actions : " << currentName ;
if(currentName == sActionName){
yInfo() << "found " << currentName << "as a known complex action";
string currentArg = it->get(1).toString();
if(currentArg == sArg){
yInfo() << "and we have a corresponding argument " << currentArg ;
for(int i = 0; i < it->get(2).asList()->size(); i++){
bSubActionList.addList() = *it->get(2).asList()->get(i).asList() ;
}
break;
} else {
yInfo() << " BUT argument " << currentArg << " does NOT match" ;
}
}
}
if (bSubActionList.size() == 0){
yError() << " error in learnPrimitive::actionCommand | action '" << sActionName << " " << sArg << "' is NOT known";
bOutput.addString("error");
bOutput.addString("action is NOT known");
return bOutput ;
}
yInfo() << "Actions to do : " << bSubActionList.toString() ;
for(int i = 0; i < bSubActionList.size(); i++){
yInfo() << "action #" << i << " : "<< bSubActionList.get(i).asList()->get(0).toString() << " the " << bSubActionList.get(i).asList()->get(1).asList()->get(0).toString() ;
//1. check if subaction is a proto
if ( mProtoActionEnd.find(bSubActionList.get(i).asList()->get(0).toString()) != mProtoActionEnd.end() ) { //proto-action
bOutput.addList() = protoCommand(bSubActionList.get(i).asList()->get(0).toString(), bSubActionList.get(i).asList()->get(1).asList()->get(0).toString());
} else { //primitive
bOutput.addList() = primitiveCommand(bSubActionList.get(i).asList()->get(0).toString(), bSubActionList.get(i).asList()->get(1).asList()->get(0).toString());
yarp::os::Time::delay(2);
} //else { //another action
//}
}
bOutput.addString("ack");
return bOutput;
}
示例3: getSensorsData
bool SpringyFinger::getSensorsData(Value &data) const
{
map<string,Sensor*>::const_iterator In_0=sensors.find("In_0");
map<string,Sensor*>::const_iterator Out_0=sensors.find("Out_0");
map<string,Sensor*>::const_iterator Out_1=sensors.find("Out_1");
map<string,Sensor*>::const_iterator Out_2=sensors.find("Out_2");
bool ok=true;
ok&=In_0!=sensors.end();
ok&=Out_0!=sensors.end();
ok&=Out_1!=sensors.end();
if (lssvm.getCoDomainSize()>2)
ok&=Out_2!=sensors.end();
if (!ok)
return false;
Value val_in, val_out[3];
In_0->second->getOutput(val_in);
Out_0->second->getOutput(val_out[0]);
Out_1->second->getOutput(val_out[1]);
Vector in(lssvm.getDomainSize());
in[0]=val_in.asDouble();
Vector out(lssvm.getCoDomainSize());
out[0]=val_out[0].asDouble();
out[1]=val_out[1].asDouble();
if (lssvm.getCoDomainSize()>2)
{
Out_2->second->getOutput(val_out[2]);
out[2]=val_out[2].asDouble();
}
Property prop;
Bottle b;
b.addList().read(in);
prop.put("in",b.get(0));
b.addList().read(out);
prop.put("out",b.get(1));
b.addList().read(prop);
data=b.get(2);
return true;
}
示例4: ncmdList
Bottle NameServer::ncmdList(int argc, char *argv[]) {
Bottle response;
ConstString prefix = "";
if (argc==1) {
prefix = STR(argv[0]);
}
response.addString("ports");
for (PLATFORM_MAP(ConstString,NameRecord)::iterator it = nameMap.begin(); it!=nameMap.end(); it++) {
NameRecord& rec = PLATFORM_MAP_ITERATOR_SECOND(it);
ConstString iname = rec.getAddress().getRegName();
if (iname.find(prefix)==0) {
if (iname==prefix || iname[prefix.length()]=='/' ||
prefix[prefix.length()-1]=='/') {
if (rec.getAddress().isValid()) {
response.addList() = botify(rec.getAddress());
}
}
}
}
return response;
}
示例5: ncmdList
Bottle NameServer::ncmdList(int argc, char *argv[]) {
Bottle response;
std::string prefix;
if (argc==1) {
prefix = STR(argv[0]);
}
response.addString("ports");
for (auto& it : nameMap) {
NameRecord& rec = it.second;
std::string iname = rec.getAddress().getRegName();
if (iname.find(prefix)==0) {
if (iname==prefix || iname[prefix.length()]=='/' ||
prefix[prefix.length()-1]=='/') {
if (rec.getAddress().isValid()) {
response.addList() = botify(rec.getAddress());
}
}
}
}
return response;
}
示例6: getOutput
bool SpringyFingersModel::getOutput(Value &out) const
{
if (configured)
{
Value val[5];
fingers[0].getOutput(val[0]);
fingers[1].getOutput(val[1]);
fingers[2].getOutput(val[2]);
fingers[3].getOutput(val[3]);
fingers[4].getOutput(val[4]);
Bottle bOut; Bottle &ins=bOut.addList();
ins.addDouble(val[0].asDouble());
ins.addDouble(val[1].asDouble());
ins.addDouble(val[2].asDouble());
ins.addDouble(val[3].asDouble());
ins.addDouble(val[4].asDouble());
out.fromString(bOut.toString().c_str());
return true;
}
else
return false;
}
示例7: primitiveCommand
Bottle learnPrimitive::primitiveCommand(string sActionName, string sArg){
Bottle bOutput;
//1. check if primitive is known
// vPrimitiveActionBottle =
// open (hand) ( (unfold thumb) (unfold index) (unfold middle) (unfold ring) )
// close (hand) ( (fold thumb) (fold index) (fold middle) (fold ring) )
// b.get(1) b.get(2) b.get(3)
// name arg list of proto-action
Bottle bProtoActionList; //primitive only composed by proto-action
for(std::vector<yarp::os::Bottle>::iterator it = vPrimitiveActionBottle.begin(); it < vPrimitiveActionBottle.end(); it++){
string currentName = it->get(0).toString();
if(currentName == sActionName){
yInfo() << "found " << currentName << "as a known primitive";
string currentArg = it->get(1).toString();
if(currentArg == sArg){
yInfo() << "and we have a corresponding argument " << currentArg ;
for(int i = 0; i < it->get(2).asList()->size(); i++){
bProtoActionList.addList() = *it->get(2).asList()->get(i).asList() ;
}
break;
} else {
yInfo() << " BUT argument " << currentArg << " does NOT match" ;
}
}
}
if (bProtoActionList.size() == 0){
yError() << " error in learnPrimitive::primitiveCommand | action '" << sActionName << " " << sArg << "' is NOT known";
bOutput.addString("error");
bOutput.addString("action is NOT known");
return bOutput ;
}
yInfo() << "Actions to do : " << bProtoActionList.toString() ;
for(int i = 0; i < bProtoActionList.size(); i++){
yInfo() << "action #" << i << " : "<< bProtoActionList.get(i).asList()->get(0).toString() << " the " << bProtoActionList.get(i).asList()->get(1).asList()->get(0).toString() ;
bOutput.addList() = protoCommand(bProtoActionList.get(i).asList()->get(0).toString(), bProtoActionList.get(i).asList()->get(1).asList()->get(0).toString());
}
bOutput.addString("ack");
return bOutput;
}
示例8: getBusInfo
void getBusInfo(NodeArgs& na)
{
unsigned int opaque_id = 1;
ROSReport report;
Value v;
Bottle* connections = v.asList();
mutex.lock();
for (std::multimap<std::string, NodeItem>::iterator it = by_part_name.begin(); it != by_part_name.end(); ++it) {
NodeItem& item = it->second;
if (!(item.isSubscriber() || item.isPublisher())) {
continue;
}
item.update();
item.contactable->getReport(report);
}
mutex.unlock();
for (std::multimap<std::string, std::string>::const_iterator it = report.outgoingURIs.begin(); it != report.outgoingURIs.end(); ++it) {
Bottle& lst = connections->addList();
lst.addInt32(opaque_id); // connectionId
lst.addString(it->second);
lst.addString("o");
lst.addString("TCPROS");
NestedContact nc(it->first);
lst.addString(toRosName(nc.getNestedName()));
opaque_id++;
}
for (std::multimap<std::string, std::string>::const_iterator it = report.incomingURIs.begin(); it != report.incomingURIs.end(); ++it) {
Bottle& lst = connections->addList();
lst.addInt32(opaque_id); // connectionId
lst.addString(it->second);
lst.addString("i");
lst.addString("TCPROS");
NestedContact nc(it->first);
lst.addString(toRosName(nc.getNestedName()));
opaque_id++;
}
if (connections->size() == 0) {
connections->addList(); // add empty list
}
na.reply = v;
na.success();
}
示例9: addVectorToOption
void helperPID::addVectorToOption(Bottle &option, const char *key, const Vector &val)
{
Bottle &bKey=option.addList();
bKey.addString(key);
Bottle &bKeyContent=bKey.addList();
for (size_t i=0; i<val.length(); i++)
bKeyContent.addDouble(val[i]);
}
示例10:
void ff2LayNN::setItem(Property &options, const string &tag, const Vector &item) const
{
Bottle b; Bottle &v=b.addList();
for (size_t i=0; i<item.length(); i++)
v.addDouble(item[i]);
options.put(tag.c_str(),b.get(0));
}
示例11: asBottle
Bottle Adjective::asBottle()
{
//Get the Object bottle
Bottle b = this->Entity::asBottle();
Bottle bSub;
bSub.addString("qualityType");
bSub.addString(m_quality.c_str());
b.addList() = bSub;
return b;
}
示例12: toString
ConstString toString() {
Bottle bot;
for (PLATFORM_MAP(String,PropertyItem)::iterator
it = data.begin(); it!=data.end(); it++) {
PropertyItem& rec = PLATFORM_MAP_ITERATOR_SECOND(it);
Bottle& sub = bot.addList();
sub.copy(rec.bot);
}
return bot.toString();
}
示例13: setStraightness
void setStraightness(const double straightness)
{
ICartesianControl *icart;
action->getCartesianIF(icart);
Bottle options;
Bottle &straightOpt=options.addList();
straightOpt.addString("straightness");
straightOpt.addDouble(straightness);
icart->tweakSet(options);
}
示例14: getPidOptions
void Localizer::getPidOptions(Bottle &options)
{
mutex.lock();
pid->getOptions(options);
Bottle &bDominantEye=options.addList();
bDominantEye.addString("dominantEye");
bDominantEye.addString(dominantEye.c_str());
mutex.unlock();
}
示例15: toProperty
bool LSSVMCalibrator::toProperty(Property &info) const
{
Bottle data;
Bottle &values=data.addList();
values.addString(impl->toString().c_str());
info.clear();
info.put("type",type.c_str());
info.put("calibration_data",data.get(0));
return Calibrator::toProperty(info);
}