25#include <yarp/math/Math.h> 
   28#define GAZECTRL_CLIENT_VER     "2.0" 
   29#define GAZECTRL_DEFAULT_TMO    0.1      
   30#define GAZECTRL_ACK            Vocab32::encode("ack") 
   31#define GAZECTRL_NACK           Vocab32::encode("nack") 
   34using namespace yarp::os;
 
   36using namespace yarp::sig;
 
   37using namespace yarp::math;
 
   92    string remote, local, carrier;
 
   94    if (config.check(
"remote"))
 
   95        remote=config.find(
"remote").asString();
 
   99    if (config.check(
"local"))
 
  100        local=config.find(
"local").asString();
 
  105    carrier=config.check(
"carrier",Value(
"udp")).asString();
 
  107    if (config.check(
"timeout"))
 
  108        timeout=config.find(
"timeout").asFloat64();
 
  121    ok&=Network::connect(
portRpc.getName(),remote+
"/rpc");
 
  126        if (info.check(
"server_version"))
 
  128            string server_version=info.find(
"server_version").asString();
 
  131                yError(
"version mismatch => server(%s) != client(%s); please update accordingly",
 
  138            yWarning(
"unable to retrieve server version; please update the server");
 
  142        yError(
"unable to connect to the server rpc port!");
 
  147    ok&=Network::connect(
portCmdFp.getName(),remote+
"/xd:i",carrier);
 
  148    ok&=Network::connect(
portCmdAng.getName(),remote+
"/angles:i",carrier);
 
  149    ok&=Network::connect(
portCmdMono.getName(),remote+
"/mono:i",carrier);
 
  150    ok&=Network::connect(
portCmdStereo.getName(),remote+
"/stereo:i",carrier);
 
  151    ok&=Network::connect(remote+
"/x:o",
portStateFp.getName(),carrier);
 
  152    ok&=Network::connect(remote+
"/angles:o",
portStateAng.getName(),carrier);
 
  154    ok&=Network::connect(remote+
"/events:o",
portEvents.getName(),carrier);
 
 
  202    Bottle command, reply;
 
  203    command.addString(
"set");
 
  204    command.addString(
"track");
 
  205    command.addInt32((
int)
f);
 
  207    if (!
portRpc.write(command,reply))
 
  209        yError(
"unable to get reply from server!");
 
 
  223    Bottle command, reply;
 
  224    command.addString(
"get");
 
  225    command.addString(
"track");
 
  227    if (!
portRpc.write(command,reply))
 
  229        yError(
"unable to get reply from server!");
 
  233    if ((reply.get(0).asVocab32()==
GAZECTRL_ACK) && (reply.size()>1))
 
  235        *
f=(reply.get(1).asInt32()>0);
 
 
  249    Bottle command, reply;
 
  250    command.addString(
"set");
 
  251    command.addString(
"stab");
 
  252    command.addInt32((
int)
f);
 
  254    if (!
portRpc.write(command,reply))
 
  256        yError(
"unable to get reply from server!");
 
 
  270    Bottle command, reply;
 
  271    command.addString(
"get");
 
  272    command.addString(
"stab");
 
  274    if (!
portRpc.write(command,reply))
 
  276        yError(
"unable to get reply from server!");
 
  280    if ((reply.get(0).asVocab32()==
GAZECTRL_ACK) && (reply.size()>1))
 
  282        *
f=(reply.get(1).asInt32()>0);
 
 
  296    double now=Time::now();
 
 
  318    double now=Time::now();
 
 
  343    cmd.addFloat64(
fp[0]);
 
  344    cmd.addFloat64(
fp[1]);
 
  345    cmd.addFloat64(
fp[2]);
 
 
  361    cmd.addString(
"abs");
 
  362    cmd.addFloat64(ang[0]);
 
  363    cmd.addFloat64(ang[1]);
 
  364    cmd.addFloat64(ang[2]);
 
 
  380    cmd.addString(
"rel");
 
  381    cmd.addFloat64(ang[0]);
 
  382    cmd.addFloat64(ang[1]);
 
  383    cmd.addFloat64(ang[2]);
 
 
  400    cmd.addString((camSel==0)?
"left":
"right");
 
  401    cmd.addFloat64(px[0]);
 
  402    cmd.addFloat64(px[1]);
 
 
  421    cmd.addString((camSel==0)?
"left":
"right");
 
  422    cmd.addFloat64(px[0]);
 
  423    cmd.addFloat64(px[1]);
 
  424    cmd.addString(
"ver");
 
 
  435    if (!
connected || (pxl.length()<2) || (pxr.length()<2))
 
  441    cmd.addFloat64(pxl[0]);
 
  442    cmd.addFloat64(pxl[1]);
 
  443    cmd.addFloat64(pxr[0]);
 
  444    cmd.addFloat64(pxr[1]);
 
 
  457    Bottle command, reply;
 
  458    command.addString(
"look");
 
  459    command.addString(
"3D");
 
  460    Bottle &payLoad=command.addList();
 
  461    payLoad.addFloat64(
fp[0]);
 
  462    payLoad.addFloat64(
fp[1]);
 
  463    payLoad.addFloat64(
fp[2]);
 
  465    if (!
portRpc.write(command,reply))
 
  467        yError(
"unable to get reply from server!");
 
 
  481    Bottle command, reply;
 
  482    command.addString(
"look");
 
  483    command.addString(
"ang");
 
  484    Bottle &payLoad=command.addList();
 
  485    payLoad.addString(
"abs");
 
  486    for (
size_t i=0; i<ang.length(); i++)
 
  487        payLoad.addFloat64(ang[i]);
 
  489    if (!
portRpc.write(command,reply))
 
  491        yError(
"unable to get reply from server!");
 
 
  505    Bottle command, reply;
 
  506    command.addString(
"look");
 
  507    command.addString(
"ang");
 
  508    Bottle &payLoad=command.addList();
 
  509    payLoad.addString(
"rel");
 
  510    for (
size_t i=0; i<ang.length(); i++)
 
  511        payLoad.addFloat64(ang[i]);
 
  513    if (!
portRpc.write(command,reply))
 
  515        yError(
"unable to get reply from server!");
 
 
  531    Bottle command, reply;
 
  532    command.addString(
"look");
 
  533    command.addString(
"mono");
 
  534    Bottle &payLoad=command.addList();
 
  535    payLoad.addString((camSel==0)?
"left":
"right");
 
  536    payLoad.addFloat64(px[0]);
 
  537    payLoad.addFloat64(px[1]);
 
  538    payLoad.addFloat64(
z);
 
  540    if (!
portRpc.write(command,reply))
 
  542        yError(
"unable to get reply from server!");
 
 
  558    Bottle command, reply;
 
  559    command.addString(
"look");
 
  560    command.addString(
"mono");
 
  561    Bottle &payLoad=command.addList();
 
  562    payLoad.addString((camSel==0)?
"left":
"right");
 
  563    payLoad.addFloat64(px[0]);
 
  564    payLoad.addFloat64(px[1]);
 
  565    payLoad.addString(
"ver");
 
  566    payLoad.addFloat64(ver);
 
  568    if (!
portRpc.write(command,reply))
 
  570        yError(
"unable to get reply from server!");
 
 
  582    if (!
connected || (pxl.length()<2) || (pxr.length()<2))
 
  585    Bottle command, reply;
 
  586    command.addString(
"look");
 
  587    command.addString(
"stereo");
 
  588    Bottle &payLoad=command.addList();
 
  589    payLoad.addFloat64(pxl[0]);
 
  590    payLoad.addFloat64(pxl[1]);
 
  591    payLoad.addFloat64(pxr[0]);
 
  592    payLoad.addFloat64(pxr[1]);    
 
  594    if (!
portRpc.write(command,reply))
 
  596        yError(
"unable to get reply from server!");
 
 
  610    Bottle command, reply;
 
  611    command.addString(
"get");
 
  612    command.addString(
"Tneck");
 
  614    if (!
portRpc.write(command,reply))
 
  616        yError(
"unable to get reply from server!");
 
  620    if ((reply.get(0).asVocab32()==
GAZECTRL_ACK) && (reply.size()>1))
 
  622        *t=reply.get(1).asFloat64();
 
 
  636    Bottle command, reply;
 
  637    command.addString(
"get");
 
  638    command.addString(
"Teyes");
 
  640    if (!
portRpc.write(command,reply))
 
  642        yError(
"unable to get reply from server!");
 
  646    if ((reply.get(0).asVocab32()==
GAZECTRL_ACK) && (reply.size()>1))
 
  648        *t=reply.get(1).asFloat64();
 
 
  662    Bottle command, reply;
 
  663    command.addString(
"get");
 
  664    command.addString(
"vor");
 
  666    if (!
portRpc.write(command,reply))
 
  668        yError(
"unable to get reply from server!");
 
  672    if ((reply.get(0).asVocab32()==
GAZECTRL_ACK) && (reply.size()>1))
 
  674        *gain=reply.get(1).asFloat64();
 
 
  688    Bottle command, reply;
 
  689    command.addString(
"get");
 
  690    command.addString(
"ocr");
 
  692    if (!
portRpc.write(command,reply))
 
  694        yError(
"unable to get reply from server!");
 
  698    if ((reply.get(0).asVocab32()==
GAZECTRL_ACK) && (reply.size()>1))
 
  700        *gain=reply.get(1).asFloat64();
 
 
  714    Bottle command, reply;
 
  715    command.addString(
"get");
 
  716    command.addString(
"sacc");
 
  718    if (!
portRpc.write(command,reply))
 
  720        yError(
"unable to get reply from server!");
 
  724    if ((reply.get(0).asVocab32()==
GAZECTRL_ACK) && (reply.size()>1))
 
  726        *
f=(reply.get(1).asInt32()>0);
 
 
  740    Bottle command, reply;
 
  741    command.addString(
"get");
 
  742    command.addString(
"sinh");
 
  744    if (!
portRpc.write(command,reply))
 
  746        yError(
"unable to get reply from server!");
 
  750    if ((reply.get(0).asVocab32()==
GAZECTRL_ACK) && (reply.size()>1))
 
  752        *period=reply.get(1).asFloat64();
 
 
  766    Bottle command, reply;
 
  767    command.addString(
"get");
 
  768    command.addString(
"sact");
 
  770    if (!
portRpc.write(command,reply))
 
  772        yError(
"unable to get reply from server!");
 
  776    if ((reply.get(0).asVocab32()==
GAZECTRL_ACK) && (reply.size()>1))
 
  778        *angle=reply.get(1).asFloat64();
 
 
  793    Bottle command, reply;
 
  794    command.addString(
"get");
 
  795    command.addString(
"pose");
 
  796    command.addString(poseSel);
 
  798    if (!
portRpc.write(command,reply))
 
  800        yError(
"unable to get reply from server!");
 
  804    if ((reply.get(0).asVocab32()==
GAZECTRL_ACK) && (reply.size()>1))
 
  806        if (Bottle *bPose=reply.get(1).asList())
 
  808            if (bPose->size()>=7)
 
  811                o.resize(bPose->size()-
x.length());
 
  813                for (
size_t i=0; i<
x.length(); i++)
 
  814                    x[i]=bPose->get(i).asFloat64();
 
  816                for (
size_t i=0; i<o.length(); i++)
 
  817                    o[i]=bPose->get(
x.length()+i).asFloat64();
 
  819                if ((reply.size()>2) && (stamp!=NULL))
 
  821                    if (Bottle *bStamp=reply.get(2).asList())
 
  823                        Stamp tmpStamp(bStamp->get(0).asInt32(),
 
  824                                       bStamp->get(1).asFloat64());
 
 
  867    Bottle command, reply;
 
  868    command.addString(
"get");
 
  869    command.addString(
"2D");
 
  870    Bottle &bOpt=command.addList();
 
  871    bOpt.addString((camSel==0)?
"left":
"right");
 
  872    bOpt.addFloat64(
x[0]);
 
  873    bOpt.addFloat64(
x[1]);
 
  874    bOpt.addFloat64(
x[2]);
 
  876    if (!
portRpc.write(command,reply))
 
  878        yError(
"unable to get reply from server!");
 
  882    if ((reply.get(0).asVocab32()==
GAZECTRL_ACK) && (reply.size()>1))
 
  884        if (Bottle *bPixel=reply.get(1).asList())
 
  886            px.resize(bPixel->size());
 
  887            for (
size_t i=0; i<px.length(); i++)
 
  888                px[i]=bPixel->get(i).asFloat64();
 
 
  900                                      const double z, Vector &
x)
 
  905    Bottle command, reply;
 
  906    command.addString(
"get");
 
  907    command.addString(
"3D");
 
  908    command.addString(
"mono");
 
  909    Bottle &bOpt=command.addList();
 
  910    bOpt.addString((camSel==0)?
"left":
"right");
 
  911    bOpt.addFloat64(px[0]);
 
  912    bOpt.addFloat64(px[1]);
 
  915    if (!
portRpc.write(command,reply))
 
  917        yError(
"unable to get reply from server!");
 
  921    if ((reply.get(0).asVocab32()==
GAZECTRL_ACK) && (reply.size()>1))
 
  923        if (Bottle *bPoint=reply.get(1).asList())
 
  925            x.resize(bPoint->size());
 
  926            for (
size_t i=0; i<
x.length(); i++)
 
  927                x[i]=bPoint->get(i).asFloat64();
 
 
  939                                             const Vector &plane, Vector &
