Skip to content

Commit

Permalink
Refactored due to upgrade to YARP-3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
pattacini committed Nov 21, 2021
1 parent a956df1 commit 07ca7fa
Show file tree
Hide file tree
Showing 176 changed files with 3,731 additions and 3,731 deletions.
32 changes: 16 additions & 16 deletions src/core/emotionInterface/emotionInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,28 @@ class iCub::contrib::IEmotionInterface

};

constexpr yarp::conf::vocab32_t EMOTION_VOCAB_SET = yarp::os::createVocab('s','e','t');
constexpr yarp::conf::vocab32_t EMOTION_VOCAB_GET = yarp::os::createVocab('g','e','t');
constexpr yarp::conf::vocab32_t EMOTION_VOCAB_IS = yarp::os::createVocab('i','s');
constexpr yarp::conf::vocab32_t EMOTION_VOCAB_FAILED = yarp::os::createVocab('f','a','i','l');
constexpr yarp::conf::vocab32_t EMOTION_VOCAB_OK = yarp::os::createVocab('o','k');
constexpr yarp::conf::vocab32_t EMOTION_VOCAB_HELP = yarp::os::createVocab('h','e','l','p');
constexpr yarp::conf::vocab32_t EMOTION_VOCAB_SET = yarp::os::createVocab32('s','e','t');
constexpr yarp::conf::vocab32_t EMOTION_VOCAB_GET = yarp::os::createVocab32('g','e','t');
constexpr yarp::conf::vocab32_t EMOTION_VOCAB_IS = yarp::os::createVocab32('i','s');
constexpr yarp::conf::vocab32_t EMOTION_VOCAB_FAILED = yarp::os::createVocab32('f','a','i','l');
constexpr yarp::conf::vocab32_t EMOTION_VOCAB_OK = yarp::os::createVocab32('o','k');
constexpr yarp::conf::vocab32_t EMOTION_VOCAB_HELP = yarp::os::createVocab32('h','e','l','p');

constexpr yarp::conf::vocab32_t EMOTION_VOCAB_MOUTH = yarp::os::createVocab('m','o','u');
constexpr yarp::conf::vocab32_t EMOTION_VOCAB_EYELIDS = yarp::os::createVocab('e','l','i');
constexpr yarp::conf::vocab32_t EMOTION_VOCAB_LEFTEYEBROW = yarp::os::createVocab('l','e','b');
constexpr yarp::conf::vocab32_t EMOTION_VOCAB_RIGHTEYEBROW = yarp::os::createVocab('r','e','b');
constexpr yarp::conf::vocab32_t EMOTION_VOCAB_ALL = yarp::os::createVocab('a','l','l');
constexpr yarp::conf::vocab32_t EMOTION_VOCAB_RAW = yarp::os::createVocab('r','a','w');
constexpr yarp::conf::vocab32_t EMOTION_VOCAB_COLOR = yarp::os::createVocab('c','o','l');
constexpr yarp::conf::vocab32_t EMOTION_VOCAB_BRIG = yarp::os::createVocab('b','r','i','g');
constexpr yarp::conf::vocab32_t EMOTION_VOCAB_MASK = yarp::os::createVocab('m','a','s','k');
constexpr yarp::conf::vocab32_t EMOTION_VOCAB_MOUTH = yarp::os::createVocab32('m','o','u');
constexpr yarp::conf::vocab32_t EMOTION_VOCAB_EYELIDS = yarp::os::createVocab32('e','l','i');
constexpr yarp::conf::vocab32_t EMOTION_VOCAB_LEFTEYEBROW = yarp::os::createVocab32('l','e','b');
constexpr yarp::conf::vocab32_t EMOTION_VOCAB_RIGHTEYEBROW = yarp::os::createVocab32('r','e','b');
constexpr yarp::conf::vocab32_t EMOTION_VOCAB_ALL = yarp::os::createVocab32('a','l','l');
constexpr yarp::conf::vocab32_t EMOTION_VOCAB_RAW = yarp::os::createVocab32('r','a','w');
constexpr yarp::conf::vocab32_t EMOTION_VOCAB_COLOR = yarp::os::createVocab32('c','o','l');
constexpr yarp::conf::vocab32_t EMOTION_VOCAB_BRIG = yarp::os::createVocab32('b','r','i','g');
constexpr yarp::conf::vocab32_t EMOTION_VOCAB_MASK = yarp::os::createVocab32('m','a','s','k');



