21 #include <iCub/d4c/d4c_client.h>
22 #include <iCub/d4c/private/d4c_helpers.h>
31 D4CClient::D4CClient() : isOpen(false), verbosity(0)
45 D4CClient::~D4CClient()
52 void D4CClient::printMessage(
const int logtype,
const int level,
53 const char *format, ...)
const
58 str=
"*** "+local+
": ";
63 vsnprintf(buf,
sizeof(buf),format,arg);
73 yWarning(str.c_str());
79 printf(
"%s\n",str.c_str());
86 bool D4CClient::open(
const Property &options)
88 if (options.check(
"remote"))
89 remote=options.find(
"remote").asString().c_str();
92 printMessage(log::error,1,
"\"remote\" option is mandatory to open the client!");
96 if (options.check(
"local"))
97 local=options.find(
"local").asString().c_str();
100 printMessage(log::error,1,
"\"local\" option is mandatory to open the client!");
104 carrier=options.check(
"carrier",Value(
"udp")).asString().c_str();
105 verbosity=options.check(
"verbosity",Value(0)).asInt();
107 data.open((local+
"/data:i").c_str());
108 rpc.open((local+
"/rpc").c_str());
112 ok&=Network::connect((remote+
"/data:o").c_str(),data.getName().c_str(),carrier.c_str());
113 ok&=Network::connect(rpc.getName().c_str(),(remote+
"/rpc").c_str());
118 cmd.addVocab(D4C_VOCAB_CMD_PING);
120 if (rpc.write(cmd,reply))
124 if (reply.get(0).asVocab()==D4C_VOCAB_CMD_ACK)
126 printMessage(log::info,1,
"successfully connected with the server %s!",remote.c_str());
132 printMessage(log::error,1,
"unable to get correct reply from the server %s!",remote.c_str());
139 printMessage(log::error,1,
"unable to connect to the server %s!",remote.c_str());
148 void D4CClient::close()
160 printMessage(log::info,1,
"client closed");
163 printMessage(log::warning,3,
"client is already closed");
168 bool D4CClient::addItem(
const Property &options,
int &item)
172 string options_str=options.toString().c_str();
173 printMessage(log::no_info,2,
"request for adding new item: %s",options_str.c_str());
176 val.fromString((
"("+options_str+
")").c_str());
179 cmd.addVocab(D4C_VOCAB_CMD_ADD);
182 if (rpc.write(cmd,reply))
184 if (reply.get(0).asVocab()==D4C_VOCAB_CMD_ACK)
186 item=reply.get(1).asInt();
187 printMessage(log::no_info,1,
"item %d successfully added",item);
192 printMessage(log::error,1,
"something went wrong: request rejected");
198 printMessage(log::error,1,
"unable to get reply from the server %s!",remote.c_str());
204 printMessage(log::warning,1,
"client is not open");
211 bool D4CClient::eraseItem(
const int item)
215 printMessage(log::no_info,2,
"request for erasing item %d",item);
218 cmd.addVocab(D4C_VOCAB_CMD_DEL);
221 if (rpc.write(cmd,reply))
223 if (reply.get(0).asVocab()==D4C_VOCAB_CMD_ACK)
225 printMessage(log::no_info,1,
"item %d successfully erased",item);
230 printMessage(log::error,1,
"something went wrong: request rejected");
236 printMessage(log::error,1,
"unable to get reply from the server %s!",remote.c_str());
242 printMessage(log::warning,1,
"client is not open");
249 bool D4CClient::clearItems()
253 printMessage(log::no_info,2,
"request for clearing item table");
256 cmd.addVocab(D4C_VOCAB_CMD_CLEAR);
258 if (rpc.write(cmd,reply))
260 if (reply.get(0).asVocab()==D4C_VOCAB_CMD_ACK)
262 printMessage(log::no_info,1,
"all items have been successfully erased");
267 printMessage(log::error,1,
"something went wrong: request rejected");
273 printMessage(log::error,1,
"unable to get reply from the server %s!",remote.c_str());
279 printMessage(log::warning,1,
"client is not open");
286 bool D4CClient::getItems(Bottle &items)
290 printMessage(log::no_info,2,
"request for retrieving items ids list");
293 cmd.addVocab(D4C_VOCAB_CMD_LIST);
295 if (rpc.write(cmd,reply))
297 if (reply.get(0).asVocab()==D4C_VOCAB_CMD_ACK)
299 items=*reply.get(1).asList();
300 printMessage(log::no_info,1,
"items ids successfully retrieved: %s",
301 items.toString().c_str());
306 printMessage(log::error,1,
"something went wrong: request rejected");
312 printMessage(log::error,1,
"unable to get reply from the server %s!",remote.c_str());
318 printMessage(log::warning,1,
"client is not open");
325 bool D4CClient::setProperty(
const int item,
const Property &options)
329 string options_str=options.toString().c_str();
330 printMessage(log::no_info,2,
"request for setting item %d property: %s",
331 item,options_str.c_str());
334 val.fromString((
"("+options_str+
")").c_str());
337 cmd.addVocab(D4C_VOCAB_CMD_SET);
341 if (rpc.write(cmd,reply))
343 if (reply.get(0).asVocab()==D4C_VOCAB_CMD_ACK)
345 printMessage(log::no_info,1,
"item %d property successfully updated: %s",
346 item,options_str.c_str());
351 printMessage(log::error,1,
"something went wrong: request rejected");
357 printMessage(log::error,1,
"unable to get reply from the server %s!",remote.c_str());
363 printMessage(log::warning,1,
"client is not open");
370 bool D4CClient::getProperty(
const int item, Property &options)
374 printMessage(log::no_info,2,
"request for retrieving item %d property",item);
377 cmd.addVocab(D4C_VOCAB_CMD_GET);
380 if (rpc.write(cmd,reply))
382 if (reply.get(0).asVocab()==D4C_VOCAB_CMD_ACK)
384 options=extractProperty(reply.get(1));
385 printMessage(log::no_info,1,
"item %d property successfully retrieved: %s",
386 item,options.toString().c_str());
391 printMessage(log::error,1,
"something went wrong: request rejected");
397 printMessage(log::error,1,
"unable to get reply from the server %s!",remote.c_str());
403 printMessage(log::warning,1,
"client is not open");
410 bool D4CClient::enableField()
414 printMessage(log::no_info,2,
"request for enabling field");
417 cmd.addVocab(D4C_VOCAB_CMD_ENFIELD);
419 if (rpc.write(cmd,reply))
421 if (reply.get(0).asVocab()==D4C_VOCAB_CMD_ACK)
423 printMessage(log::no_info,1,
"field enabled");
428 printMessage(log::error,1,
"something went wrong: request rejected");
434 printMessage(log::error,1,
"unable to get reply from the server %s!",remote.c_str());
440 printMessage(log::warning,1,
"client is not open");
447 bool D4CClient::disableField()
451 printMessage(log::no_info,2,
"request for disabling field");
454 cmd.addVocab(D4C_VOCAB_CMD_DISFIELD);
456 if (rpc.write(cmd,reply))
458 if (reply.get(0).asVocab()==D4C_VOCAB_CMD_ACK)
460 printMessage(log::no_info,1,
"field disabled");
465 printMessage(log::error,1,
"something went wrong: request rejected");
471 printMessage(log::error,1,
"unable to get reply from the server %s!",remote.c_str());
477 printMessage(log::warning,1,
"client is not open");
484 bool D4CClient::getFieldStatus(
bool &status)
488 printMessage(log::no_info,2,
"request for retrieving field status");
491 cmd.addVocab(D4C_VOCAB_CMD_STATFIELD);
493 if (rpc.write(cmd,reply))
495 if (reply.get(0).asVocab()==D4C_VOCAB_CMD_ACK)
497 string sw=reply.get(1).asString().c_str();
499 printMessage(log::no_info,1,
"field status = %s",sw.c_str());
504 printMessage(log::error,1,
"something went wrong: request rejected");
510 printMessage(log::error,1,
"unable to get reply from the server %s!",remote.c_str());
516 printMessage(log::warning,1,
"client is not open");
523 bool D4CClient::enableControl()
527 printMessage(log::no_info,2,
"request for enabling control");
530 cmd.addVocab(D4C_VOCAB_CMD_ENCTRL);
532 if (rpc.write(cmd,reply))
534 if (reply.get(0).asVocab()==D4C_VOCAB_CMD_ACK)
536 printMessage(log::no_info,1,
"control enabled");
541 printMessage(log::error,1,
"something went wrong: request rejected");
547 printMessage(log::error,1,
"unable to get reply from the server %s!",remote.c_str());
553 printMessage(log::warning,1,
"client is not open");
560 bool D4CClient::disableControl()
564 printMessage(log::no_info,2,
"request for disabling control");
567 cmd.addVocab(D4C_VOCAB_CMD_DISCTRL);
569 if (rpc.write(cmd,reply))
571 if (reply.get(0).asVocab()==D4C_VOCAB_CMD_ACK)
573 printMessage(log::no_info,1,
"control disabled");
578 printMessage(log::error,1,
"something went wrong: request rejected");
584 printMessage(log::error,1,
"unable to get reply from the server %s!",remote.c_str());
590 printMessage(log::warning,1,
"client is not open");
597 bool D4CClient::getControlStatus(
bool &status)
601 printMessage(log::no_info,2,
"request for retrieving control status");
604 cmd.addVocab(D4C_VOCAB_CMD_STATCTRL);
606 if (rpc.write(cmd,reply))
608 if (reply.get(0).asVocab()==D4C_VOCAB_CMD_ACK)
610 string sw=reply.get(1).asString().c_str();
612 printMessage(log::no_info,1,
"control status = %s",sw.c_str());
617 printMessage(log::error,1,
"something went wrong: request rejected");
623 printMessage(log::error,1,
"unable to get reply from the server %s!",remote.c_str());
629 printMessage(log::warning,1,
"client is not open");
636 bool D4CClient::enableSimulation()
640 printMessage(log::no_info,2,
"request for enabling simulation");
643 cmd.addVocab(D4C_VOCAB_CMD_ENSIM);
645 if (rpc.write(cmd,reply))
647 if (reply.get(0).asVocab()==D4C_VOCAB_CMD_ACK)
649 printMessage(log::no_info,1,
"simulation enabled");
654 printMessage(log::error,1,
"something went wrong: request rejected");
660 printMessage(log::error,1,
"unable to get reply from the server %s!",remote.c_str());
666 printMessage(log::warning,1,
"client is not open");
673 bool D4CClient::disableSimulation()
677 printMessage(log::no_info,2,
"request for disabling simulation");
680 cmd.addVocab(D4C_VOCAB_CMD_DISSIM);
682 if (rpc.write(cmd,reply))
684 if (reply.get(0).asVocab()==D4C_VOCAB_CMD_ACK)
686 printMessage(log::no_info,1,
"simulation disabled");
691 printMessage(log::error,1,
"something went wrong: request rejected");
697 printMessage(log::error,1,
"unable to get reply from the server %s!",remote.c_str());
703 printMessage(log::warning,1,
"client is not open");
710 bool D4CClient::getSimulationStatus(
bool &status)
714 printMessage(log::no_info,2,
"request for retrieving simulation status");
717 cmd.addVocab(D4C_VOCAB_CMD_STATSIM);
719 if (rpc.write(cmd,reply))
721 if (reply.get(0).asVocab()==D4C_VOCAB_CMD_ACK)
723 string sw=reply.get(1).asString().c_str();
725 printMessage(log::no_info,1,
"simulation status = %s",sw.c_str());
730 printMessage(log::error,1,
"something went wrong: request rejected");
736 printMessage(log::error,1,
"unable to get reply from the server %s!",remote.c_str());
742 printMessage(log::warning,1,
"client is not open");
749 bool D4CClient::setPeriod(
const int period)
753 printMessage(log::no_info,2,
"request for setting period to %s [ms]",period);
756 cmd.addVocab(D4C_VOCAB_CMD_SETPER);
759 if (rpc.write(cmd,reply))
761 if (reply.get(0).asVocab()==D4C_VOCAB_CMD_ACK)
763 printMessage(log::no_info,1,
"period successfully updated");
768 printMessage(log::error,1,
"something went wrong: request rejected");
774 printMessage(log::error,1,
"unable to get reply from the server %s!",remote.c_str());
780 printMessage(log::warning,1,
"client is not open");
787 bool D4CClient::getPeriod(
int &period)
791 printMessage(log::no_info,2,
"request for retrieving period");
794 cmd.addVocab(D4C_VOCAB_CMD_GETPER);
796 if (rpc.write(cmd,reply))
798 if (reply.get(0).asVocab()==D4C_VOCAB_CMD_ACK)
800 period=reply.get(1).asInt();
801 printMessage(log::no_info,1,
"period successfully retrieved: %d [ms]",period);
806 printMessage(log::error,1,
"something went wrong: request rejected");
812 printMessage(log::error,1,
"unable to get reply from the server %s!",remote.c_str());
818 printMessage(log::warning,1,
"client is not open");
825 bool D4CClient::setPointStateToTool()
829 printMessage(log::no_info,2,
"request for setting state equal to tool state");
832 cmd.addVocab(D4C_VOCAB_CMD_SETSTATETOTOOL);
834 if (rpc.write(cmd,reply))
836 if (reply.get(0).asVocab()==D4C_VOCAB_CMD_ACK)
838 printMessage(log::no_info,1,
"state successfully updated");
843 printMessage(log::error,1,
"something went wrong: request rejected");
849 printMessage(log::error,1,
"unable to get reply from the server %s!",remote.c_str());
855 printMessage(log::warning,1,
"client is not open");
862 bool D4CClient::attachToolFrame(
const yarp::sig::Vector &x,
const yarp::sig::Vector &o)
866 if ((x.length()<3) || (o.length()<4))
868 printMessage(log::error,1,
"problem with vector lengths");
872 Value val_x; val_x.fromString((
"("+
string(x.toString().c_str())+
")").c_str());
873 Value val_o; val_o.fromString((
"("+
string(o.toString().c_str())+
")").c_str());
876 options.put(
"x",val_x);
877 options.put(
"o",val_o);
879 string options_str=options.toString().c_str();
880 printMessage(log::no_info,2,
"request for attaching tool frame: %s",options_str.c_str());
883 val.fromString((
"("+options_str+
")").c_str());
886 cmd.addVocab(D4C_VOCAB_CMD_ATTACHTOOLFRAME);
889 if (rpc.write(cmd,reply))
891 if (reply.get(0).asVocab()==D4C_VOCAB_CMD_ACK)
893 printMessage(log::no_info,1,
"tool frame successfully attached");
898 printMessage(log::error,1,
"something went wrong: request rejected");
904 printMessage(log::error,1,
"unable to get reply from the server %s!",remote.c_str());
910 printMessage(log::warning,1,
"client is not open");
917 bool D4CClient::getToolFrame(yarp::sig::Vector &x, yarp::sig::Vector &o)
921 printMessage(log::no_info,2,
"request for retrieving tool frame");
924 cmd.addVocab(D4C_VOCAB_CMD_GETTOOLFRAME);
926 if (rpc.write(cmd,reply))
928 if (reply.get(0).asVocab()==D4C_VOCAB_CMD_ACK)
930 Property options=extractProperty(reply.get(1));
931 extractVector(options,
"x",x);
932 extractVector(options,
"o",o);
934 printMessage(log::no_info,1,
"tool frame successfully retrieved %s",
935 options.toString().c_str());
940 printMessage(log::error,1,
"something went wrong: request rejected");
946 printMessage(log::error,1,
"unable to get reply from the server %s!",remote.c_str());
952 printMessage(log::warning,1,
"client is not open");
959 bool D4CClient::removeToolFrame()
963 printMessage(log::no_info,2,
"request for removing tool frame");
966 cmd.addVocab(D4C_VOCAB_CMD_REMOVETOOLFRAME);
968 if (rpc.write(cmd,reply))
970 if (reply.get(0).asVocab()==D4C_VOCAB_CMD_ACK)
972 printMessage(log::no_info,1,
"tool successfully removed");
977 printMessage(log::error,1,
"something went wrong: request rejected");
983 printMessage(log::error,1,
"unable to get reply from the server %s!",remote.c_str());
989 printMessage(log::warning,1,
"client is not open");
996 bool D4CClient::getTool(yarp::sig::Vector &x, yarp::sig::Vector &o)
1000 printMessage(log::no_info,2,
"request for retrieving tool");
1003 cmd.addVocab(D4C_VOCAB_CMD_GETTOOL);
1005 if (rpc.write(cmd,reply))
1007 if (reply.get(0).asVocab()==D4C_VOCAB_CMD_ACK)
1009 Property options=extractProperty(reply.get(1));
1010 extractVector(options,
"x",x);
1011 extractVector(options,
"o",o);
1013 printMessage(log::no_info,1,
"tool successfully retrieved %s",
1014 options.toString().c_str());
1019 printMessage(log::error,1,
"something went wrong: request rejected");
1025 printMessage(log::error,1,
"unable to get reply from the server %s!",remote.c_str());
1031 printMessage(log::warning,1,
"client is not open");
1038 bool D4CClient::setPointState(
const Vector &x,
const Vector &o,
1039 const Vector &xdot,
const Vector &odot)
1043 Vector pos(7),vel(7);
1044 copyVectorData(x,pos);
1045 copyVectorData(o,pos);
1046 copyVectorData(xdot,vel);
1047 copyVectorData(odot,vel);
1049 Value val_x; val_x.fromString((
"("+
string(pos.toString().c_str())+
")").c_str());
1050 Value val_xdot; val_xdot.fromString((
"("+
string(vel.toString().c_str())+
")").c_str());
1053 options.put(
"x",val_x);
1054 options.put(
"xdot",val_xdot);
1056 string options_str=options.toString().c_str();
1057 printMessage(log::no_info,2,
"request for setting state: %s",options_str.c_str());
1060 val.fromString((
"("+options_str+
")").c_str());
1063 cmd.addVocab(D4C_VOCAB_CMD_SETSTATE);
1066 if (rpc.write(cmd,reply))
1068 if (reply.get(0).asVocab()==D4C_VOCAB_CMD_ACK)
1070 printMessage(log::no_info,1,
"state successfully updated");
1075 printMessage(log::error,1,
"something went wrong: request rejected");
1081 printMessage(log::error,1,
"unable to get reply from the server %s!",remote.c_str());
1087 printMessage(log::warning,1,
"client is not open");
1094 bool D4CClient::setPointOrientation(
const Vector &o,
const Vector &odot)
1098 Value val_o; val_o.fromString((
"("+
string(o.toString().c_str())+
")").c_str());
1099 Value val_odot; val_odot.fromString((
"("+
string(odot.toString().c_str())+
")").c_str());
1102 options.put(
"o",val_o);
1103 options.put(
"odot",val_odot);
1105 string options_str=options.toString().c_str();
1106 printMessage(log::no_info,2,
"request for setting orientation: %s",options_str.c_str());
1109 val.fromString((
"("+options_str+
")").c_str());
1112 cmd.addVocab(D4C_VOCAB_CMD_SETORIEN);
1115 if (rpc.write(cmd,reply))
1117 if (reply.get(0).asVocab()==D4C_VOCAB_CMD_ACK)
1119 printMessage(log::no_info,1,
"orientation successfully updated");
1124 printMessage(log::error,1,
"something went wrong: request rejected");
1130 printMessage(log::error,1,
"unable to get reply from the server %s!",remote.c_str());
1136 printMessage(log::warning,1,
"client is not open");
1143 bool D4CClient::getPointState(Vector &x, Vector &o, Vector &xdot, Vector &odot)
1147 if (Property *prop=data.read(
false))
1149 extractVector(*prop,
"x",this->x);
1150 extractVector(*prop,
"xdot",this->xdot);
1153 x=getVectorPos(this->x);
1154 o=getVectorOrien(this->x);
1155 xdot=getVectorPos(this->xdot);
1156 odot=getVectorOrien(this->xdot);
1158 printMessage(log::no_info,1,
"got state: x = %s xdot = %s",
1159 this->x.toString().c_str(),this->xdot.toString().c_str());
1164 printMessage(log::warning,1,
"client is not open");
1171 bool D4CClient::getField(Vector &field)
1175 if (Property *prop=data.read(
false))
1176 extractVector(*prop,
"field",this->field);
1180 printMessage(log::no_info,1,
"got field: field=%s",
1181 this->field.toString().c_str());
1186 printMessage(log::warning,1,
"client is not open");
1193 bool D4CClient::getSimulation(Vector &xhat, Vector &ohat, Vector &qhat)
1197 if (Property *prop=data.read(
false))
1199 extractVector(*prop,
"xhat",this->xhat);
1200 extractVector(*prop,
"qhat",this->qhat);
1203 xhat=getVectorPos(this->xhat);
1204 ohat=getVectorOrien(this->xhat);
1207 printMessage(log::no_info,1,
"got simulated end-effector pose: xhat = %s; got part configuration: qhat = %s",
1208 this->xhat.toString().c_str(),this->qhat.toString().c_str());
1213 printMessage(log::warning,1,
"client is not open");
1220 bool D4CClient::getActiveIF(
string &activeIF)
1224 printMessage(log::no_info,2,
"request to know the active interface");
1227 cmd.addVocab(D4C_VOCAB_CMD_GETACTIF);
1229 if (rpc.write(cmd,reply))
1231 if (reply.get(0).asVocab()==D4C_VOCAB_CMD_ACK)
1233 activeIF=reply.get(1).asString().c_str();
1234 printMessage(log::no_info,1,
"active interface: %s",activeIF.c_str());
1239 printMessage(log::error,1,
"something went wrong: request rejected");
1245 printMessage(log::error,1,
"unable to get reply from the server %s!",remote.c_str());
1251 printMessage(log::warning,1,
"client is not open");
1258 bool D4CClient::setActiveIF(
const string &activeIF)
1262 printMessage(log::no_info,2,
"request to set the active interface");
1265 cmd.addVocab(D4C_VOCAB_CMD_SETACTIF);
1266 cmd.addString(activeIF.c_str());
1268 if (rpc.write(cmd,reply))
1270 if (reply.get(0).asVocab()==D4C_VOCAB_CMD_ACK)
1272 printMessage(log::no_info,1,
"active interface successfully set to %s",activeIF.c_str());
1277 printMessage(log::error,1,
"something went wrong: request rejected");
1283 printMessage(log::error,1,
"unable to get reply from the server %s!",remote.c_str());
1289 printMessage(log::warning,1,
"client is not open");
1296 bool D4CClient::getTrajectory(deque<Vector> &trajPos, deque<Vector> &trajOrien,
1297 const unsigned int maxIterations,
const double Ts)
1301 printMessage(log::no_info,2,
"request to retrieve the whole trajectory");
1304 cmd.addVocab(D4C_VOCAB_CMD_GETTRAJ);
1307 options.put(
"maxIterations",(
int)maxIterations);
1308 options.put(
"Ts",Ts);
1310 string options_str=options.toString().c_str();
1313 val.fromString((
"("+options_str+
")").c_str());
1316 if (rpc.write(cmd,reply))
1318 if (reply.get(0).asVocab()==D4C_VOCAB_CMD_ACK)
1321 if (Bottle *BtrajPos=reply.get(1).asList())
1323 if (BtrajPos->get(0).asString()==
"trajPos")
1326 for (
int i=1; i<BtrajPos->size(); i++)
1328 if (Bottle *point=BtrajPos->get(i).asList())
1330 Vector pos(point->size());
1331 for (
int j=0; j<point->size(); j++)
1332 pos[j]=point->get(j).asDouble();
1334 trajPos.push_back(pos);
1339 printMessage(log::no_info,1,
"trajectory in position has been computed");
1344 if (Bottle *BtrajOrien=reply.get(2).asList())
1346 if (BtrajOrien->get(0).asString()==
"trajOrien")
1349 for (
int i=1; i<BtrajOrien->size(); i++)
1351 if (Bottle *point=BtrajOrien->get(i).asList())
1353 Vector orien(point->size());
1354 for (
int j=0; j<point->size(); j++)
1355 orien[j]=point->get(j).asDouble();
1357 trajOrien.push_back(orien);
1362 printMessage(log::no_info,1,
"trajectory in orientation has been computed");
1366 if (okPos && okOrien)
1370 printMessage(log::error,1,
"something went wrong: request rejected");
1375 printMessage(log::error,1,
"unable to get reply from the server %s!",remote.c_str());
1381 printMessage(log::warning,1,
"client is not open");
1388 bool D4CClient::executeTrajectory(
const deque<Vector> &trajPos,
const deque<Vector> &trajOrien,
1389 const double trajTime)
1393 printMessage(log::no_info,2,
"request to execute user trajectory");
1395 if (trajPos.size()!=trajOrien.size())
1397 printMessage(log::error,1,
"position and orientation data have different size!");
1400 else if (trajTime<0.0)
1402 printMessage(log::error,1,
"negative trajectory duration provided!");
1407 cmd.addVocab(D4C_VOCAB_CMD_EXECTRAJ);
1408 Bottle &cmdOptions=cmd.addList();
1410 Bottle &bTrajTime=cmdOptions.addList();
1411 bTrajTime.addString(
"trajTime");
1412 bTrajTime.addDouble(trajTime);
1414 Bottle &bPos=cmdOptions.addList();
1415 bPos.addString(
"trajPos");
1416 for (
unsigned int i=0; i<trajPos.size(); i++)
1418 Bottle &point=bPos.addList();
1419 for (
size_t j=0; j<trajPos[i].length(); j++)
1420 point.addDouble(trajPos[i][j]);
1423 Bottle &bOrien=cmdOptions.addList();
1424 bOrien.addString(
"trajOrien");
1425 for (
unsigned int i=0; i<trajOrien.size(); i++)
1427 Bottle &point=bOrien.addList();
1428 for (
size_t j=0; j<trajOrien[i].length(); j++)
1429 point.addDouble(trajOrien[i][j]);
1432 if (rpc.write(cmd,reply))
1434 if (reply.get(0).asVocab()==D4C_VOCAB_CMD_ACK)
1436 printMessage(log::no_info,1,
"trajectory executed");
1440 printMessage(log::error,1,
"something went wrong: request rejected");
1445 printMessage(log::error,1,
"unable to get reply from the server %s!",remote.c_str());
1451 printMessage(log::warning,1,
"client is not open");