x)
 
  941    if (!
connected || (px.length()<2) || (plane.length()<4))
 
  944    Bottle command, reply;
 
  945    command.addString(
"get");
 
  946    command.addString(
"3D");
 
  947    command.addString(
"proj");
 
  948    Bottle &bOpt=command.addList();
 
  949    bOpt.addString((camSel==0)?
"left":
"right");
 
  950    bOpt.addFloat64(px[0]);
 
  951    bOpt.addFloat64(px[1]);
 
  952    bOpt.addFloat64(plane[0]);
 
  953    bOpt.addFloat64(plane[1]);
 
  954    bOpt.addFloat64(plane[2]);
 
  955    bOpt.addFloat64(plane[3]);
 
  957    if (!
portRpc.write(command,reply))
 
  959        yError(
"unable to get reply from server!");
 
  963    if ((reply.get(0).asVocab32()==
GAZECTRL_ACK) && (reply.size()>1))
 
  965        if (Bottle *bPoint=reply.get(1).asList())
 
  967            x.resize(bPoint->size());
 
  968            for (
size_t i=0; i<
x.length(); i++)
 
  969                x[i]=bPoint->get(i).asFloat64();
 
 
  986    Bottle command, reply;
 
  987    command.addString(
"get");
 
  988    command.addString(
"3D");
 
  989    command.addString(
"ang");
 
  990    Bottle &bOpt=command.addList();
 
  991    bOpt.addString((mode==0)?
"abs":
"rel");
 
  992    bOpt.addFloat64(ang[0]);
 
  993    bOpt.addFloat64(ang[1]);
 
  994    bOpt.addFloat64(ang[2]);
 
  996    if (!
portRpc.write(command,reply))
 
  998        yError(
"unable to get reply from server!");
 
 1002    if ((reply.get(0).asVocab32()==
GAZECTRL_ACK) && (reply.size()>1))
 
 1004        if (Bottle *bPoint=reply.get(1).asList())
 
 1006            x.resize(bPoint->size());
 
 1007            for (
size_t i=0; i<
x.length(); i++)
 
 1008                x[i]=bPoint->get(i).asFloat64();
 
 
 1024    Bottle command, reply;
 
 1025    command.addString(
"get");
 
 1026    command.addString(
"ang");
 
 1027    Bottle &bOpt=command.addList();
 
 1028    bOpt.addFloat64(
x[0]);
 
 1029    bOpt.addFloat64(
x[1]);
 
 1030    bOpt.addFloat64(
x[2]);
 
 1032    if (!
portRpc.write(command,reply))
 
 1034        yError(
"unable to get reply from server!");
 
 1038    if ((reply.get(0).asVocab32()==
GAZECTRL_ACK) && (reply.size()>1))
 
 1040        if (Bottle *bAng=reply.get(1).asList())
 
 1042            ang.resize(bAng->size());
 
 1043            for (
size_t i=0; i<ang.length(); i++)
 
 1044                ang[i]=bAng->get(i).asFloat64();
 
 
 1058    if (!
connected || ((pxl.length()<2) && (pxr.length()<2)))
 
 1061    Bottle command, reply;
 
 1062    command.addString(
"get");
 
 1063    command.addString(
"3D");
 
 1064    command.addString(
"stereo");
 
 1065    Bottle &bOpt=command.addList();
 
 1066    bOpt.addFloat64(pxl[0]);
 
 1067    bOpt.addFloat64(pxl[1]);
 
 1068    bOpt.addFloat64(pxr[0]);
 
 1069    bOpt.addFloat64(pxr[1]);
 
 1071    if (!
portRpc.write(command,reply))
 
 1073        yError(
"unable to get reply from server!");
 
 1077    if ((reply.get(0).asVocab32()==
GAZECTRL_ACK) && (reply.size()>1))
 
 1079        if (Bottle *bPoint=reply.get(1).asList())
 
 1081            x.resize(bPoint->size());
 
 1082            for (
size_t i=0; i<
x.length(); i++)
 
 1083                x[i]=bPoint->get(i).asFloat64();
 
 
 1099    Bottle command, reply;
 
 1100    command.addString(
"get");
 
 1101    command.addString(
"des");
 
 1103    if (!
portRpc.write(command,reply))
 
 1105        yError(
"unable to get reply from server!");
 
 1109    if ((reply.get(0).asVocab32()==
GAZECTRL_ACK) && (reply.size()>1))
 
 1111        if (Bottle *bDes=reply.get(1).asList())
 
 1113            qdes.resize(bDes->size());
 
 1114            for (
size_t i=0; i<qdes.length(); i++)
 
 1115                qdes[i]=bDes->get(i).asFloat64();
 
 
 1131    Bottle command, reply;
 
 1132    command.addString(
"get");
 
 1133    command.addString(
"vel");
 
 1135    if (!
portRpc.write(command,reply))
 
 1137        yError(
"unable to get reply from server!");
 
 1141    if ((reply.get(0).asVocab32()==
GAZECTRL_ACK) && (reply.size()>1))
 
 1143        if (Bottle *bVel=reply.get(1).asList())
 
 1145            qdot.resize(bVel->size());
 
 1146            for (
size_t i=0; i<qdot.length(); i++)
 
 1147                qdot[i]=bVel->get(i).asFloat64();
 
 
 1163    Bottle command, reply;
 
 1164    command.addString(
"get");
 
 1165    command.addString(
"pid");
 
 1167    if (!
portRpc.write(command,reply))
 
 1169        yError(
"unable to get reply from server!");
 
 1173    if ((reply.get(0).asVocab32()==
GAZECTRL_ACK) && (reply.size()>1))
 
 1175        if (Bottle *bOpt=reply.get(1).asList())
 
 
 1192    Bottle command, reply;
 
 1193    command.addString(
"set");
 
 1194    command.addString(
"Tneck");
 
 1195    command.addFloat64(t);
 
 1197    if (!
portRpc.write(command,reply))
 
 1199        yError(
"unable to get reply from server!");
 
 
 1213    Bottle command, reply;
 
 1214    command.addString(
"set");
 
 1215    command.addString(
"Teyes");
 
 1216    command.addFloat64(t);
 
 1218    if (!
portRpc.write(command,reply))
 
 1220        yError(
"unable to get reply from server!");
 
 
 1234    Bottle command, reply;
 
 1235    command.addString(
"set");
 
 1236    command.addString(
"vor");
 
 1237    command.addFloat64(gain);
 
 1239    if (!
portRpc.write(command,reply))
 
 1241        yError(
"unable to get reply from server!");
 
 
 1255    Bottle command, reply;
 
 1256    command.addString(
"set");
 
 1257    command.addString(
"ocr");
 
 1258    command.addFloat64(gain);
 
 1260    if (!
portRpc.write(command,reply))
 
 1262        yError(
"unable to get reply from server!");
 
 
 1276    Bottle command, reply;
 
 1277    command.addString(
"set");
 
 1278    command.addString(
"sacc");
 
 1279    command.addInt32((
int)
f);
 
 1281    if (!
portRpc.write(command,reply))
 
 1283        yError(
"unable to get reply from server!");
 
 
 1297    Bottle command, reply;
 
 1298    command.addString(
"set");
 
 1299    command.addString(
"sinh");
 
 1300    command.addFloat64(period);
 
 1302    if (!
portRpc.write(command,reply))
 
 1304        yError(
"unable to get reply from server!");
 
 
 1318    Bottle command, reply;
 
 1319    command.addString(
"set");
 
 1320    command.addString(
"sact");
 
 1321    command.addFloat64(angle);
 
 1323    if (!
portRpc.write(command,reply))
 
 1325        yError(
"unable to get reply from server!");
 
 
 1339    Bottle command, reply;
 
 1340    command.addString(
"set");
 
 1341    command.addString(
"pid");
 
 1342    command.addList()=options;
 
 1344    if (!
portRpc.write(command,reply))
 
 1346        yError(
"unable to get reply from server!");
 
 
 1361    Bottle command, reply;
 
 1362    command.addString(
"bind");
 
 1363    command.addString(joint);
 
 1364    command.addFloat64(min);
 
 1365    command.addFloat64(max);
 
 1367    if (!
portRpc.write(command,reply))
 
 1369        yError(
"unable to get reply from server!");
 
 
 1392    if (!
connected || (min==NULL) || (max==NULL))
 
 1395    Bottle command, reply;
 
 1396    command.addString(
"get");
 
 1397    command.addString(joint);
 
 1399    if (!
portRpc.write(command,reply))
 
 1401        yError(
"unable to get reply from server!");
 
 1405    if ((reply.get(0).asVocab32()==
GAZECTRL_ACK) && (reply.size()>2))
 
 1407        *min=reply.get(1).asFloat64();
 
 1408        *max=reply.get(2).asFloat64();
 
 
 1422    Bottle command, reply;
 
 1423    command.addString(
"clear");
 
 1424    command.addString(joint);
 
 1426    if (!
portRpc.write(command,reply))
 
 1428        yError(
"unable to get reply from server!");
 
 
 1505    Bottle command, reply;
 
 1506    command.addString(
"bind");
 
 1507    command.addString(
"eyes");
 
 1508    command.addFloat64(ver);
 
 1510    if (!
portRpc.write(command,reply))
 
 1512        yError(
"unable to get reply from server!");
 
 
 1558    Bottle command, reply;
 
 1559    command.addString(
"get");
 
 1560    command.addString(
"eyes");
 
 1562    if (!
portRpc.write(command,reply))
 
 1564        yError(
"unable to get reply from server!");
 
 1568    if ((reply.get(0).asVocab32()==
GAZECTRL_ACK) && (reply.size()>2))
 
 1570        *ver=reply.get(1).asFloat64();
 
 
 1612    Bottle command, reply;
 
 1613    command.addString(
"get");
 
 1614    command.addString(
"ntol");
 
 1616    if (!
portRpc.write(command,reply))
 
 1618        yError(
"unable to get reply from server!");
 
 1622    if ((reply.get(0).asVocab32()==
GAZECTRL_ACK) && (reply.size()>1))
 
 1624        *angle=reply.get(1).asFloat64();
 
 
 1638    Bottle command, reply;
 
 1639    command.addString(
"set");
 
 1640    command.addString(
"ntol");
 
 1641    command.addFloat64(angle);
 
 1643    if (!
portRpc.write(command,reply))
 
 1645        yError(
"unable to get reply from server!");
 
 
 1659    Bottle command, reply;
 
 1660    command.addString(
"get");
 
 1661    command.addString(
"done");
 
 1663    if (!
portRpc.write(command,reply))
 
 1665        yError(
"unable to get reply from server!");
 
 1671        *