inline bool EMOTION_CHECK_FAIL(bool ok, yarp::os::Bottle& response) {
if (ok) {
if (response.get(0).isVocab() && response.get(0).asVocab() == EMOTION_VOCAB_FAILED) {
if (response.get(0).isVocab32() && response.get(0).asVocab32() == EMOTION_VOCAB_FAILED) {
return false;
}
}
Expand Down
32 changes: 16 additions & 16 deletions src/core/emotionInterface/emotionInterfaceModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ std::bitset<32> populateBitset(const yarp::os::Bottle& bt)
{
std::bitset<32> bitSet{};
for(size_t i=0; i<bt.size(); i++){
bitSet.set(bt.get(i).asInt());
bitSet.set(bt.get(i).asInt32());
}
return bitSet;
}
Expand Down Expand Up @@ -74,7 +74,7 @@ void printHelp (yarp::os::Bottle& reply) {
"\tm_name stands for mask name and the availble bitmasks can be consulted/added in faceExpressions/emotions_rfe.ini\n";

reply.clear();
reply.addVocab(Vocab::encode("many"));
reply.addVocab32("many");
reply.addString(helpMessage.c_str());
}

Expand All @@ -95,12 +95,12 @@ bool EmotionInterfaceModule::configure(ResourceFinder& config){
return false;
}

_highlevelemotions = config.check("emotions", Value(0), "Number of predefined facial expressions").asInt();
_numberOfColors = config.check("colors", Value(0), "Number of predefined colors").asInt();
_eyebrowmaskemotions = config.check("bitmask_eyebrow_emotions", Value(0), "Number of predefined bitmask eyebrow expressions").asInt();
_mouthmaskemotions = config.check("bitmask_mouth_emotions", Value(0), "Number of predefined bitmask eyebrow expressions").asInt();
_highlevelemotions = config.check("emotions", Value(0), "Number of predefined facial expressions").asInt32();
_numberOfColors = config.check("colors", Value(0), "Number of predefined colors").asInt32();
_eyebrowmaskemotions = config.check("bitmask_eyebrow_emotions", Value(0), "Number of predefined bitmask eyebrow expressions").asInt32();
_mouthmaskemotions = config.check("bitmask_mouth_emotions", Value(0), "Number of predefined bitmask eyebrow expressions").asInt32();
_auto = config.check("auto");
_period = config.check("period", Value(10.0), "Period for expression switching in auto mode").asDouble();
_period = config.check("period", Value(10.0), "Period for expression switching in auto mode").asFloat64();
if(_highlevelemotions == 0)
{
_emotion_table = nullptr;
Expand Down Expand Up @@ -354,14 +354,14 @@ bool EmotionInterfaceModule::respond(const Bottle &command,Bottle &reply){
bool ok = false;
bool rec = false; // is the command recognized?

switch (command.get(0).asVocab()) {
switch (command.get(0).asVocab32()) {
case EMOTION_VOCAB_HELP:
printHelp(reply);
return true;
case EMOTION_VOCAB_SET:
rec = true;
{
switch(command.get(1).asVocab()) {
switch(command.get(1).asVocab32()) {
case EMOTION_VOCAB_MOUTH:{
ok = setMouth(command.get(2).toString());
break;
Expand Down Expand Up @@ -407,24 +407,24 @@ bool EmotionInterfaceModule::respond(const Bottle &command,Bottle &reply){
case EMOTION_VOCAB_GET:
rec = true;
/*{
reply.addVocab(VOCAB_IS);
reply.addVocab32(VOCAB_IS);
reply.add(command.get(1));
switch(command.get(1).asVocab()) {
switch(command.get(1).asVocab32()) {
case EGOSPHERE_VOCAB_THRESHOLD_SALIENCE:{
float thr = getThresholdSalience();
reply.addDouble((double)thr);
reply.addFloat64((double)thr);
ok = true;
break;
}
case EGOSPHERE_VOCAB_OUTPUT:{
int v = (int)getOutput();
reply.addInt(v);
reply.addInt32(v);
ok = true;
break;
}
case EGOSPHERE_VOCAB_SALIENCE_DECAY:{
double rate = getSalienceDecay();
reply.addDouble(rate);
reply.addFloat64(rate);
ok = true;
break;
}
Expand All @@ -444,10 +444,10 @@ bool EmotionInterfaceModule::respond(const Bottle &command,Bottle &reply){

if (!ok) {
reply.clear();
reply.addVocab(EMOTION_VOCAB_FAILED);
reply.addVocab32(EMOTION_VOCAB_FAILED);
}
else
reply.addVocab(EMOTION_VOCAB_OK);
reply.addVocab32(EMOTION_VOCAB_OK);

return ok;
}
Expand Down
42 changes: 21 additions & 21 deletions src/libraries/actionPrimitives/src/actionPrimitives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ bool ActionPrimitives::handleTorsoDOF(Property &opt, const string &key)
{
Bottle info;
cartCtrl->getInfo(info);
double hwver=info.find("arm_version").asDouble();
double hwver=info.find("arm_version").asFloat64();
map<string,int> remap{{ACTIONPRIM_TORSO_PITCH,0},{ACTIONPRIM_TORSO_ROLL,1},{ACTIONPRIM_TORSO_YAW,2}};
if (hwver>=3.0)
{
Expand All @@ -432,8 +432,8 @@ bool ActionPrimitives::handleTorsoDOF(Property &opt, const string &key)

cartCtrl->getLimits(j,&min,&max);

min=opt.check(minKey,Value(min)).asDouble();
max=opt.check(maxKey,Value(max)).asDouble();
min=opt.check(minKey,Value(min)).asFloat64();
max=opt.check(maxKey,Value(max)).asFloat64();

cartCtrl->setLimits(j,min,max);
cartCtrl->getLimits(j,&min,&max);
Expand Down Expand Up @@ -485,7 +485,7 @@ bool ActionPrimitives::configHandSeq(Property &opt)
return false;
}

int numSequences=bGeneral.find("numSequences").asInt();
int numSequences=bGeneral.find("numSequences").asInt32();

// SEQUENCE groups
for (int i=0; i<numSequences; i++)
Expand Down Expand Up @@ -596,12 +596,12 @@ bool ActionPrimitives::open(Property &opt)
robot=opt.check("robot",Value("icub")).asString();
local=opt.find("local").asString();
part=opt.check("part",Value(ACTIONPRIM_DEFAULT_PART)).asString();
default_exec_time=opt.check("default_exec_time",Value(ACTIONPRIM_DEFAULT_EXECTIME)).asDouble();
default_exec_time=opt.check("default_exec_time",Value(ACTIONPRIM_DEFAULT_EXECTIME)).asFloat64();
tracking_mode=opt.check("tracking_mode",Value(ACTIONPRIM_DEFAULT_TRACKINGMODE)).asString()=="on"?true:false;
verbose=opt.check("verbosity",Value(ACTIONPRIM_DEFAULT_VERBOSITY)).asString()=="on"?true:false;

int period=opt.check("thread_period",Value(ACTIONPRIM_DEFAULT_PER)).asInt();
double reach_tol=opt.check("reach_tol",Value(ACTIONPRIM_DEFAULT_REACHTOL)).asDouble();
int period=opt.check("thread_period",Value(ACTIONPRIM_DEFAULT_PER)).asInt32();
double reach_tol=opt.check("reach_tol",Value(ACTIONPRIM_DEFAULT_REACHTOL)).asFloat64();

// create the model for grasp detection (if any)
if (!configGraspModel(opt))
Expand Down Expand Up @@ -763,7 +763,7 @@ bool ActionPrimitives::isHandSeqEnded()
// span over fingers
for (int fng=0; fng<5; fng++)
{
double val=pB->get(fng).asDouble();
double val=pB->get(fng).asFloat64();
double thres=curGraspDetectionThres[fng];

// detect contact on the finger
Expand Down Expand Up @@ -1562,7 +1562,7 @@ bool ActionPrimitives::addHandSequence(const string &handSeqKey, const Bottle &s
return false;
}

int numWayPoints=sequence.find("numWayPoints").asInt();
int numWayPoints=sequence.find("numWayPoints").asInt32();
bool ret=false;

for (int j=0; j<numWayPoints; j++)
Expand Down Expand Up @@ -1611,27 +1611,27 @@ bool ActionPrimitives::addHandSequence(const string &handSeqKey, const Bottle &s
Vector poss(bPoss->size());

for (size_t k=0; k<poss.length(); k++)
poss[k]=bPoss->get(k).asDouble();
poss[k]=bPoss->get(k).asFloat64();

Bottle *bVels=bWP.find("vels").asList();
Vector vels(bVels->size());

for (size_t k=0; k<vels.length(); k++)
vels[k]=bVels->get(k).asDouble();
vels[k]=bVels->get(k).asFloat64();

Bottle *bTols=bWP.find("tols").asList();
Vector tols(bTols->size());

for (size_t k=0; k<tols.length(); k++)
tols[k]=bTols->get(k).asDouble();
tols[k]=bTols->get(k).asFloat64();

Bottle *bThres=bWP.find("thres").asList();
Vector thres(bThres->size());

for (size_t k=0; k<thres.length(); k++)
thres[k]=bThres->get(k).asDouble();
thres[k]=bThres->get(k).asFloat64();

double tmo=bWP.find("tmo").asDouble();
double tmo=bWP.find("tmo").asFloat64();

if (addHandSeqWP(handSeqKey,poss,vels,tols,thres,tmo))
ret=true; // at least one WP has been added
Expand Down Expand Up @@ -1695,7 +1695,7 @@ bool ActionPrimitives::getHandSequence(const string &handSeqKey, Bottle &sequenc
// numWayPoints part
Bottle &bNum=sequence.addList();
bNum.addString("numWayPoints");
bNum.addInt((int)handWP.size());
bNum.addInt32((int)handWP.size());

// wayPoints parts
for (unsigned int i=0; i<handWP.size(); i++)
Expand All @@ -1711,33 +1711,33 @@ bool ActionPrimitives::getHandSequence(const string &handSeqKey, Bottle &sequenc
bPoss.addString("poss");
Bottle &bPossVects=bPoss.addList();
for (size_t j=0; j<handWP[i].poss.length(); j++)
bPossVects.addDouble(handWP[i].poss[j]);
bPossVects.addFloat64(handWP[i].poss[j]);

// vels part
Bottle &bVels=bWP.addList();
bVels.addString("vels");
Bottle &bVelsVects=bVels.addList();
for (size_t j=0; j<handWP[i].vels.length(); j++)
bVelsVects.addDouble(handWP[i].vels[j]);
bVelsVects.addFloat64(handWP[i].vels[j]);

// tols part
Bottle &bTols=bWP.addList();
bTols.addString("tols");
Bottle &bTolsVects=bTols.addList();
for (size_t j=0; j<handWP[i].tols.length(); j++)
bTolsVects.addDouble(handWP[i].tols[j]);
bTolsVects.addFloat64(handWP[i].tols[j]);

// thres part
Bottle &bThres=bWP.addList();
bThres.addString("thres");
Bottle &bThresVects=bThres.addList();
for (size_t j=0; j<handWP[i].thres.length(); j++)
bThresVects.addDouble(handWP[i].thres[j]);
bThresVects.addFloat64(handWP[i].thres[j]);

// tmo part
Bottle &bTmo=bWP.addList();
bTmo.addString("tmo");
bTmo.addDouble(handWP[i].tmo);
bTmo.addFloat64(handWP[i].tmo);
}

return true;
Expand Down Expand Up @@ -2251,7 +2251,7 @@ bool ActionPrimitivesLayer2::open(Property &opt)

if (configured)
{
ext_force_thres=opt.check("ext_force_thres",Value(std::numeric_limits<double>::max())).asDouble();
ext_force_thres=opt.check("ext_force_thres",Value(std::numeric_limits<double>::max())).asFloat64();
string wbdynStemName=opt.check("wbdyn_stem_name",Value(ACTIONPRIM_DEFAULT_WBDYN_STEMNAME)).asString();
string wbdynPortName=opt.check("wbdyn_port_name",Value(ACTIONPRIM_DEFAULT_WBDYN_PORTNAME)).asString();

Expand Down
4 changes: 2 additions & 2 deletions src/libraries/ctrlLib/src/clustering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ namespace iCub {
map<size_t,set<size_t>> DBSCAN::cluster(const vector<Vector> &data,
const Property &options)
{
double epsilon=options.check("epsilon",Value(1.0)).asDouble();
size_t minpts=(size_t)options.check("minpts",Value(2)).asInt();
double epsilon=options.check("epsilon",Value(1.0)).asFloat64();
size_t minpts=(size_t)options.check("minpts",Value(2)).asInt32();
shared_ptr<dbscan::Data_t> augData(new dbscan::Data_t(data,epsilon,minpts));

size_t id=0;
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/ctrlLib/src/functionEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ bool WaveletEncoder::setEncoderOptions(const Property &options)
{
if (options.check("resolution"))
{
double R=options.find("resolution").asDouble();
double R=options.find("resolution").asFloat64();

// apply saturation
resolution=std::max(0.0,std::min(R,double(WAVELET_LUP_SIZE-1)));
Expand Down
10 changes: 5 additions & 5 deletions src/libraries/ctrlLib/src/minJerkCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,22 +213,22 @@ void minJerkVelCtrlForNonIdealPlant::setPlantParameters(const Property &paramete
for (int i=0; i<len; i++)
{
ostringstream entry;
entry<<entryTag<<"_"<<(ordering.size()==0?i:ordering.get(i).asInt());
entry<<entryTag<<"_"<<(ordering.size()==0?i:ordering.get(i).asInt32());
if (parameters.check(entry.str()))
{
if (Bottle *options=parameters.find(entry.str()).asList())
{
if (options->check("Kp"))
Kp[i]=options->find("Kp").asDouble();
Kp[i]=options->find("Kp").asFloat64();

if (options->check("Tz"))
Tz[i]=options->find("Tz").asDouble();
Tz[i]=options->find("Tz").asFloat64();

if (options->check("Tw"))
Tw[i]=options->find("Tw").asDouble();
Tw[i]=options->find("Tw").asFloat64();

if (options->check("Zeta"))
Zeta[i]=options->find("Zeta").asDouble();
Zeta[i]=options->find("Zeta").asFloat64();
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/libraries/ctrlLib/src/neuralNetworks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void ff2LayNN::setItem(Property &options, const string &tag, const Vector &item)
{
Bottle b; Bottle &v=b.addList();
for (size_t i=0; i<item.length(); i++)
v.addDouble(item[i]);
v.addFloat64(item[i]);

options.put(tag,b.get(0));
}
Expand All @@ -61,7 +61,7 @@ bool ff2LayNN::getItem(const Property &options, const string &tag, Vector &item)
{
item.resize(b->size());
for (size_t i=0; i<item.length(); i++)
item[i]=b->get(i).asDouble();
item[i]=b->get(i).asFloat64();

return true;
}
Expand Down Expand Up @@ -116,7 +116,7 @@ bool ff2LayNN::configure(const Property &options)
!options.check("numOutputNodes"))
return false;

int numHiddenNodes=options.find("numHiddenNodes").asInt();
int numHiddenNodes=options.find("numHiddenNodes").asInt32();
for (int i=0; i<numHiddenNodes; i++)
{
ostringstream tag;
Expand All @@ -132,7 +132,7 @@ bool ff2LayNN::configure(const Property &options)
if (!getItem(options,"b1",b1))
return false;

int numOutputNodes=options.find("numOutputNodes").asInt();
int numOutputNodes=options.find("numOutputNodes").asInt32();
for (int i=0; i<numOutputNodes; i++)
{
ostringstream tag;
Expand All @@ -148,7 +148,7 @@ bool ff2LayNN::configure(const Property &options)
if (!getItem(options,"b2",b2))
return false;

int numInputNodes=options.find("numInputNodes").asInt();
int numInputNodes=options.find("numInputNodes").asInt32();
for (int i=0; i<numInputNodes; i++)
{
ostringstream tagX, tagY;
Expand Down
4 changes: 2 additions & 2 deletions src/libraries/ctrlLib/src/outliersDetection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ set<size_t> ModifiedThompsonTau::detect(const Vector &data, const Property &opti

if (options.check("mean") && options.check("std"))
{
mean=options.find("mean").asDouble();
stdev=options.find("std").asDouble();
mean=options.find("mean").asFloat64();
stdev=options.find("std").asFloat64();
}
else if (N>0)
{
Expand Down
Loading

0 comments on commit 07ca7fa

Please sign in to comment.