f=(reply.get(1).asInt32()>0);
 
 
 1683    double t0=Time::now();
 
 1687        Time::delay(period);
 
 
 1703    Bottle command, reply;
 
 1704    command.addString(
"get");
 
 1705    command.addString(
"sdon");
 
 1707    if (!
portRpc.write(command,reply))
 
 1709        yError(
"unable to get reply from server!");
 
 1715        *
f=(reply.get(1).asInt32()>0);
 
 
 1727    double t0=Time::now();
 
 1731        Time::delay(period);
 
 
 1747    Bottle command, reply;
 
 1748    command.addString(
"stop");
 
 1750    if (!
portRpc.write(command,reply))
 
 1752        yError(
"unable to get reply from server!");
 
 
 1766    Bottle command, reply;
 
 1767    command.addString(
"stor");
 
 1769    if (!
portRpc.write(command,reply))
 
 1771        yError(
"unable to get reply from server!");
 
 
 1791    Bottle command, reply;
 
 1792    command.addString(
"rest");
 
 1793    command.addInt32(
id);
 
 1795    if (!
portRpc.write(command,reply))
 
 1797        yError(
"unable to get reply from server!");
 
 
 1811    Bottle command, reply;
 
 1812    command.addString(
"del");
 
 1813    command.addList().addInt32(
id);
 
 1815    if (!
portRpc.write(command,reply))
 
 1817        yError(
"unable to get reply from server!");
 
 
 1840    Bottle command, reply;
 
 1841    command.addString(
"del");
 
 1842    Bottle &ids=command.addList();
 
 1846    if (!
portRpc.write(command,reply))
 
 1848        yError(
"unable to get reply from server!");
 
 
 1861    Bottle command, reply;
 
 1862    command.addString(
"get");
 
 1863    command.addString(
"info");
 
 1865    if (!
portRpc.write(command,reply))
 
 1867        yError(
"unable to get reply from server!");
 
 1875            if (Bottle *infoPart=reply.get(1).asList())
 
 
 1899    string type=
event.get(0).asString();
 
 1900    double time=
event.get(1).asFloat64();
 
 1901    double checkPoint=(type==
"motion-ongoing")?event.get(2).asFloat64():-1.0;
 
 1902    map<string,GazeEvent*>::iterator itr;
 
 1908        if (itr->second!=NULL)
 
 1910            GazeEvent &Event=*itr->second;
 
 1911            Event.gazeEventVariables.type=type;
 
 1912            Event.gazeEventVariables.time=
time;
 
 1914            if (checkPoint>=0.0)
 
 1915                Event.gazeEventVariables.motionOngoingCheckPoint=checkPoint;
 
 1917            Event.gazeEventCallback();
 
 1921    string typeExtended=type;
 
 1922    if (checkPoint>=0.0)
 
 1925        ss<<type<<
"-"<<checkPoint;
 
 1926        typeExtended=ss.str();
 
 1933        if (itr->second!=NULL)
 
 1935            GazeEvent &Event=*itr->second;
 
 1936            Event.gazeEventVariables.type=type;
 
 1937            Event.gazeEventVariables.time=
time;
 
 1939            if (checkPoint>=0.0)
 
 1940                Event.gazeEventVariables.motionOngoingCheckPoint=checkPoint;
 
 1942            Event.gazeEventCallback();
 
 
 1954    string type=
event.gazeEventParameters.type;
 
 1955    if (type==
"motion-ongoing")
 
 1957        double checkPoint=
event.gazeEventParameters.motionOngoingCheckPoint;
 
 1959        Bottle command, reply;
 
 1960        command.addString(
"register");
 
 1961        command.addString(
"ongoing");
 
 1962        command.addFloat64(checkPoint);
 
 1964        if (!
portRpc.write(command,reply))
 
 1966            yError(
"unable to get reply from server!");
 
 1974        ss<<type<<
"-"<<checkPoint;
 
 
 1989    string type=
event.gazeEventParameters.type;
 
 1990    if (type==
"motion-ongoing")
 
 1992        double checkPoint=
event.gazeEventParameters.motionOngoingCheckPoint;
 
 1994        Bottle command, reply;
 
 1995        command.addString(
"unregister");
 
 1996        command.addString(
"ongoing");
 
 1997        command.addFloat64(checkPoint);
 
 1999        if (!
portRpc.write(command,reply))
 
 2001            yError(
"unable to get reply from server!");
 
 2009        ss<<type<<
"-"<<checkPoint;
 
 
 2024    Bottle command, reply;
 
 2025    command.addString(
"set");
 
 2026    command.addString(
"tweak");
 
 2027    command.addList()=options;
 
 2029    if (!
portRpc.write(command,reply))
 
 2031        yError(
"unable to get reply from server!");
 
 
 2045    Bottle command, reply;
 
 2046    command.addString(
"get");
 
 2047    command.addString(
"tweak");
 
 2049    if (!
portRpc.write(command,reply))
 
 2051        yError(
"unable to get reply from server!");
 
 2059            if (Bottle *optionsPart=reply.get(1).asList())
 
 2060                options=*optionsPart;
 
 
#define GAZECTRL_CLIENT_VER
 
#define GAZECTRL_DEFAULT_TMO
 
clientgazecontroller : implements the client part of the the Gaze Control Interface.
 
bool getPose(const std::string &poseSel, yarp::sig::Vector &x, yarp::sig::Vector &o, yarp::os::Stamp *stamp=NULL)
 
bool getFixationPoint(yarp::sig::Vector &fp, yarp::os::Stamp *stamp=NULL)
 
bool lookAtFixationPointSync(const yarp::sig::Vector &fp)
 
bool lookAtMonoPixel(const int camSel, const yarp::sig::Vector &px, const double z=1.0)
 
bool waitSaccadeDone(const double period=0.1, const double timeout=0.0)
 
bool lookAtMonoPixelWithVergenceSync(const int camSel, const yarp::sig::Vector &px, const double ver)
 
bool setTrackingMode(const bool f)
 
bool get3DPointOnPlane(const int camSel, const yarp::sig::Vector &px, const yarp::sig::Vector &plane, yarp::sig::Vector &x)
 
bool triangulate3DPoint(const yarp::sig::Vector &pxl, const yarp::sig::Vector &pxr, yarp::sig::Vector &x)
 
bool bindNeckPitch(const double min, const double max)
 
bool setStabilizationMode(const bool f)
 
bool setVORGain(const double gain)
 
yarp::os::BufferedPort< yarp::sig::Vector > portStateHead
 
bool getJointsVelocities(yarp::sig::Vector &qdot)
 
bool getNeckPitchRange(double *min, double *max)
 
bool getInfo(yarp::os::Bottle &info)
 
bool getNeckJointRange(const std::string &joint, double *min, double *max)
 
bool lookAtMonoPixelWithVergence(const int camSel, const yarp::sig::Vector &px, const double ver)
 
yarp::os::BufferedPort< yarp::os::Bottle > portCmdAng
 
bool setOCRGain(const double gain)
 
bool unregisterEvent(yarp::dev::GazeEvent &event)
 
std::map< std::string, yarp::dev::GazeEvent * > eventsMap
 
bool get3DPoint(const int camSel, const yarp::sig::Vector &px, const double z, yarp::sig::Vector &x)
 
bool tweakGet(yarp::os::Bottle &options)
 
yarp::os::BufferedPort< yarp::sig::Vector > portStateFp
 
yarp::os::BufferedPort< yarp::os::Bottle > portCmdFp
 
bool getNeckTrajTime(double *t)
 
bool getSaccadesActivationAngle(double *angle)
 
bool getOCRGain(double *gain)
 
bool lookAtStereoPixelsSync(const yarp::sig::Vector &pxl, const yarp::sig::Vector &pxr)
 
bool lookAtRelAngles(const yarp::sig::Vector &ang)
 
yarp::os::Stamp anglesStamp
 
bool getSaccadesMode(bool *f)
 
bool getLeftEyePose(yarp::sig::Vector &x, yarp::sig::Vector &o, yarp::os::Stamp *stamp=NULL)
 
bool getVORGain(double *gain)
 
bool getNeckAngleUserTolerance(double *angle)
 
yarp::os::BufferedPort< yarp::os::Bottle > portCmdMono
 
bool getBlockedVergence(double *ver)
 
bool getRightEyePose(yarp::sig::Vector &x, yarp::sig::Vector &o, yarp::os::Stamp *stamp=NULL)
 
double lastFpMsgArrivalTime
 
bool registerEvent(yarp::dev::GazeEvent &event)
 
bool setNeckAngleUserTolerance(const double angle)
 
bool getSaccadesInhibitionPeriod(double *period)
 
bool storeContext(int *id)
 
bool setSaccadesActivationAngle(const double angle)
 
bool checkSaccadeDone(bool *f)
 
bool bindNeckYaw(const double min, const double max)
 
yarp::os::RpcClient portRpc
 
bool getTrackingMode(bool *f)
 
bool setEyesTrajTime(const double t)
 
bool lookAtStereoPixels(const yarp::sig::Vector &pxl, const yarp::sig::Vector &pxr)
 
bool getInfoHelper(yarp::os::Bottle &info)
 
bool setStereoOptions(const yarp::os::Bottle &options)
 
bool bindNeckRoll(const double min, const double max)
 
bool getEyesTrajTime(double *t)
 
bool setSaccadesMode(const bool f)
 
bool blockNeckJoint(const std::string &joint, const double min, const double max)
 
bool setSaccadesInhibitionPeriod(const double period)
 
yarp::sig::Vector fixationPoint
 
bool getAngles(yarp::sig::Vector &ang, yarp::os::Stamp *stamp=NULL)
 
yarp::os::BufferedPort< yarp::sig::Vector > portStateAng
 
bool tweakSet(const yarp::os::Bottle &options)
 
bool getAnglesFrom3DPoint(const yarp::sig::Vector &x, yarp::sig::Vector &ang)
 
bool getJointsDesired(yarp::sig::Vector &qdes)
 
bool clearJoint(const std::string &joint)
 
virtual ~ClientGazeController()
 
bool get2DPixel(const int camSel, const yarp::sig::Vector &x, yarp::sig::Vector &px)
 
bool lookAtMonoPixelSync(const int camSel, const yarp::sig::Vector &px, const double z=1.0)
 
bool lookAtRelAnglesSync(const yarp::sig::Vector &ang)
 
bool getStereoOptions(yarp::os::Bottle &options)
 
bool waitMotionDone(const double period=0.1, const double timeout=0.0)
 
bool getHeadPose(yarp::sig::Vector &x, yarp::sig::Vector &o, yarp::os::Stamp *stamp=NULL)
 
bool setNeckTrajTime(const double t)
 
bool checkMotionDone(bool *f)
 
bool lookAtFixationPoint(const yarp::sig::Vector &fp)
 
bool getNeckYawRange(double *min, double *max)
 
yarp::os::BufferedPort< yarp::os::Bottle > portCmdStereo
 
std::set< int > contextIdList
 
bool lookAtAbsAngles(const yarp::sig::Vector &ang)
 
bool deleteContext(const int id)
 
bool getNeckRollRange(double *min, double *max)
 
GazeEventHandler portEvents
 
bool lookAtAbsAnglesSync(const yarp::sig::Vector &ang)
 
bool restoreContext(const int id)
 
bool get3DPointFromAngles(const int mode, const yarp::sig::Vector &ang, yarp::sig::Vector &x)
 
bool getStabilizationMode(bool *f)
 
double lastAngMsgArrivalTime
 
bool open(yarp::os::Searchable &config)
 
void eventHandling(yarp::os::Bottle &event)
 
void setInterface(ClientGazeController *interface)
 
void onRead(yarp::os::Bottle &event)
 
ClientGazeController * interface
 
static struct bpf_program fp