YARP
Yet Another Robot Platform
RemoteControlBoard.cpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include "RemoteControlBoard.h"
9 #include "stateExtendedReader.h"
10 
11 #include <cstring>
12 
13 #include <yarp/os/PortablePair.h>
14 #include <yarp/os/BufferedPort.h>
15 #include <yarp/os/Time.h>
16 #include <yarp/os/Network.h>
17 #include <yarp/os/PeriodicThread.h>
18 #include <yarp/os/Vocab.h>
19 #include <yarp/os/Stamp.h>
20 #include <yarp/os/LogStream.h>
21 #include <yarp/os/QosStyle.h>
22 
23 
25 #include <yarp/dev/PolyDriver.h>
29 
30 #include <mutex>
31 
32 
33 using namespace yarp::os;
34 using namespace yarp::dev;
35 using namespace yarp::sig;
36 
37 namespace {
38 
39 constexpr int PROTOCOL_VERSION_MAJOR = 1;
40 constexpr int PROTOCOL_VERSION_MINOR = 9;
41 constexpr int PROTOCOL_VERSION_TWEAK = 0;
42 
43 constexpr double DIAGNOSTIC_THREAD_PERIOD = 1.000;
44 
45 inline bool getTimeStamp(Bottle &bot, Stamp &st)
46 {
47  if (bot.get(3).asVocab32()==VOCAB_TIMESTAMP)
48  {
49  //yup! we have a timestamp
50  int fr=bot.get(4).asInt32();
51  double ts=bot.get(5).asFloat64();
52  st=Stamp(fr,ts);
53  return true;
54  }
55  return false;
56 }
57 
58 } // namespace
59 
60 
62  public PeriodicThread
63 {
64  StateExtendedInputPort *owner{nullptr};
65  std::string ownerName;
66 
67 public:
69 
71  {
72  owner = o;
73  ownerName = owner->getName();
74  }
75 
76  void run() override
77  {
78  if (owner != nullptr)
79  {
80  if (owner->getIterations() > 100)
81  {
82  int it;
83  double av;
84  double max;
85  double min;
86  owner->getEstFrequency(it, av, min, max);
87  owner->resetStat();
89  "%s: %d msgs av:%.2lf min:%.2lf max:%.2lf [ms]",
90  ownerName.c_str(),
91  it,
92  av,
93  min,
94  max);
95  }
96 
97  }
98  }
99 };
100 
101 
103 {
104  if (!njIsKnown) {
105  int axes = 0;
106  bool ok = get1V1I(VOCAB_AXES, axes);
107  if (axes >= 0 && ok) {
108  nj = axes;
109  njIsKnown = true;
110  }
111  }
112  return njIsKnown;
113 }
114 
115 
117 {
118  bool error=false;
119  // verify protocol
120  Bottle cmd, reply;
121  cmd.addVocab32(VOCAB_GET);
123  rpc_p.write(cmd, reply);
124 
125  // check size and format of messages, expected [prot] int int int [ok]
126  if (reply.size() != 5) {
127  error = true;
128  }
129 
130  if (reply.get(0).asVocab32() != VOCAB_PROTOCOL_VERSION) {
131  error = true;
132  }
133 
134  if (!error)
135  {
136  protocolVersion.major=reply.get(1).asInt32();
137  protocolVersion.minor=reply.get(2).asInt32();
138  protocolVersion.tweak=reply.get(3).asInt32();
139 
140  //verify protocol
141  if (protocolVersion.major != PROTOCOL_VERSION_MAJOR) {
142  error = true;
143  }
144 
145  if (protocolVersion.minor != PROTOCOL_VERSION_MINOR) {
146  error = true;
147  }
148  }
149 
150  if (!error) {
151  return true;
152  }
153 
154  // protocol did not match
156  "Expecting protocol %d %d %d, but the device we are connecting to has protocol version %d %d %d",
160  protocolVersion.major,
161  protocolVersion.minor,
162  protocolVersion.tweak);
163 
164  bool ret;
165  if (ignore)
166  {
167  yCWarning(REMOTECONTROLBOARD, "Ignoring error but please update YARP or the remotecontrolboard implementation");
168  ret = true;
169  }
170  else
171  {
172  yCError(REMOTECONTROLBOARD, "Please update YARP or the remotecontrolboard implementation");
173  ret = false;
174  }
175 
176  return ret;
177 }
178 
180 {
181  remote = config.find("remote").asString();
182  local = config.find("local").asString();
183 
184  if (config.check("timeout"))
185  {
186  extendedIntputStatePort.setTimeout(config.find("timeout").asFloat64());
187  }
188  // check the Qos perefernces if available (local and remote)
189  yarp::os::QosStyle localQos;
190  if (config.check("local_qos")) {
191  Bottle& qos = config.findGroup("local_qos");
192  if (qos.check("thread_priority")) {
193  localQos.setThreadPriority(qos.find("thread_priority").asInt32());
194  }
195  if (qos.check("thread_policy")) {
196  localQos.setThreadPolicy(qos.find("thread_policy").asInt32());
197  }
198  if (qos.check("packet_priority")) {
199  localQos.setPacketPriority(qos.find("packet_priority").asString());
200  }
201  }
202 
203  yarp::os::QosStyle remoteQos;
204  if (config.check("remote_qos")) {
205  Bottle& qos = config.findGroup("remote_qos");
206  if (qos.check("thread_priority")) {
207  remoteQos.setThreadPriority(qos.find("thread_priority").asInt32());
208  }
209  if (qos.check("thread_policy")) {
210  remoteQos.setThreadPolicy(qos.find("thread_policy").asInt32());
211  }
212  if (qos.check("packet_priority")) {
213  remoteQos.setPacketPriority(qos.find("packet_priority").asString());
214  }
215  }
216 
217  bool writeStrict_isFound = config.check("writeStrict");
218  if(writeStrict_isFound)
219  {
220  Value &gotStrictVal = config.find("writeStrict");
221  if(gotStrictVal.asString() == "on")
222  {
223  writeStrict_singleJoint = true;
224  writeStrict_moreJoints = true;
225  yCInfo(REMOTECONTROLBOARD, "RemoteControlBoard is ENABLING the writeStrict option for all commands");
226  }
227  else if(gotStrictVal.asString() == "off")
228  {
229  writeStrict_singleJoint = false;
230  writeStrict_moreJoints = false;
231  yCInfo(REMOTECONTROLBOARD, "RemoteControlBoard is DISABLING the writeStrict opition for all commands");
232  } else {
233  yCError(REMOTECONTROLBOARD, "Found writeStrict opition with wrong value. Accepted options are 'on' or 'off'");
234  }
235  }
236 
237  if (local=="") {
238  yCError(REMOTECONTROLBOARD, "Problem connecting to remote controlboard, 'local' port prefix not given");
239  return false;
240  }
241 
242  if (remote=="") {
243  yCError(REMOTECONTROLBOARD, "Problem connecting to remote controlboard, 'remote' port name not given");
244  return false;
245  }
246 
247  std::string carrier =
248  config.check("carrier",
249  Value("udp"),
250  "default carrier for streaming robot state").asString();
251 
252  bool portProblem = false;
253  if (local != "") {
254  std::string s1 = local;
255  s1 += "/rpc:o";
256  if (!rpc_p.open(s1)) { portProblem = true; }
257  s1 = local;
258  s1 += "/command:o";
259  if (!command_p.open(s1)) { portProblem = true; }
260  s1 = local;
261  s1 += "/stateExt:i";
262  if (!extendedIntputStatePort.open(s1)) { portProblem = true; }
263  if (!portProblem)
264  {
265  extendedIntputStatePort.useCallback();
266  }
267  }
268 
269  bool connectionProblem = false;
270  if (remote != "" && !portProblem)
271  {
272  std::string s1 = remote;
273  s1 += "/rpc:i";
274  std::string s2 = local;
275  s2 += "/rpc:o";
276  bool ok = false;
277  // RPC port needs to be tcp, therefore no carrier option is added here
278  // ok=Network::connect(s2.c_str(), s1.c_str()); //This doesn't take into consideration possible YARP_PORT_PREFIX on local ports
279  // ok=Network::connect(rpc_p.getName(), s1.c_str()); //This should work also with YARP_PORT_PREFIX because getting back the name of the port will return the modified name
280  ok=rpc_p.addOutput(s1); //This works because we are manipulating only remote side and let yarp handle the local side
281  if (!ok) {
282  yCError(REMOTECONTROLBOARD, "Problem connecting to %s, is the remote device available?", s1.c_str());
283  connectionProblem = true;
284  }
285 
286  s1 = remote;
287  s1 += "/command:i";
288  s2 = local;
289  s2 += "/command:o";
290  //ok = Network::connect(s2.c_str(), s1.c_str(), carrier);
291  // ok=Network::connect(command_p.getName(), s1.c_str(), carrier); //doesn't take into consideration possible YARP_PORT_PREFIX on local ports
292  ok = command_p.addOutput(s1, carrier);
293  if (!ok) {
294  yCError(REMOTECONTROLBOARD, "Problem connecting to %s, is the remote device available?", s1.c_str());
295  connectionProblem = true;
296  }
297  // set the QoS preferences for the 'command' port
298  if (config.check("local_qos") || config.check("remote_qos")) {
299  NetworkBase::setConnectionQos(command_p.getName(), s1, localQos, remoteQos, false);
300  }
301 
302  s1 = remote;
303  s1 += "/stateExt:o";
304  s2 = local;
305  s2 += "/stateExt:i";
306  // not checking return value for now since it is wip (different machines can have different compilation flags
307  ok = Network::connect(s1, extendedIntputStatePort.getName(), carrier);
308  if (ok)
309  {
310  // set the QoS preferences for the 'state' port
311  if (config.check("local_qos") || config.check("remote_qos")) {
312  NetworkBase::setConnectionQos(s1, extendedIntputStatePort.getName(), remoteQos, localQos, false);
313  }
314  }
315  else
316  {
317  yCError(REMOTECONTROLBOARD, "Problem connecting to %s, is the remote device available?", s1.c_str());
318  connectionProblem = true;
319  }
320  }
321 
322  if (connectionProblem||portProblem) {
323 
324  rpc_p.close();
325  command_p.close();
326  extendedIntputStatePort.close();
327  return false;
328  }
329 
330  state_buffer.setStrict(false);
331  command_buffer.attach(command_p);
332 
333  if (!checkProtocolVersion(config.check("ignoreProtocolCheck")))
334  {
335  yCError(REMOTECONTROLBOARD) << "checkProtocolVersion failed";
336  command_buffer.detach();
337  rpc_p.close();
338  command_p.close();
339  extendedIntputStatePort.close();
340  return false;
341  }
342 
343  if (!isLive()) {
344  if (remote!="") {
345  yCError(REMOTECONTROLBOARD, "Problems with obtaining the number of controlled axes");
346  command_buffer.detach();
347  rpc_p.close();
348  command_p.close();
349  extendedIntputStatePort.close();
350  return false;
351  }
352  }
353 
354  if (config.check("diagnostic"))
355  {
356  diagnosticThread = new DiagnosticThread(DIAGNOSTIC_THREAD_PERIOD);
357  diagnosticThread->setOwner(&extendedIntputStatePort);
358  diagnosticThread->start();
359  } else {
360  diagnosticThread = nullptr;
361  }
362 
363  // allocate memory for helper struct
364  // single joint
365  last_singleJoint.jointPosition.resize(1);
366  last_singleJoint.jointVelocity.resize(1);
367  last_singleJoint.jointAcceleration.resize(1);
368  last_singleJoint.motorPosition.resize(1);
369  last_singleJoint.motorVelocity.resize(1);
370  last_singleJoint.motorAcceleration.resize(1);
371  last_singleJoint.torque.resize(1);
372  last_singleJoint.pwmDutycycle.resize(1);
373  last_singleJoint.current.resize(1);
374  last_singleJoint.controlMode.resize(1);
375  last_singleJoint.interactionMode.resize(1);
376 
377  // whole part (safe here because we already got the nj
378  last_wholePart.jointPosition.resize(nj);
379  last_wholePart.jointVelocity.resize(nj);
380  last_wholePart.jointAcceleration.resize(nj);
381  last_wholePart.motorPosition.resize(nj);
382  last_wholePart.motorVelocity.resize(nj);
383  last_wholePart.motorAcceleration.resize(nj);
384  last_wholePart.torque.resize(nj);
385  last_wholePart.current.resize(nj);
386  last_wholePart.pwmDutycycle.resize(nj);
387  last_wholePart.controlMode.resize(nj);
388  last_wholePart.interactionMode.resize(nj);
389  return true;
390 }
391 
393 {
394  if (diagnosticThread!=nullptr)
395  {
396  diagnosticThread->stop();
397  delete diagnosticThread;
398  }
399 
400  rpc_p.interrupt();
401  command_p.interrupt();
402  extendedIntputStatePort.interrupt();
403 
404  rpc_p.close();
405  command_p.close();
406  extendedIntputStatePort.close();
407  return true;
408 }
409 
410 // BEGIN Helpers functions
411 
413 {
414  Bottle cmd, response;
415  cmd.addVocab32(v);
416  bool ok=rpc_p.write(cmd, response);
417  if (CHECK_FAIL(ok, response)) {
418  return true;
419  }
420  return false;
421 }
422 
423 bool RemoteControlBoard::send2V(int v1, int v2)
424 {
425  Bottle cmd, response;
426  cmd.addVocab32(v1);
427  cmd.addVocab32(v2);
428  bool ok=rpc_p.write(cmd, response);
429  if (CHECK_FAIL(ok, response)) {
430  return true;
431  }
432  return false;
433 }
434 
435 bool RemoteControlBoard::send2V1I(int v1, int v2, int axis)
436 {
437  Bottle cmd, response;
438  cmd.addVocab32(v1);
439  cmd.addVocab32(v2);
440  cmd.addInt32(axis);
441  bool ok=rpc_p.write(cmd, response);
442  if (CHECK_FAIL(ok, response)) {
443  return true;
444  }
445  return false;
446 }
447 
448 bool RemoteControlBoard::send1V1I(int v, int axis)
449 {
450  Bottle cmd, response;
451  cmd.addVocab32(v);
452  cmd.addInt32(axis);
453  bool ok=rpc_p.write(cmd, response);
454  if (CHECK_FAIL(ok, response)) {
455  return true;
456  }
457  return false;
458 }
459 
460 bool RemoteControlBoard::send3V1I(int v1, int v2, int v3, int j)
461 {
462  Bottle cmd, response;
463  cmd.addVocab32(v1);
464  cmd.addVocab32(v2);
465  cmd.addVocab32(v3);
466  cmd.addInt32(j);
467  bool ok=rpc_p.write(cmd, response);
468  if (CHECK_FAIL(ok, response)) {
469  return true;
470  }
471  return false;
472 }
473 
475 {
476  Bottle cmd, response;
477  cmd.addVocab32(VOCAB_SET);
478  cmd.addVocab32(code);
479 
480  bool ok = rpc_p.write(cmd, response);
481  return CHECK_FAIL(ok, response);
482 }
483 
484 bool RemoteControlBoard::set1V2D(int code, double v)
485 {
486  Bottle cmd, response;
487  cmd.addVocab32(VOCAB_SET);
488  cmd.addVocab32(code);
489  cmd.addFloat64(v);
490 
491  bool ok = rpc_p.write(cmd, response);
492 
493  return CHECK_FAIL(ok, response);
494 }
495 
496 bool RemoteControlBoard::set1V1I(int code, int v)
497 {
498  Bottle cmd, response;
499  cmd.addVocab32(VOCAB_SET);
500  cmd.addVocab32(code);
501  cmd.addInt32(v);
502 
503  bool ok = rpc_p.write(cmd, response);
504 
505  return CHECK_FAIL(ok, response);
506 }
507 
508 bool RemoteControlBoard::get1V1D(int code, double& v) const
509 {
510  Bottle cmd;
511  Bottle response;
512  cmd.addVocab32(VOCAB_GET);
513  cmd.addVocab32(code);
514 
515  bool ok = rpc_p.write(cmd, response);
516 
517  if (CHECK_FAIL(ok, response)) {
518  // response should be [cmd] [name] value
519  v = response.get(2).asFloat64();
520 
521  getTimeStamp(response, lastStamp);
522  return true;
523  }
524 
525  return false;
526 }
527 
528 bool RemoteControlBoard::get1V1I(int code, int& v) const
529 {
530  Bottle cmd;
531  Bottle response;
532  cmd.addVocab32(VOCAB_GET);
533  cmd.addVocab32(code);
534 
535  bool ok = rpc_p.write(cmd, response);
536 
537  if (CHECK_FAIL(ok, response)) {
538  // response should be [cmd] [name] value
539  v = response.get(2).asInt32();
540 
541  getTimeStamp(response, lastStamp);
542  return true;
543  }
544 
545  return false;
546 }
547 
548 bool RemoteControlBoard::set1V1I1D(int code, int j, double val)
549 {
550  Bottle cmd, response;
551  cmd.addVocab32(VOCAB_SET);
552  cmd.addVocab32(code);
553  cmd.addInt32(j);
554  cmd.addFloat64(val);
555  bool ok = rpc_p.write(cmd, response);
556  return CHECK_FAIL(ok, response);
557 }
558 
559 bool RemoteControlBoard::set1V1I2D(int code, int j, double val1, double val2)
560 {
561  Bottle cmd, response;
562  cmd.addVocab32(VOCAB_SET);
563  cmd.addVocab32(code);
564  cmd.addInt32(j);
565  cmd.addFloat64(val1);
566  cmd.addFloat64(val2);
567 
568  bool ok = rpc_p.write(cmd, response);
569  return CHECK_FAIL(ok, response);
570 }
571 
572 bool RemoteControlBoard::set1VDA(int v, const double *val)
573 {
574  if (!isLive()) {
575  return false;
576  }
577  Bottle cmd, response;
578  cmd.addVocab32(VOCAB_SET);
579  cmd.addVocab32(v);
580  Bottle& l = cmd.addList();
581  for (size_t i = 0; i < nj; i++) {
582  l.addFloat64(val[i]);
583  }
584  bool ok = rpc_p.write(cmd, response);
585  return CHECK_FAIL(ok, response);
586 }
587 
588 bool RemoteControlBoard::set2V1DA(int v1, int v2, const double *val)
589 {
590  if (!isLive()) {
591  return false;
592  }
593  Bottle cmd, response;
594  cmd.addVocab32(VOCAB_SET);
595  cmd.addVocab32(v1);
596  cmd.addVocab32(v2);
597  Bottle& l = cmd.addList();
598  for (size_t i = 0; i < nj; i++) {
599  l.addFloat64(val[i]);
600  }
601  bool ok = rpc_p.write(cmd, response);
602  return CHECK_FAIL(ok, response);
603 }
604 
605 bool RemoteControlBoard::set2V2DA(int v1, int v2, const double *val1, const double *val2)
606 {
607  if (!isLive()) {
608  return false;
609  }
610  Bottle cmd, response;
611  cmd.addVocab32(VOCAB_SET);
612  cmd.addVocab32(v1);
613  cmd.addVocab32(v2);
614  Bottle& l1 = cmd.addList();
615  for (size_t i = 0; i < nj; i++) {
616  l1.addFloat64(val1[i]);
617  }
618  Bottle& l2 = cmd.addList();
619  for (size_t i = 0; i < nj; i++) {
620  l2.addFloat64(val2[i]);
621  }
622  bool ok = rpc_p.write(cmd, response);
623  return CHECK_FAIL(ok, response);
624 }
625 
626 bool RemoteControlBoard::set1V1I1IA1DA(int v, const int len, const int *val1, const double *val2)
627 {
628  if (!isLive()) {
629  return false;
630  }
631  Bottle cmd, response;
632  cmd.addVocab32(VOCAB_SET);
633  cmd.addVocab32(v);
634  cmd.addInt32(len);
635  int i;
636  Bottle& l1 = cmd.addList();
637  for (i = 0; i < len; i++) {
638  l1.addInt32(val1[i]);
639  }
640  Bottle& l2 = cmd.addList();
641  for (i = 0; i < len; i++) {
642  l2.addFloat64(val2[i]);
643  }
644  bool ok = rpc_p.write(cmd, response);
645  return CHECK_FAIL(ok, response);
646 }
647 
648 bool RemoteControlBoard::set2V1I1D(int v1, int v2, int axis, double val)
649 {
650  Bottle cmd, response;
651  cmd.addVocab32(VOCAB_SET);
652  cmd.addVocab32(v1);
653  cmd.addVocab32(v2);
654  cmd.addInt32(axis);
655  cmd.addFloat64(val);
656  bool ok = rpc_p.write(cmd, response);
657  return CHECK_FAIL(ok, response);
658 }
659 
660 bool RemoteControlBoard::setValWithPidType(int voc, PidControlTypeEnum type, int axis, double val)
661 {
662  if (!isLive()) {
663  return false;
664  }
665  Bottle cmd, response;
666  cmd.addVocab32(VOCAB_SET);
667  cmd.addVocab32(VOCAB_PID);
668  cmd.addVocab32(voc);
669  cmd.addVocab32(type);
670  cmd.addInt32(axis);
671  cmd.addFloat64(val);
672  bool ok = rpc_p.write(cmd, response);
673  return CHECK_FAIL(ok, response);
674 }
675 
676 bool RemoteControlBoard::setValWithPidType(int voc, PidControlTypeEnum type, const double* val_arr)
677 {
678  if (!isLive()) {
679  return false;
680  }
681  Bottle cmd, response;
682  cmd.addVocab32(VOCAB_SET);
683  cmd.addVocab32(VOCAB_PID);
684  cmd.addVocab32(voc);
685  cmd.addVocab32(type);
686  Bottle& l = cmd.addList();
687  for (size_t i = 0; i < nj; i++) {
688  l.addFloat64(val_arr[i]);
689  }
690  bool ok = rpc_p.write(cmd, response);
691  return CHECK_FAIL(ok, response);
692 }
693 
694 bool RemoteControlBoard::getValWithPidType(int voc, PidControlTypeEnum type, int j, double *val)
695 {
696  Bottle cmd, response;
697  cmd.addVocab32(VOCAB_GET);
698  cmd.addVocab32(VOCAB_PID);
699  cmd.addVocab32(voc);
700  cmd.addVocab32(type);
701  cmd.addInt32(j);
702  bool ok = rpc_p.write(cmd, response);
703 
704  if (CHECK_FAIL(ok, response))
705  {
706  *val = response.get(2).asFloat64();
707  getTimeStamp(response, lastStamp);
708  return true;
709  }
710  return false;
711 }
712 
714 {
715  if (!isLive()) {
716  return false;
717  }
718  Bottle cmd, response;
719  cmd.addVocab32(VOCAB_GET);
720  cmd.addVocab32(VOCAB_PID);
721  cmd.addVocab32(voc);
722  cmd.addVocab32(type);
723  bool ok = rpc_p.write(cmd, response);
724  if (CHECK_FAIL(ok, response))
725  {
726  Bottle* lp = response.get(2).asList();
727  if (lp == nullptr) {
728  return false;
729  }
730  Bottle& l = *lp;
731  yCAssert(REMOTECONTROLBOARD, nj == l.size());
732  for (size_t i = 0; i < nj; i++) {
733  val[i] = l.get(i).asFloat64();
734  }
735  getTimeStamp(response, lastStamp);
736  return true;
737  }
738  return false;
739 }
740 
741 bool RemoteControlBoard::set2V1I(int v1, int v2, int axis)
742 {
743  Bottle cmd, response;
744  cmd.addVocab32(VOCAB_SET);
745  cmd.addVocab32(v1);
746  cmd.addVocab32(v2);
747  cmd.addInt32(axis);
748  bool ok = rpc_p.write(cmd, response);
749  return CHECK_FAIL(ok, response);
750 }
751 
752 bool RemoteControlBoard::get1V1I1D(int v, int j, double *val)
753 {
754  Bottle cmd, response;
755  cmd.addVocab32(VOCAB_GET);
756  cmd.addVocab32(v);
757  cmd.addInt32(j);
758  bool ok = rpc_p.write(cmd, response);
759 
760  if (CHECK_FAIL(ok, response)) {
761  // ok
762  *val = response.get(2).asFloat64();
763 
764  getTimeStamp(response, lastStamp);
765  return true;
766  }
767  return false;
768 }
769 
770 bool RemoteControlBoard::get1V1I1I(int v, int j, int *val)
771 {
772  Bottle cmd, response;
773  cmd.addVocab32(VOCAB_GET);
774  cmd.addVocab32(v);
775  cmd.addInt32(j);
776  bool ok = rpc_p.write(cmd, response);
777  if (CHECK_FAIL(ok, response)) {
778  // ok
779  *val = response.get(2).asInt32();
780 
781  getTimeStamp(response, lastStamp);
782  return true;
783  }
784  return false;
785 }
786 
787 bool RemoteControlBoard::get2V1I1D(int v1, int v2, int j, double *val)
788 {
789  Bottle cmd, response;
790  cmd.addVocab32(VOCAB_GET);
791  cmd.addVocab32(v1);
792  cmd.addVocab32(v2);
793  cmd.addInt32(j);
794  bool ok = rpc_p.write(cmd, response);
795 
796  if (CHECK_FAIL(ok, response)) {
797  // ok
798  *val = response.get(2).asFloat64();
799 
800  getTimeStamp(response, lastStamp);
801  return true;
802  }
803  return false;
804 }
805 
806 bool RemoteControlBoard::get2V1I2D(int v1, int v2, int j, double *val1, double *val2)
807 {
808  Bottle cmd, response;
809  cmd.addVocab32(VOCAB_GET);
810  cmd.addVocab32(v1);
811  cmd.addVocab32(v2);
812  cmd.addInt32(j);
813  bool ok = rpc_p.write(cmd, response);
814  if (CHECK_FAIL(ok, response)) {
815  // ok
816  *val1 = response.get(2).asFloat64();
817  *val2 = response.get(3).asFloat64();
818 
819  getTimeStamp(response, lastStamp);
820  return true;
821  }
822  return false;
823 }
824 
825 bool RemoteControlBoard::get1V1I2D(int code, int axis, double *v1, double *v2)
826 {
827  Bottle cmd, response;
828  cmd.addVocab32(VOCAB_GET);
829  cmd.addVocab32(code);
830  cmd.addInt32(axis);
831 
832  bool ok = rpc_p.write(cmd, response);
833 
834  if (CHECK_FAIL(ok, response)) {
835  *v1 = response.get(2).asFloat64();
836  *v2 = response.get(3).asFloat64();
837  return true;
838  }
839  return false;
840 }
841 
842 bool RemoteControlBoard::get1V1I1B(int v, int j, bool &val)
843 {
844  Bottle cmd, response;
845  cmd.addVocab32(VOCAB_GET);
846  cmd.addVocab32(v);
847  cmd.addInt32(j);
848  bool ok = rpc_p.write(cmd, response);
849  if (CHECK_FAIL(ok, response)) {
850  val = (response.get(2).asInt32()!=0);
851  getTimeStamp(response, lastStamp);
852  return true;
853  }
854  return false;
855 }
856 
857 bool RemoteControlBoard::get1V1I1IA1B(int v, const int len, const int *val1, bool &retVal)
858 {
859  Bottle cmd, response;
860  cmd.addVocab32(VOCAB_GET);
861  cmd.addVocab32(v);
862  cmd.addInt32(len);
863  Bottle& l1 = cmd.addList();
864  for (int i = 0; i < len; i++) {
865  l1.addInt32(val1[i]);
866  }
867 
868  bool ok = rpc_p.write(cmd, response);
869 
870  if (CHECK_FAIL(ok, response)) {
871  retVal = (response.get(2).asInt32()!=0);
872  getTimeStamp(response, lastStamp);
873  return true;
874  }
875  return false;
876 }
877 
878 bool RemoteControlBoard::get2V1I1IA1DA(int v1, int v2, const int n_joints, const int *joints, double *retVals, std::string functionName)
879 {
880  Bottle cmd, response;
881  if (!isLive()) {
882  return false;
883  }
884 
885  cmd.addVocab32(VOCAB_GET);
886  cmd.addVocab32(v1);
887  cmd.addVocab32(v2);
888  cmd.addInt32(n_joints);
889 
890  Bottle& l1 = cmd.addList();
891  for (int i = 0; i < n_joints; i++) {
892  l1.addInt32(joints[i]);
893  }
894 
895  bool ok = rpc_p.write(cmd, response);
896 
897  if (CHECK_FAIL(ok, response))
898  {
899  int i;
900  Bottle& list = *(response.get(0).asList());
901  yCAssert(REMOTECONTROLBOARD, list.size() >= (size_t) n_joints)
902 
903  if (list.size() != (size_t )n_joints)
904  {
906  "%s length of response does not match: expected %d, received %zu\n ",
907  functionName.c_str(),
908  n_joints ,
909  list.size() );
910  return false;
911  }
912  else
913  {
914  for (i = 0; i < n_joints; i++)
915  {
916  retVals[i] = (double) list.get(i).asFloat64();
917  }
918  return true;
919  }
920  }
921  return false;
922 }
923 
924 bool RemoteControlBoard::get1V1B(int v, bool &val)
925 {
926  Bottle cmd, response;
927  cmd.addVocab32(VOCAB_GET);
928  cmd.addVocab32(v);
929  bool ok = rpc_p.write(cmd, response);
930  if (CHECK_FAIL(ok, response)) {
931  val = (response.get(2).asInt32()!=0);
932  getTimeStamp(response, lastStamp);
933  return true;
934  }
935  return false;
936 }
937 
938 bool RemoteControlBoard::get1VIA(int v, int *val)
939 {
940  if (!isLive()) {
941  return false;
942  }
943  Bottle cmd, response;
944  cmd.addVocab32(VOCAB_GET);
945  cmd.addVocab32(v);
946  bool ok = rpc_p.write(cmd, response);
947  if (CHECK_FAIL(ok, response)) {
948  Bottle* lp = response.get(2).asList();
949  if (lp == nullptr) {
950  return false;
951  }
952  Bottle& l = *lp;
953  yCAssert(REMOTECONTROLBOARD, nj == l.size());
954  for (size_t i = 0; i < nj; i++) {
955  val[i] = l.get(i).asInt32();
956  }
957 
958  getTimeStamp(response, lastStamp);
959 
960  return true;
961  }
962  return false;
963 }
964 
965 bool RemoteControlBoard::get1VDA(int v, double *val)
966 {
967  if (!isLive()) {
968  return false;
969  }
970  Bottle cmd, response;
971  cmd.addVocab32(VOCAB_GET);
972  cmd.addVocab32(v);
973  bool ok = rpc_p.write(cmd, response);
974  if (CHECK_FAIL(ok, response)) {
975  Bottle* lp = response.get(2).asList();
976  if (lp == nullptr) {
977  return false;
978  }
979  Bottle& l = *lp;
980  yCAssert(REMOTECONTROLBOARD, nj == l.size());
981  for (size_t i = 0; i < nj; i++) {
982  val[i] = l.get(i).asFloat64();
983  }
984 
985  getTimeStamp(response, lastStamp);
986 
987  return true;
988  }
989  return false;
990 }
991 
992 bool RemoteControlBoard::get1V1DA(int v1, double *val)
993 {
994  if (!isLive()) {
995  return false;
996  }
997  Bottle cmd, response;
998  cmd.addVocab32(VOCAB_GET);
999  cmd.addVocab32(v1);
1000  bool ok = rpc_p.write(cmd, response);
1001 
1002  if (CHECK_FAIL(ok, response)) {
1003  Bottle* lp = response.get(2).asList();
1004  if (lp == nullptr) {
1005  return false;
1006  }
1007  Bottle& l = *lp;
1008  yCAssert(REMOTECONTROLBOARD, nj == l.size());
1009  for (size_t i = 0; i < nj; i++) {
1010  val[i] = l.get(i).asFloat64();
1011  }
1012 
1013  getTimeStamp(response, lastStamp);
1014  return true;
1015  }
1016  return false;
1017 }
1018 
1019 bool RemoteControlBoard::get2V1DA(int v1, int v2, double *val)
1020 {
1021  if (!isLive()) {
1022  return false;
1023  }
1024  Bottle cmd, response;
1025  cmd.addVocab32(VOCAB_GET);
1026  cmd.addVocab32(v1);
1027  cmd.addVocab32(v2);
1028  bool ok = rpc_p.write(cmd, response);
1029 
1030  if (CHECK_FAIL(ok, response)) {
1031  Bottle* lp = response.get(2).asList();
1032  if (lp == nullptr) {
1033  return false;
1034  }
1035  Bottle& l = *lp;
1036  yCAssert(REMOTECONTROLBOARD, nj == l.size());
1037  for (size_t i = 0; i < nj; i++) {
1038  val[i] = l.get(i).asFloat64();
1039  }
1040 
1041  getTimeStamp(response, lastStamp);
1042  return true;
1043  }
1044  return false;
1045 }
1046 
1047 bool RemoteControlBoard::get2V2DA(int v1, int v2, double *val1, double *val2)
1048 {
1049  if (!isLive()) {
1050  return false;
1051  }
1052  Bottle cmd, response;
1053  cmd.addVocab32(VOCAB_GET);
1054  cmd.addVocab32(v1);
1055  cmd.addVocab32(v2);
1056  bool ok = rpc_p.write(cmd, response);
1057  if (CHECK_FAIL(ok, response)) {
1058  Bottle* lp1 = response.get(2).asList();
1059  if (lp1 == nullptr) {
1060  return false;
1061  }
1062  Bottle& l1 = *lp1;
1063  Bottle* lp2 = response.get(3).asList();
1064  if (lp2 == nullptr) {
1065  return false;
1066  }
1067  Bottle& l2 = *lp2;
1068 
1069  size_t nj1 = l1.size();
1070  size_t nj2 = l2.size();
1071  // yCAssert(REMOTECONTROLBOARD, nj == nj1);
1072  // yCAssert(REMOTECONTROLBOARD, nj == nj2);
1073 
1074  for (size_t i = 0; i < nj1; i++) {
1075  val1[i] = l1.get(i).asFloat64();
1076  }
1077  for (size_t i = 0; i < nj2; i++) {
1078  val2[i] = l2.get(i).asFloat64();
1079  }
1080 
1081  getTimeStamp(response, lastStamp);
1082  return true;
1083  }
1084  return false;
1085 }
1086 
1087 bool RemoteControlBoard::get1V1I1S(int code, int j, std::string &name)
1088 {
1089  Bottle cmd, response;
1090  cmd.addVocab32(VOCAB_GET);
1091  cmd.addVocab32(code);
1092  cmd.addInt32(j);
1093  bool ok = rpc_p.write(cmd, response);
1094 
1095  if (CHECK_FAIL(ok, response)) {
1096  name = response.get(2).asString();
1097  return true;
1098  }
1099  return false;
1100 }
1101 
1102 
1103 bool RemoteControlBoard::get1V1I1IA1DA(int v, const int len, const int *val1, double *val2)
1104 {
1105  if (!isLive()) {
1106  return false;
1107  }
1108 
1109  Bottle cmd, response;
1110  cmd.addVocab32(VOCAB_GET);
1111  cmd.addVocab32(v);
1112  cmd.addInt32(len);
1113  Bottle &l1 = cmd.addList();
1114  for (int i = 0; i < len; i++) {
1115  l1.addInt32(val1[i]);
1116  }
1117 
1118  bool ok = rpc_p.write(cmd, response);
1119 
1120  if (CHECK_FAIL(ok, response)) {
1121  Bottle* lp2 = response.get(2).asList();
1122  if (lp2 == nullptr) {
1123  return false;
1124  }
1125  Bottle& l2 = *lp2;
1126 
1127  size_t nj2 = l2.size();
1128  if(nj2 != (unsigned)len)
1129  {
1130  yCError(REMOTECONTROLBOARD, "received an answer with an unexpected number of entries!");
1131  return false;
1132  }
1133  for (size_t i = 0; i < nj2; i++) {
1134  val2[i] = l2.get(i).asFloat64();
1135  }
1136 
1137  getTimeStamp(response, lastStamp);
1138  return true;
1139  }
1140  return false;
1141 }
1142 
1143 // END Helpers functions
1144 
1146 {
1147  return get1V1I(VOCAB_AXES, *ax);
1148 }
1149 
1150 // BEGIN IPidControl
1151 
1152 bool RemoteControlBoard::setPid(const PidControlTypeEnum& pidtype, int j, const Pid &pid)
1153 {
1154  Bottle cmd, response;
1155  cmd.addVocab32(VOCAB_SET);
1156  cmd.addVocab32(VOCAB_PID);
1157  cmd.addVocab32(VOCAB_PID);
1158  cmd.addVocab32(pidtype);
1159  cmd.addInt32(j);
1160  Bottle& l = cmd.addList();
1161  l.addFloat64(pid.kp);
1162  l.addFloat64(pid.kd);
1163  l.addFloat64(pid.ki);
1164  l.addFloat64(pid.max_int);
1165  l.addFloat64(pid.max_output);
1166  l.addFloat64(pid.offset);
1167  l.addFloat64(pid.scale);
1168  l.addFloat64(pid.stiction_up_val);
1170  l.addFloat64(pid.kff);
1171  bool ok = rpc_p.write(cmd, response);
1172  return CHECK_FAIL(ok, response);
1173 }
1174 
1175 bool RemoteControlBoard::setPids(const PidControlTypeEnum& pidtype, const Pid *pids)
1176 {
1177  if (!isLive()) {
1178  return false;
1179  }
1180  Bottle cmd, response;
1181  cmd.addVocab32(VOCAB_SET);
1182  cmd.addVocab32(VOCAB_PID);
1183  cmd.addVocab32(VOCAB_PIDS);
1184  cmd.addVocab32(pidtype);
1185  Bottle& l = cmd.addList();
1186  for (size_t i = 0; i < nj; i++) {
1187  Bottle& m = l.addList();
1188  m.addFloat64(pids[i].kp);
1189  m.addFloat64(pids[i].kd);
1190  m.addFloat64(pids[i].ki);
1191  m.addFloat64(pids[i].max_int);
1192  m.addFloat64(pids[i].max_output);
1193  m.addFloat64(pids[i].offset);
1194  m.addFloat64(pids[i].scale);
1195  m.addFloat64(pids[i].stiction_up_val);
1196  m.addFloat64(pids[i].stiction_down_val);
1197  m.addFloat64(pids[i].kff);
1198  }
1199 
1200  bool ok = rpc_p.write(cmd, response);
1201  return CHECK_FAIL(ok, response);
1202 }
1203 
1204 bool RemoteControlBoard::setPidReference(const PidControlTypeEnum& pidtype, int j, double ref)
1205 {
1206  return setValWithPidType(VOCAB_REF, pidtype, j, ref);
1207 }
1208 
1209 bool RemoteControlBoard::setPidReferences(const PidControlTypeEnum& pidtype, const double *refs)
1210 {
1211  return setValWithPidType(VOCAB_REFS, pidtype, refs);
1212 }
1213 
1214 bool RemoteControlBoard::setPidErrorLimit(const PidControlTypeEnum& pidtype, int j, double limit)
1215 {
1216  return setValWithPidType(VOCAB_LIM, pidtype, j, limit);
1217 }
1218 
1219 bool RemoteControlBoard::setPidErrorLimits(const PidControlTypeEnum& pidtype, const double *limits)
1220 {
1221  return setValWithPidType(VOCAB_LIMS, pidtype, limits);
1222 }
1223 
1224 bool RemoteControlBoard::getPidError(const PidControlTypeEnum& pidtype, int j, double *err)
1225 {
1226  return getValWithPidType(VOCAB_ERR, pidtype, j, err);
1227 }
1228 
1229 bool RemoteControlBoard::getPidErrors(const PidControlTypeEnum& pidtype, double *errs)
1230 {
1231  return getValWithPidType(VOCAB_ERRS, pidtype, errs);
1232 }
1233 
1234 bool RemoteControlBoard::getPid(const PidControlTypeEnum& pidtype, int j, Pid *pid)
1235 {
1236  Bottle cmd, response;
1237  cmd.addVocab32(VOCAB_GET);
1238  cmd.addVocab32(VOCAB_PID);
1239  cmd.addVocab32(VOCAB_PID);
1240  cmd.addVocab32(pidtype);
1241  cmd.addInt32(j);
1242  bool ok = rpc_p.write(cmd, response);
1243  if (CHECK_FAIL(ok, response)) {
1244  Bottle* lp = response.get(2).asList();
1245  if (lp == nullptr) {
1246  return false;
1247  }
1248  Bottle& l = *lp;
1249  pid->kp = l.get(0).asFloat64();
1250  pid->kd = l.get(1).asFloat64();
1251  pid->ki = l.get(2).asFloat64();
1252  pid->max_int = l.get(3).asFloat64();
1253  pid->max_output = l.get(4).asFloat64();
1254  pid->offset = l.get(5).asFloat64();
1255  pid->scale = l.get(6).asFloat64();
1256  pid->stiction_up_val = l.get(7).asFloat64();
1257  pid->stiction_down_val = l.get(8).asFloat64();
1258  pid->kff = l.get(9).asFloat64();
1259  return true;
1260  }
1261  return false;
1262 }
1263 
1265 {
1266  if (!isLive()) {
1267  return false;
1268  }
1269  Bottle cmd, response;
1270  cmd.addVocab32(VOCAB_GET);
1271  cmd.addVocab32(VOCAB_PID);
1272  cmd.addVocab32(VOCAB_PIDS);
1273  cmd.addVocab32(pidtype);
1274  bool ok = rpc_p.write(cmd, response);
1275  if (CHECK_FAIL(ok, response))
1276  {
1277  Bottle* lp = response.get(2).asList();
1278  if (lp == nullptr) {
1279  return false;
1280  }
1281  Bottle& l = *lp;
1282  yCAssert(REMOTECONTROLBOARD, nj == l.size());
1283  for (size_t i = 0; i < nj; i++)
1284  {
1285  Bottle* mp = l.get(i).asList();
1286  if (mp == nullptr) {
1287  return false;
1288  }
1289  pids[i].kp = mp->get(0).asFloat64();
1290  pids[i].kd = mp->get(1).asFloat64();
1291  pids[i].ki = mp->get(2).asFloat64();
1292  pids[i].max_int = mp->get(3).asFloat64();
1293  pids[i].max_output = mp->get(4).asFloat64();
1294  pids[i].offset = mp->get(5).asFloat64();
1295  pids[i].scale = mp->get(6).asFloat64();
1296  pids[i].stiction_up_val = mp->get(7).asFloat64();
1297  pids[i].stiction_down_val = mp->get(8).asFloat64();
1298  pids[i].kff = mp->get(9).asFloat64();
1299  }
1300  return true;
1301  }
1302  return false;
1303 }
1304 
1305 bool RemoteControlBoard::getPidReference(const PidControlTypeEnum& pidtype, int j, double *ref)
1306 {
1307  return getValWithPidType(VOCAB_REF, pidtype, j, ref);
1308 }
1309 
1311 {
1312  return getValWithPidType(VOCAB_REFS, pidtype, refs);
1313 }
1314 
1315 bool RemoteControlBoard::getPidErrorLimit(const PidControlTypeEnum& pidtype, int j, double *limit)
1316 {
1317  return getValWithPidType(VOCAB_LIM, pidtype, j, limit);
1318 }
1319 
1320 bool RemoteControlBoard::getPidErrorLimits(const PidControlTypeEnum& pidtype, double *limits)
1321 {
1322  return getValWithPidType(VOCAB_LIMS, pidtype, limits);
1323 }
1324 
1326 {
1327  if (!isLive()) {
1328  return false;
1329  }
1330  Bottle cmd, response;
1331  cmd.addVocab32(VOCAB_SET);
1332  cmd.addVocab32(VOCAB_PID);
1333  cmd.addVocab32(VOCAB_RESET);
1334  cmd.addVocab32(pidtype);
1335  cmd.addInt32(j);
1336  bool ok = rpc_p.write(cmd, response);
1337  return CHECK_FAIL(ok, response);
1338 }
1339 
1341 {
1342  if (!isLive()) {
1343  return false;
1344  }
1345  Bottle cmd, response;
1346  cmd.addVocab32(VOCAB_SET);
1347  cmd.addVocab32(VOCAB_PID);
1349  cmd.addVocab32(pidtype);
1350  cmd.addInt32(j);
1351  bool ok = rpc_p.write(cmd, response);
1352  return CHECK_FAIL(ok, response);
1353 }
1354 
1356 {
1357  if (!isLive()) {
1358  return false;
1359  }
1360  Bottle cmd, response;
1361  cmd.addVocab32(VOCAB_SET);
1362  cmd.addVocab32(VOCAB_PID);
1363  cmd.addVocab32(VOCAB_ENABLE);
1364  cmd.addVocab32(pidtype);
1365  cmd.addInt32(j);
1366  bool ok = rpc_p.write(cmd, response);
1367  return CHECK_FAIL(ok, response);
1368 }
1369 
1370 bool RemoteControlBoard::isPidEnabled(const PidControlTypeEnum& pidtype, int j, bool* enabled)
1371 {
1372  Bottle cmd, response;
1373  cmd.addVocab32(VOCAB_GET);
1374  cmd.addVocab32(VOCAB_PID);
1375  cmd.addVocab32(VOCAB_ENABLE);
1376  cmd.addVocab32(pidtype);
1377  cmd.addInt32(j);
1378  bool ok = rpc_p.write(cmd, response);
1379  if (CHECK_FAIL(ok, response))
1380  {
1381  *enabled = response.get(2).asBool();
1382  return true;
1383  }
1384  return false;
1385 }
1386 
1387 bool RemoteControlBoard::getPidOutput(const PidControlTypeEnum& pidtype, int j, double *out)
1388 {
1389  return getValWithPidType(VOCAB_OUTPUT, pidtype, j, out);
1390 }
1391 
1392 bool RemoteControlBoard::getPidOutputs(const PidControlTypeEnum& pidtype, double *outs)
1393 {
1394  return getValWithPidType(VOCAB_OUTPUTS, pidtype, outs);
1395 }
1396 
1397 bool RemoteControlBoard::setPidOffset(const PidControlTypeEnum& pidtype, int j, double v)
1398 {
1399  return setValWithPidType(VOCAB_OFFSET, pidtype, j, v);
1400 }
1401 
1402 // END IPidControl
1403 
1404 // BEGIN IEncoder
1405 
1407 {
1408  return set1V1I(VOCAB_E_RESET, j);
1409 }
1410 
1412 {
1413  return set1V(VOCAB_E_RESETS);
1414 }
1415 
1416 bool RemoteControlBoard::setEncoder(int j, double val)
1417 {
1418  return set1V1I1D(VOCAB_ENCODER, j, val);
1419 }
1420 
1421 bool RemoteControlBoard::setEncoders(const double *vals)
1422 {
1423  return set1VDA(VOCAB_ENCODERS, vals);
1424 }
1425 
1426 bool RemoteControlBoard::getEncoder(int j, double *v)
1427 {
1428  double localArrivalTime = 0.0;
1429 
1430  extendedPortMutex.lock();
1431  bool ret = extendedIntputStatePort.getLastSingle(j, VOCAB_ENCODER, v, lastStamp, localArrivalTime);
1432  extendedPortMutex.unlock();
1433  return ret;
1434 }
1435 
1436 bool RemoteControlBoard::getEncoderTimed(int j, double *v, double *t)
1437 {
1438  double localArrivalTime = 0.0;
1439 
1440  extendedPortMutex.lock();
1441  bool ret = extendedIntputStatePort.getLastSingle(j, VOCAB_ENCODER, v, lastStamp, localArrivalTime);
1442  *t=lastStamp.getTime();
1443  extendedPortMutex.unlock();
1444  return ret;
1445 }
1446 
1448 {
1449  double localArrivalTime = 0.0;
1450 
1451  extendedPortMutex.lock();
1452  bool ret = extendedIntputStatePort.getLastVector(VOCAB_ENCODERS, encs, lastStamp, localArrivalTime);
1453  extendedPortMutex.unlock();
1454 
1455  return ret;
1456 }
1457 
1458 bool RemoteControlBoard::getEncodersTimed(double *encs, double *ts)
1459 {
1460  double localArrivalTime=0.0;
1461 
1462  extendedPortMutex.lock();
1463  bool ret = extendedIntputStatePort.getLastVector(VOCAB_ENCODERS, encs, lastStamp, localArrivalTime);
1464  std::fill_n(ts, nj, lastStamp.getTime());
1465  extendedPortMutex.unlock();
1466  return ret;
1467 }
1468 
1470 {
1471  double localArrivalTime=0.0;
1472 
1473  extendedPortMutex.lock();
1474  bool ret = extendedIntputStatePort.getLastSingle(j, VOCAB_ENCODER_SPEED, sp, lastStamp, localArrivalTime);
1475  extendedPortMutex.unlock();
1476  return ret;
1477 }
1478 
1480 {
1481  double localArrivalTime=0.0;
1482 
1483  extendedPortMutex.lock();
1484  bool ret = extendedIntputStatePort.getLastVector(VOCAB_ENCODER_SPEEDS, spds, lastStamp, localArrivalTime);
1485  extendedPortMutex.unlock();
1486  return ret;
1487 }
1488 
1490 {
1491  double localArrivalTime=0.0;
1492  extendedPortMutex.lock();
1493  bool ret = extendedIntputStatePort.getLastSingle(j, VOCAB_ENCODER_ACCELERATION, acc, lastStamp, localArrivalTime);
1494  extendedPortMutex.unlock();
1495  return ret;
1496 }
1497 
1499 {
1500  double localArrivalTime=0.0;
1501  extendedPortMutex.lock();
1502  bool ret = extendedIntputStatePort.getLastVector(VOCAB_ENCODER_ACCELERATIONS, accs, lastStamp, localArrivalTime);
1503  extendedPortMutex.unlock();
1504  return ret;
1505 }
1506 
1507 // END IEncoder
1508 
1509 // BEGIN IRemoteVariable
1510 
1512 {
1513  Bottle cmd, response;
1514  cmd.addVocab32(VOCAB_GET);
1517  cmd.addString(key);
1518  bool ok = rpc_p.write(cmd, response);
1519  if (CHECK_FAIL(ok, response))
1520  {
1521  val = *(response.get(2).asList());
1522  return true;
1523  }
1524  return false;
1525 }
1526 
1528 {
1529  Bottle cmd, response;
1530  cmd.addVocab32(VOCAB_SET);
1533  cmd.addString(key);
1534  cmd.append(val);
1535  //std::string s = cmd.toString();
1536  bool ok = rpc_p.write(cmd, response);
1537 
1538  return CHECK_FAIL(ok, response);
1539 }
1540 
1541 
1543 {
1544  Bottle cmd, response;
1545  cmd.addVocab32(VOCAB_GET);
1548  bool ok = rpc_p.write(cmd, response);
1549  //std::string s = response.toString();
1550  if (CHECK_FAIL(ok, response))
1551  {
1552  *listOfKeys = *(response.get(2).asList());
1553  //std::string s = listOfKeys->toString();
1554  return true;
1555  }
1556  return false;
1557 }
1558 
1559 // END IRemoteVariable
1560 
1561 // BEGIN IMotor
1562 
1564 {
1565  return get1V1I(VOCAB_MOTORS_NUMBER, *num);
1566 }
1567 
1568 bool RemoteControlBoard::getTemperature (int m, double* val)
1569 {
1570  return get1V1I1D(VOCAB_TEMPERATURE, m, val);
1571 }
1572 
1574 {
1575  return get1VDA(VOCAB_TEMPERATURES, vals);
1576 }
1577 
1579 {
1580  return get1V1I1D(VOCAB_TEMPERATURE_LIMIT, m, val);
1581 }
1582 
1583 bool RemoteControlBoard::setTemperatureLimit (int m, const double val)
1584 {
1585  return set1V1I1D(VOCAB_TEMPERATURE_LIMIT, m, val);
1586 }
1587 
1588 bool RemoteControlBoard::getGearboxRatio(int m, double* val)
1589 {
1590  return get1V1I1D(VOCAB_GEARBOX_RATIO, m, val);
1591 }
1592 
1593 bool RemoteControlBoard::setGearboxRatio(int m, const double val)
1594 {
1595  return set1V1I1D(VOCAB_GEARBOX_RATIO, m, val);
1596 }
1597 
1598 // END IMotor
1599 
1600 // BEGIN IMotorEncoder
1601 
1603 {
1604  return set1V1I(VOCAB_MOTOR_E_RESET, j);
1605 }
1606 
1608 {
1609  return set1V(VOCAB_MOTOR_E_RESETS);
1610 }
1611 
1612 bool RemoteControlBoard::setMotorEncoder(int j, const double val)
1613 {
1614  return set1V1I1D(VOCAB_MOTOR_ENCODER, j, val);
1615 }
1616 
1618 {
1619  return set1V1I1D(VOCAB_MOTOR_CPR, m, cpr);
1620 }
1621 
1623 {
1624  return get1V1I1D(VOCAB_MOTOR_CPR, m, cpr);
1625 }
1626 
1628 {
1629  return set1VDA(VOCAB_MOTOR_ENCODERS, vals);
1630 }
1631 
1633 {
1634  double localArrivalTime = 0.0;
1635 
1636  extendedPortMutex.lock();
1637  bool ret = extendedIntputStatePort.getLastSingle(j, VOCAB_MOTOR_ENCODER, v, lastStamp, localArrivalTime);
1638  extendedPortMutex.unlock();
1639  return ret;
1640 }
1641 
1642 bool RemoteControlBoard::getMotorEncoderTimed(int j, double *v, double *t)
1643 {
1644  double localArrivalTime = 0.0;
1645 
1646  extendedPortMutex.lock();
1647  bool ret = extendedIntputStatePort.getLastSingle(j, VOCAB_MOTOR_ENCODER, v, lastStamp, localArrivalTime);
1648  *t=lastStamp.getTime();
1649  extendedPortMutex.unlock();
1650  return ret;
1651 }
1652 
1654 {
1655  double localArrivalTime=0.0;
1656 
1657  extendedPortMutex.lock();
1658  bool ret = extendedIntputStatePort.getLastVector(VOCAB_MOTOR_ENCODERS, encs, lastStamp, localArrivalTime);
1659  extendedPortMutex.unlock();
1660 
1661  return ret;
1662 }
1663 
1664 bool RemoteControlBoard::getMotorEncodersTimed(double *encs, double *ts)
1665 {
1666  double localArrivalTime=0.0;
1667 
1668  extendedPortMutex.lock();
1669  bool ret = extendedIntputStatePort.getLastVector(VOCAB_MOTOR_ENCODERS, encs, lastStamp, localArrivalTime);
1670  std::fill_n(ts, nj, lastStamp.getTime());
1671  extendedPortMutex.unlock();
1672  return ret;
1673 }
1674 
1676 {
1677  double localArrivalTime=0.0;
1678  extendedPortMutex.lock();
1679  bool ret = extendedIntputStatePort.getLastSingle(j, VOCAB_MOTOR_ENCODER_SPEED, sp, lastStamp, localArrivalTime);
1680  extendedPortMutex.unlock();
1681  return ret;
1682 }
1683 
1685 {
1686  double localArrivalTime=0.0;
1687  extendedPortMutex.lock();
1688  bool ret = extendedIntputStatePort.getLastVector(VOCAB_MOTOR_ENCODER_SPEEDS, spds, lastStamp, localArrivalTime);
1689  extendedPortMutex.unlock();
1690  return ret;
1691 }
1692 
1694 {
1695  double localArrivalTime=0.0;
1696  extendedPortMutex.lock();
1697  bool ret = extendedIntputStatePort.getLastSingle(j, VOCAB_MOTOR_ENCODER_ACCELERATION, acc, lastStamp, localArrivalTime);
1698  extendedPortMutex.unlock();
1699  return ret;
1700 }
1701 
1703 {
1704  double localArrivalTime=0.0;
1705  extendedPortMutex.lock();
1706  bool ret = extendedIntputStatePort.getLastVector(VOCAB_MOTOR_ENCODER_SPEEDS, accs, lastStamp, localArrivalTime);
1707  extendedPortMutex.unlock();
1708  return ret;
1709 }
1710 
1712 {
1713  return get1V1I(VOCAB_MOTOR_ENCODER_NUMBER, *num);
1714 }
1715 
1716 // END IMotorEncoder
1717 
1718 // BEGIN IPreciselyTimed
1719 
1725 {
1726  Stamp ret;
1727 // mutex.lock();
1728  ret = lastStamp;
1729 // mutex.unlock();
1730  return ret;
1731 }
1732 
1733 // END IPreciselyTimed
1734 
1735 // BEGIN IPositionControl
1736 
1737 bool RemoteControlBoard::positionMove(int j, double ref)
1738 {
1739  return set1V1I1D(VOCAB_POSITION_MOVE, j, ref);
1740 }
1741 
1742 bool RemoteControlBoard::positionMove(const int n_joint, const int *joints, const double *refs)
1743 {
1744  return set1V1I1IA1DA(VOCAB_POSITION_MOVE_GROUP, n_joint, joints, refs);
1745 }
1746 
1747 bool RemoteControlBoard::positionMove(const double *refs)
1748 {
1749  return set1VDA(VOCAB_POSITION_MOVES, refs);
1750 }
1751 
1752 bool RemoteControlBoard::getTargetPosition(const int joint, double *ref)
1753 {
1754  return get1V1I1D(VOCAB_POSITION_MOVE, joint, ref);
1755 }
1756 
1758 {
1759  return get1V1DA(VOCAB_POSITION_MOVES, refs);
1760 }
1761 
1762 bool RemoteControlBoard::getTargetPositions(const int n_joint, const int *joints, double *refs)
1763 {
1764  return get1V1I1IA1DA(VOCAB_POSITION_MOVE_GROUP, n_joint, joints, refs);
1765 }
1766 
1767 bool RemoteControlBoard::relativeMove(int j, double delta)
1768 {
1769  return set1V1I1D(VOCAB_RELATIVE_MOVE, j, delta);
1770 }
1771 
1772 bool RemoteControlBoard::relativeMove(const int n_joint, const int *joints, const double *refs)
1773 {
1774  return set1V1I1IA1DA(VOCAB_RELATIVE_MOVE_GROUP, n_joint, joints, refs);
1775 }
1776 
1777 bool RemoteControlBoard::relativeMove(const double *deltas)
1778 {
1779  return set1VDA(VOCAB_RELATIVE_MOVES, deltas);
1780 }
1781 
1783 {
1784  return get1V1I1B(VOCAB_MOTION_DONE, j, *flag);
1785 }
1786 
1787 bool RemoteControlBoard::checkMotionDone(const int n_joint, const int *joints, bool *flag)
1788 {
1789  return get1V1I1IA1B(VOCAB_MOTION_DONE_GROUP, n_joint, joints, *flag);
1790 }
1791 
1793 {
1794  return get1V1B(VOCAB_MOTION_DONES, *flag);
1795 }
1796 
1797 bool RemoteControlBoard::setRefSpeed(int j, double sp)
1798 {
1799  return set1V1I1D(VOCAB_REF_SPEED, j, sp);
1800 }
1801 
1802 bool RemoteControlBoard::setRefSpeeds(const int n_joint, const int *joints, const double *spds)
1803 {
1804  return set1V1I1IA1DA(VOCAB_REF_SPEED_GROUP, n_joint, joints, spds);
1805 }
1806 
1807 bool RemoteControlBoard::setRefSpeeds(const double *spds)
1808 {
1809  return set1VDA(VOCAB_REF_SPEEDS, spds);
1810 }
1811 
1813 {
1814  return set1V1I1D(VOCAB_REF_ACCELERATION, j, acc);
1815 }
1816 
1817 bool RemoteControlBoard::setRefAccelerations(const int n_joint, const int *joints, const double *accs)
1818 {
1819  return set1V1I1IA1DA(VOCAB_REF_ACCELERATION_GROUP, n_joint, joints, accs);
1820 }
1821 
1823 {
1824  return set1VDA(VOCAB_REF_ACCELERATIONS, accs);
1825 }
1826 
1827 bool RemoteControlBoard::getRefSpeed(int j, double *ref)
1828 {
1829  return get1V1I1D(VOCAB_REF_SPEED, j, ref);
1830 }
1831 
1832 bool RemoteControlBoard::getRefSpeeds(const int n_joint, const int *joints, double *spds)
1833 {
1834  return get1V1I1IA1DA(VOCAB_REF_SPEED_GROUP, n_joint, joints, spds);
1835 }
1836 
1838 {
1839  return get1VDA(VOCAB_REF_SPEEDS, spds);
1840 }
1841 
1843 {
1844  return get1V1I1D(VOCAB_REF_ACCELERATION, j, acc);
1845 }
1846 
1847 bool RemoteControlBoard::getRefAccelerations(const int n_joint, const int *joints, double *accs)
1848 {
1849  return get1V1I1IA1DA(VOCAB_REF_ACCELERATION_GROUP, n_joint, joints, accs);
1850 }
1851 
1853 {
1854  return get1VDA(VOCAB_REF_ACCELERATIONS, accs);
1855 }
1856 
1858 {
1859  return set1V1I(VOCAB_STOP, j);
1860 }
1861 
1862 bool RemoteControlBoard::stop(const int len, const int *val1)
1863 {
1864  if (!isLive()) {
1865  return false;
1866  }
1867  Bottle cmd, response;
1868  cmd.addVocab32(VOCAB_SET);
1870  cmd.addInt32(len);
1871  int i;
1872  Bottle& l1 = cmd.addList();
1873  for (i = 0; i < len; i++) {
1874  l1.addInt32(val1[i]);
1875  }
1876 
1877  bool ok = rpc_p.write(cmd, response);
1878  return CHECK_FAIL(ok, response);
1879 }
1880 
1882 {
1883  return set1V(VOCAB_STOPS);
1884 }
1885 
1886 // END IPositionControl
1887 
1888 // BEGIN IVelocityControl
1889 
1891 {
1892  // return set1V1I1D(VOCAB_VELOCITY_MOVE, j, v);
1893  if (!isLive()) {
1894  return false;
1895  }
1896  CommandMessage& c = command_buffer.get();
1897  c.head.clear();
1898  c.head.addVocab32(VOCAB_VELOCITY_MOVE);
1899  c.head.addInt32(j);
1900  c.body.resize(1);
1901  memcpy(&(c.body[0]), &v, sizeof(double));
1902  command_buffer.write(writeStrict_singleJoint);
1903  return true;
1904 }
1905 
1907 {
1908  if (!isLive()) {
1909  return false;
1910  }
1911  CommandMessage& c = command_buffer.get();
1912  c.head.clear();
1913  c.head.addVocab32(VOCAB_VELOCITY_MOVES);
1914  c.body.resize(nj);
1915  memcpy(&(c.body[0]), v, sizeof(double)*nj);
1916  command_buffer.write(writeStrict_moreJoints);
1917  return true;
1918 }
1919 
1920 // END IVelocityControl
1921 
1922 // BEGIN IAmplifierControl
1923 
1925 {
1926  return set1V1I(VOCAB_AMP_ENABLE, j);
1927 }
1928 
1930 {
1931  return set1V1I(VOCAB_AMP_DISABLE, j);
1932 }
1933 
1935 {
1936  return get1VIA(VOCAB_AMP_STATUS, st);
1937 }
1938 
1940 {
1941  return get1V1I1I(VOCAB_AMP_STATUS_SINGLE, j, st);
1942 }
1943 
1945 {
1946  return set1V1I1D(VOCAB_AMP_MAXCURRENT, j, v);
1947 }
1948 
1950 {
1951  return get1V1I1D(VOCAB_AMP_MAXCURRENT, j, v);
1952 }
1953 
1955 {
1956  return get1V1I1D(VOCAB_AMP_NOMINAL_CURRENT, m, val);
1957 }
1958 
1959 bool RemoteControlBoard::setNominalCurrent(int m, const double val)
1960 {
1961  return set1V1I1D(VOCAB_AMP_NOMINAL_CURRENT, m, val);
1962 }
1963 
1964 bool RemoteControlBoard::getPeakCurrent(int m, double *val)
1965 {
1966  return get1V1I1D(VOCAB_AMP_PEAK_CURRENT, m, val);
1967 }
1968 
1969 bool RemoteControlBoard::setPeakCurrent(int m, const double val)
1970 {
1971  return set1V1I1D(VOCAB_AMP_PEAK_CURRENT, m, val);
1972 }
1973 
1974 bool RemoteControlBoard::getPWM(int m, double* val)
1975 {
1976  double localArrivalTime = 0.0;
1977  extendedPortMutex.lock();
1978  bool ret = extendedIntputStatePort.getLastSingle(m, VOCAB_PWMCONTROL_PWM_OUTPUT, val, lastStamp, localArrivalTime);
1979  extendedPortMutex.unlock();
1980  return ret;
1981 }
1982 
1983 bool RemoteControlBoard::getPWMLimit(int m, double* val)
1984 {
1985  return get1V1I1D(VOCAB_AMP_PWM_LIMIT, m, val);
1986 }
1987 
1988 bool RemoteControlBoard::setPWMLimit(int m, const double val)
1989 {
1990  return set1V1I1D(VOCAB_AMP_PWM_LIMIT, m, val);
1991 }
1992 
1994 {
1995  return get1V1I1D(VOCAB_AMP_VOLTAGE_SUPPLY, m, val);
1996 }
1997 
1998 // END IAmplifierControl
1999 
2000 // BEGIN IControlLimits
2001 
2002 bool RemoteControlBoard::setLimits(int axis, double min, double max)
2003 {
2004  return set1V1I2D(VOCAB_LIMITS, axis, min, max);
2005 }
2006 
2007 bool RemoteControlBoard::getLimits(int axis, double *min, double *max)
2008 {
2009  return get1V1I2D(VOCAB_LIMITS, axis, min, max);
2010 }
2011 
2012 bool RemoteControlBoard::setVelLimits(int axis, double min, double max)
2013 {
2014  return set1V1I2D(VOCAB_VEL_LIMITS, axis, min, max);
2015 }
2016 
2017 bool RemoteControlBoard::getVelLimits(int axis, double *min, double *max)
2018 {
2019  return get1V1I2D(VOCAB_VEL_LIMITS, axis, min, max);
2020 }
2021 
2022 // END IControlLimits
2023 
2024 // BEGIN IAxisInfo
2025 
2026 bool RemoteControlBoard::getAxisName(int j, std::string& name)
2027 {
2028  return get1V1I1S(VOCAB_INFO_NAME, j, name);
2029 }
2030 
2032 {
2033  return get1V1I1I(VOCAB_INFO_TYPE, j, (int*)&type);
2034 }
2035 
2036 // END IAxisInfo
2037 
2038 // BEGIN IControlCalibration
2040 {
2041  return send1V(VOCAB_CALIBRATE);
2042 }
2043 
2045 {
2046  return send1V(VOCAB_ABORTCALIB);
2047 }
2048 
2050 {
2051  return send1V(VOCAB_ABORTPARK);
2052 }
2053 
2055 {
2056  return send1V(VOCAB_PARK);
2057 }
2058 
2059 bool RemoteControlBoard::calibrateAxisWithParams(int j, unsigned int ui, double v1, double v2, double v3)
2060 {
2061  Bottle cmd, response;
2062 
2064  cmd.addInt32(j);
2065  cmd.addInt32(ui);
2066  cmd.addFloat64(v1);
2067  cmd.addFloat64(v2);
2068  cmd.addFloat64(v3);
2069 
2070  bool ok = rpc_p.write(cmd, response);
2071 
2072  if (CHECK_FAIL(ok, response)) {
2073  return true;
2074  }
2075  return false;
2076 }
2077 
2079 {
2080  Bottle cmd, response;
2081 
2083  cmd.addInt32(j);
2084  cmd.addInt32(params.type);
2085  cmd.addFloat64(params.param1);
2086  cmd.addFloat64(params.param2);
2087  cmd.addFloat64(params.param3);
2088  cmd.addFloat64(params.param4);
2089 
2090  bool ok = rpc_p.write(cmd, response);
2091 
2092  if (CHECK_FAIL(ok, response)) {
2093  return true;
2094  }
2095  return false;
2096 }
2097 
2099 {
2100  return send1V1I(VOCAB_CALIBRATE_DONE, j);
2101 }
2102 
2103 // END IControlCalibration
2104 
2105 // BEGIN ITorqueControl
2106 
2108 {
2109  return get2V1I1D(VOCAB_TORQUE, VOCAB_REF, j, t);
2110 }
2111 
2113 {
2114  return get2V1DA(VOCAB_TORQUE, VOCAB_REFS, t);
2115 }
2116 
2118 {
2119  //Now we use streaming instead of rpc
2120  //return set2V1DA(VOCAB_TORQUE, VOCAB_REFS, t);
2121  if (!isLive()) {
2122  return false;
2123  }
2124  CommandMessage& c = command_buffer.get();
2125  c.head.clear();
2126  c.head.addVocab32(VOCAB_TORQUES_DIRECTS);
2127 
2128  c.body.resize(nj);
2129 
2130  memcpy(c.body.data(), t, sizeof(double) * nj);
2131 
2132  command_buffer.write(writeStrict_moreJoints);
2133  return true;
2134 }
2135 
2137 {
2138  //return set2V1I1D(VOCAB_TORQUE, VOCAB_REF, j, v);
2139  // use the streaming port!
2140  if (!isLive()) {
2141  return false;
2142  }
2143  CommandMessage& c = command_buffer.get();
2144  c.head.clear();
2145  // in streaming port only SET command can be sent, so it is implicit
2146  c.head.addVocab32(VOCAB_TORQUES_DIRECT);
2147  c.head.addInt32(j);
2148 
2149  c.body.clear();
2150  c.body.resize(1);
2151  c.body[0] = v;
2152  command_buffer.write(writeStrict_singleJoint);
2153  return true;
2154 }
2155 
2156 bool RemoteControlBoard::setRefTorques(const int n_joint, const int *joints, const double *t)
2157 {
2158  //return set2V1I1D(VOCAB_TORQUE, VOCAB_REF, j, v);
2159  // use the streaming port!
2160  if (!isLive()) {
2161  return false;
2162  }
2163  CommandMessage& c = command_buffer.get();
2164  c.head.clear();
2165  // in streaming port only SET command can be sent, so it is implicit
2166  c.head.addVocab32(VOCAB_TORQUES_DIRECT_GROUP);
2167  c.head.addInt32(n_joint);
2168  Bottle &jointList = c.head.addList();
2169  for (int i = 0; i < n_joint; i++) {
2170  jointList.addInt32(joints[i]);
2171  }
2172  c.body.resize(n_joint);
2173  memcpy(&(c.body[0]), t, sizeof(double)*n_joint);
2174  command_buffer.write(writeStrict_moreJoints);
2175  return true;
2176 }
2177 
2179 {
2180  Bottle cmd, response;
2181  cmd.addVocab32(VOCAB_SET);
2182  cmd.addVocab32(VOCAB_TORQUE);
2184  cmd.addInt32(j);
2185  Bottle& b = cmd.addList();
2186  b.addFloat64(params.bemf);
2187  b.addFloat64(params.bemf_scale);
2188  b.addFloat64(params.ktau);
2189  b.addFloat64(params.ktau_scale);
2190  bool ok = rpc_p.write(cmd, response);
2191  return CHECK_FAIL(ok, response);
2192 }
2193 
2195 {
2196  Bottle cmd, response;
2197  cmd.addVocab32(VOCAB_GET);
2198  cmd.addVocab32(VOCAB_TORQUE);
2200  cmd.addInt32(j);
2201  bool ok = rpc_p.write(cmd, response);
2202  if (CHECK_FAIL(ok, response)) {
2203  Bottle* lp = response.get(2).asList();
2204  if (lp == nullptr) {
2205  return false;
2206  }
2207  Bottle& l = *lp;
2208  if (l.size() != 4)
2209  {
2210  yCError(REMOTECONTROLBOARD, "getMotorTorqueParams return value not understood, size!=4");
2211  return false;
2212  }
2213  params->bemf = l.get(0).asFloat64();
2214  params->bemf_scale = l.get(1).asFloat64();
2215  params->ktau = l.get(2).asFloat64();
2216  params->ktau_scale = l.get(3).asFloat64();
2217  return true;
2218  }
2219  return false;
2220 }
2221 
2222 bool RemoteControlBoard::getTorque(int j, double *t)
2223 {
2224  double localArrivalTime=0.0;
2225  extendedPortMutex.lock();
2226  bool ret = extendedIntputStatePort.getLastSingle(j, VOCAB_TRQ, t, lastStamp, localArrivalTime);
2227  extendedPortMutex.unlock();
2228  return ret;
2229 }
2230 
2232 {
2233  double localArrivalTime=0.0;
2234  extendedPortMutex.lock();
2235  bool ret = extendedIntputStatePort.getLastVector(VOCAB_TRQS, t, lastStamp, localArrivalTime);
2236  extendedPortMutex.unlock();
2237  return ret;
2238 }
2239 
2240 bool RemoteControlBoard::getTorqueRange(int j, double *min, double* max)
2241 {
2242  return get2V1I2D(VOCAB_TORQUE, VOCAB_RANGE, j, min, max);
2243 }
2244 
2245 bool RemoteControlBoard::getTorqueRanges(double *min, double *max)
2246 {
2247  return get2V2DA(VOCAB_TORQUE, VOCAB_RANGES, min, max);
2248 }
2249 
2250 // END ITorqueControl
2251 
2252 // BEGIN IImpedanceControl
2253 
2254 bool RemoteControlBoard::getImpedance(int j, double *stiffness, double *damping)
2255 {
2256  Bottle cmd, response;
2257  cmd.addVocab32(VOCAB_GET);
2260  cmd.addInt32(j);
2261  bool ok = rpc_p.write(cmd, response);
2262  if (CHECK_FAIL(ok, response)) {
2263  Bottle* lp = response.get(2).asList();
2264  if (lp == nullptr) {
2265  return false;
2266  }
2267  Bottle& l = *lp;
2268  *stiffness = l.get(0).asFloat64();
2269  *damping = l.get(1).asFloat64();
2270  return true;
2271  }
2272  return false;
2273 }
2274 
2275 bool RemoteControlBoard::getImpedanceOffset(int j, double *offset)
2276 {
2277  Bottle cmd, response;
2278  cmd.addVocab32(VOCAB_GET);
2281  cmd.addInt32(j);
2282  bool ok = rpc_p.write(cmd, response);
2283  if (CHECK_FAIL(ok, response)) {
2284  Bottle* lp = response.get(2).asList();
2285  if (lp == nullptr) {
2286  return false;
2287  }
2288  Bottle& l = *lp;
2289  *offset = l.get(0).asFloat64();
2290  return true;
2291  }
2292  return false;
2293 }
2294 
2295 bool RemoteControlBoard::setImpedance(int j, double stiffness, double damping)
2296 {
2297  Bottle cmd, response;
2298  cmd.addVocab32(VOCAB_SET);
2301  cmd.addInt32(j);
2302 
2303  Bottle& b = cmd.addList();
2304  b.addFloat64(stiffness);
2305  b.addFloat64(damping);
2306 
2307  bool ok = rpc_p.write(cmd, response);
2308  return CHECK_FAIL(ok, response);
2309 }
2310 
2311 bool RemoteControlBoard::setImpedanceOffset(int j, double offset)
2312 {
2313  Bottle cmd, response;
2314  cmd.addVocab32(VOCAB_SET);
2317  cmd.addInt32(j);
2318 
2319  Bottle& b = cmd.addList();
2320  b.addFloat64(offset);
2321 
2322  bool ok = rpc_p.write(cmd, response);
2323  return CHECK_FAIL(ok, response);
2324 }
2325 
2326 bool RemoteControlBoard::getCurrentImpedanceLimit(int j, double *min_stiff, double *max_stiff, double *min_damp, double *max_damp)
2327 {
2328  Bottle cmd, response;
2329  cmd.addVocab32(VOCAB_GET);
2331  cmd.addVocab32(VOCAB_LIMITS);
2332  cmd.addInt32(j);
2333  bool ok = rpc_p.write(cmd, response);
2334  if (CHECK_FAIL(ok, response)) {
2335  Bottle* lp = response.get(2).asList();
2336  if (lp == nullptr) {
2337  return false;
2338  }
2339  Bottle& l = *lp;
2340  *min_stiff = l.get(0).asFloat64();
2341  *max_stiff = l.get(1).asFloat64();
2342  *min_damp = l.get(2).asFloat64();
2343  *max_damp = l.get(3).asFloat64();
2344  return true;
2345  }
2346  return false;
2347 }
2348 
2349 // END IImpedanceControl
2350 
2351 // BEGIN IControlMode
2352 
2354 {
2355  double localArrivalTime=0.0;
2356  extendedPortMutex.lock();
2357  bool ret = extendedIntputStatePort.getLastSingle(j, VOCAB_CM_CONTROL_MODE, mode, lastStamp, localArrivalTime);
2358  extendedPortMutex.unlock();
2359  return ret;
2360 }
2361 
2363 {
2364  double localArrivalTime=0.0;
2365  extendedPortMutex.lock();
2366  bool ret = extendedIntputStatePort.getLastVector(VOCAB_CM_CONTROL_MODES, modes, lastStamp, localArrivalTime);
2367  extendedPortMutex.unlock();
2368  return ret;
2369 }
2370 
2371 bool RemoteControlBoard::getControlModes(const int n_joint, const int *joints, int *modes)
2372 {
2373  double localArrivalTime=0.0;
2374 
2375  extendedPortMutex.lock();
2376  bool ret = extendedIntputStatePort.getLastVector(VOCAB_CM_CONTROL_MODES, last_wholePart.controlMode.data(), lastStamp, localArrivalTime);
2377  if(ret)
2378  {
2379  for (int i = 0; i < n_joint; i++) {
2380  modes[i] = last_wholePart.controlMode[joints[i]];
2381  }
2382  } else {
2383  ret = false;
2384  }
2385 
2386  extendedPortMutex.unlock();
2387  return ret;
2388 }
2389 
2390 bool RemoteControlBoard::setControlMode(const int j, const int mode)
2391 {
2392  if (!isLive()) {
2393  return false;
2394  }
2395  Bottle cmd, response;
2396  cmd.addVocab32(VOCAB_SET);
2399  cmd.addInt32(j);
2400  cmd.addVocab32(mode);
2401 
2402  bool ok = rpc_p.write(cmd, response);
2403  return CHECK_FAIL(ok, response);
2404 }
2405 
2406 bool RemoteControlBoard::setControlModes(const int n_joint, const int *joints, int *modes)
2407 {
2408  if (!isLive()) {
2409  return false;
2410  }
2411  Bottle cmd, response;
2412  cmd.addVocab32(VOCAB_SET);
2415  cmd.addInt32(n_joint);
2416  int i;
2417  Bottle& l1 = cmd.addList();
2418  for (i = 0; i < n_joint; i++) {
2419  l1.addInt32(joints[i]);
2420  }
2421 
2422  Bottle& l2 = cmd.addList();
2423  for (i = 0; i < n_joint; i++) {
2424  l2.addVocab32(modes[i]);
2425  }
2426 
2427  bool ok = rpc_p.write(cmd, response);
2428  return CHECK_FAIL(ok, response);
2429 }
2430 
2432 {
2433  if (!isLive()) {
2434  return false;
2435  }
2436  Bottle cmd, response;
2437  cmd.addVocab32(VOCAB_SET);
2440 
2441  Bottle& l2 = cmd.addList();
2442  for (size_t i = 0; i < nj; i++) {
2443  l2.addVocab32(modes[i]);
2444  }
2445 
2446  bool ok = rpc_p.write(cmd, response);
2447  return CHECK_FAIL(ok, response);
2448 }
2449 
2450 // END IControlMode
2451 
2452 // BEGIN IPositionDirect
2453 
2454 bool RemoteControlBoard::setPosition(int j, double ref)
2455 {
2456  if (!isLive()) {
2457  return false;
2458  }
2459  CommandMessage& c = command_buffer.get();
2460  c.head.clear();
2461  c.head.addVocab32(VOCAB_POSITION_DIRECT);
2462  c.head.addInt32(j);
2463  c.body.resize(1);
2464  memcpy(&(c.body[0]), &ref, sizeof(double));
2465  command_buffer.write(writeStrict_singleJoint);
2466  return true;
2467 }
2468 
2469 bool RemoteControlBoard::setPositions(const int n_joint, const int *joints, const double *refs)
2470 {
2471  if (!isLive()) {
2472  return false;
2473  }
2474  CommandMessage& c = command_buffer.get();
2475  c.head.clear();
2476  c.head.addVocab32(VOCAB_POSITION_DIRECT_GROUP);
2477  c.head.addInt32(n_joint);
2478  Bottle &jointList = c.head.addList();
2479  for (int i = 0; i < n_joint; i++) {
2480  jointList.addInt32(joints[i]);
2481  }
2482  c.body.resize(n_joint);
2483  memcpy(&(c.body[0]), refs, sizeof(double)*n_joint);
2484  command_buffer.write(writeStrict_moreJoints);
2485  return true;
2486 }
2487 
2488 bool RemoteControlBoard::setPositions(const double *refs)
2489 {
2490  if (!isLive()) {
2491  return false;
2492  }
2493  CommandMessage& c = command_buffer.get();
2494  c.head.clear();
2495  c.head.addVocab32(VOCAB_POSITION_DIRECTS);
2496  c.body.resize(nj);
2497  memcpy(&(c.body[0]), refs, sizeof(double)*nj);
2498  command_buffer.write(writeStrict_moreJoints);
2499  return true;
2500 }
2501 
2502 bool RemoteControlBoard::getRefPosition(const int joint, double* ref)
2503 {
2504  return get1V1I1D(VOCAB_POSITION_DIRECT, joint, ref);
2505 }
2506 
2508 {
2509  return get1V1DA(VOCAB_POSITION_DIRECTS, refs);
2510 }
2511 
2512 bool RemoteControlBoard::getRefPositions(const int n_joint, const int* joints, double* refs)
2513 {
2514  return get1V1I1IA1DA(VOCAB_POSITION_DIRECT_GROUP, n_joint, joints, refs);
2515 }
2516 
2517 // END IPositionDirect
2518 
2519 // BEGIN IVelocityControl
2520 
2521 bool RemoteControlBoard::velocityMove(const int n_joint, const int *joints, const double *spds)
2522 {
2523  // streaming port
2524  if (!isLive()) {
2525  return false;
2526  }
2527  CommandMessage& c = command_buffer.get();
2528  c.head.clear();
2529  c.head.addVocab32(VOCAB_VELOCITY_MOVE_GROUP);
2530  c.head.addInt32(n_joint);
2531  Bottle &jointList = c.head.addList();
2532  for (int i = 0; i < n_joint; i++) {
2533  jointList.addInt32(joints[i]);
2534  }
2535  c.body.resize(n_joint);
2536  memcpy(&(c.body[0]), spds, sizeof(double)*n_joint);
2537  command_buffer.write(writeStrict_moreJoints);
2538  return true;
2539 }
2540 
2541 bool RemoteControlBoard::getRefVelocity(const int joint, double* vel)
2542 {
2543  return get1V1I1D(VOCAB_VELOCITY_MOVE, joint, vel);
2544 }
2545 
2547 {
2548  return get1VDA(VOCAB_VELOCITY_MOVES, vels);
2549 }
2550 
2551 bool RemoteControlBoard::getRefVelocities(const int n_joint, const int* joints, double* vels)
2552 {
2553  return get1V1I1IA1DA(VOCAB_VELOCITY_MOVE_GROUP, n_joint, joints, vels);
2554 }
2555 
2556 // END IVelocityControl
2557 
2558 // BEGIN IInteractionMode
2559 
2561 {
2562  double localArrivalTime=0.0;
2563  extendedPortMutex.lock();
2564  bool ret = extendedIntputStatePort.getLastSingle(axis, VOCAB_INTERACTION_MODE, (int*) mode, lastStamp, localArrivalTime);
2565  extendedPortMutex.unlock();
2566  return ret;
2567 }
2568 
2570 {
2571  double localArrivalTime=0.0;
2572 
2573  extendedPortMutex.lock();
2574  bool ret = extendedIntputStatePort.getLastVector(VOCAB_INTERACTION_MODES, last_wholePart.interactionMode.data(), lastStamp, localArrivalTime);
2575  if(ret)
2576  {
2577  for (int i = 0; i < n_joints; i++) {
2578  modes[i] = (yarp::dev::InteractionModeEnum)last_wholePart.interactionMode[joints[i]];
2579  }
2580  } else {
2581  ret = false;
2582  }
2583 
2584  extendedPortMutex.unlock();
2585  return ret;
2586 }
2587 
2589 {
2590  double localArrivalTime=0.0;
2591  extendedPortMutex.lock();
2592  bool ret = extendedIntputStatePort.getLastVector(VOCAB_INTERACTION_MODES, (int*) modes, lastStamp, localArrivalTime);
2593  extendedPortMutex.unlock();
2594  return ret;
2595 }
2596 
2598 {
2599  Bottle cmd, response;
2600  if (!isLive()) {
2601  return false;
2602  }
2603 
2604  cmd.addVocab32(VOCAB_SET);
2607  cmd.addInt32(axis);
2608  cmd.addVocab32(mode);
2609 
2610  bool ok = rpc_p.write(cmd, response);
2611  return CHECK_FAIL(ok, response);
2612 }
2613 
2615 {
2616  Bottle cmd, response;
2617  if (!isLive()) {
2618  return false;
2619  }
2620 
2621  cmd.addVocab32(VOCAB_SET);
2624  cmd.addInt32(n_joints);
2625 
2626  Bottle& l1 = cmd.addList();
2627  for (int i = 0; i < n_joints; i++) {
2628  l1.addInt32(joints[i]);
2629  }
2630 
2631  Bottle& l2 = cmd.addList();
2632  for (int i = 0; i < n_joints; i++)
2633  {
2634  l2.addVocab32(modes[i]);
2635  }
2636  bool ok = rpc_p.write(cmd, response);
2637  return CHECK_FAIL(ok, response);
2638 }
2639 
2641 {
2642  Bottle cmd, response;
2643  if (!isLive()) {
2644  return false;
2645  }
2646 
2647  cmd.addVocab32(VOCAB_SET);
2650 
2651  Bottle& l1 = cmd.addList();
2652  for (size_t i = 0; i < nj; i++) {
2653  l1.addVocab32(modes[i]);
2654  }
2655 
2656  bool ok = rpc_p.write(cmd, response);
2657  return CHECK_FAIL(ok, response);
2658 }
2659 
2660 // END IInteractionMode
2661 
2662 // BEGIN IRemoteCalibrator
2663 
2665 {
2666  Bottle cmd, response;
2667  cmd.addVocab32(VOCAB_GET);
2670  bool ok = rpc_p.write(cmd, response);
2671  if(ok) {
2672  *isCalib = response.get(2).asInt32()!=0;
2673  } else {
2674  *isCalib = false;
2675  }
2676  return CHECK_FAIL(ok, response);
2677 }
2678 
2680 {
2682 }
2683 
2685 {
2686  Bottle cmd, response;
2687  cmd.addVocab32(VOCAB_SET);
2690  bool ok = rpc_p.write(cmd, response);
2691  return CHECK_FAIL(ok, response);
2692 }
2693 
2695 {
2697 }
2698 
2700 {
2701  Bottle cmd, response;
2702  cmd.addVocab32(VOCAB_SET);
2705  bool ok = rpc_p.write(cmd, response);
2706  yCDebug(REMOTECONTROLBOARD) << "Sent homing whole part message";
2707  return CHECK_FAIL(ok, response);
2708 }
2709 
2711 {
2713 }
2714 
2716 {
2717  Bottle cmd, response;
2718  cmd.addVocab32(VOCAB_SET);
2721  bool ok = rpc_p.write(cmd, response);
2722  return CHECK_FAIL(ok, response);
2723 }
2724 
2726 {
2727  Bottle cmd, response;
2728  cmd.addVocab32(VOCAB_SET);
2731  bool ok = rpc_p.write(cmd, response);
2732  return CHECK_FAIL(ok, response);
2733 }
2734 
2736 {
2737  Bottle cmd, response;
2738  cmd.addVocab32(VOCAB_SET);
2741  bool ok = rpc_p.write(cmd, response);
2742  return CHECK_FAIL(ok, response);
2743 }
2744 
2745 // END IRemoteCalibrator
2746 
2747 // BEGIN ICurrentControl
2748 
2750 {
2752 }
2753 
2755 {
2756  return get2V1I1D(VOCAB_CURRENTCONTROL_INTERFACE, VOCAB_CURRENT_REF, j, t);
2757 }
2758 
2759 bool RemoteControlBoard::setRefCurrents(const double *refs)
2760 {
2761  if (!isLive()) {
2762  return false;
2763  }
2764  CommandMessage& c = command_buffer.get();
2765  c.head.clear();
2766  c.head.addVocab32(VOCAB_CURRENTCONTROL_INTERFACE);
2767  c.head.addVocab32(VOCAB_CURRENT_REFS);
2768  c.body.resize(nj);
2769  memcpy(&(c.body[0]), refs, sizeof(double)*nj);
2770  command_buffer.write(writeStrict_moreJoints);
2771  return true;
2772 }
2773 
2774 bool RemoteControlBoard::setRefCurrent(int j, double ref)
2775 {
2776  if (!isLive()) {
2777  return false;
2778  }
2779  CommandMessage& c = command_buffer.get();
2780  c.head.clear();
2781  c.head.addVocab32(VOCAB_CURRENTCONTROL_INTERFACE);
2782  c.head.addVocab32(VOCAB_CURRENT_REF);
2783  c.head.addInt32(j);
2784  c.body.resize(1);
2785  memcpy(&(c.body[0]), &ref, sizeof(double));
2786  command_buffer.write(writeStrict_singleJoint);
2787  return true;
2788 }
2789 
2790 bool RemoteControlBoard::setRefCurrents(const int n_joint, const int *joints, const double *refs)
2791 {
2792  if (!isLive()) {
2793  return false;
2794  }
2795  CommandMessage& c = command_buffer.get();
2796  c.head.clear();
2797  c.head.addVocab32(VOCAB_CURRENTCONTROL_INTERFACE);
2798  c.head.addVocab32(VOCAB_CURRENT_REF_GROUP);
2799  c.head.addInt32(n_joint);
2800  Bottle &jointList = c.head.addList();
2801  for (int i = 0; i < n_joint; i++) {
2802  jointList.addInt32(joints[i]);
2803  }
2804  c.body.resize(n_joint);
2805  memcpy(&(c.body[0]), refs, sizeof(double)*n_joint);
2806  command_buffer.write(writeStrict_moreJoints);
2807  return true;
2808 }
2809 
2811 {
2812  double localArrivalTime=0.0;
2813  extendedPortMutex.lock();
2814  bool ret = extendedIntputStatePort.getLastVector(VOCAB_AMP_CURRENTS, vals, lastStamp, localArrivalTime);
2815  extendedPortMutex.unlock();
2816  return ret;
2817 }
2818 
2819 bool RemoteControlBoard::getCurrent(int j, double *val)
2820 {
2821  double localArrivalTime=0.0;
2822  extendedPortMutex.lock();
2823  bool ret = extendedIntputStatePort.getLastSingle(j, VOCAB_AMP_CURRENT, val, lastStamp, localArrivalTime);
2824  extendedPortMutex.unlock();
2825  return ret;
2826 }
2827 
2828 bool RemoteControlBoard::getCurrentRange(int j, double *min, double *max)
2829 {
2830  return get2V1I2D(VOCAB_CURRENTCONTROL_INTERFACE, VOCAB_CURRENT_RANGE, j, min, max);
2831 }
2832 
2833 bool RemoteControlBoard::getCurrentRanges(double *min, double *max)
2834 {
2835  return get2V2DA(VOCAB_CURRENTCONTROL_INTERFACE, VOCAB_CURRENT_RANGES, min, max);
2836 }
2837 
2838 // END ICurrentControl
2839 
2840 // BEGIN IPWMControl
2842 {
2843  // using the streaming port
2844  if (!isLive()) {
2845  return false;
2846  }
2847  CommandMessage& c = command_buffer.get();
2848  c.head.clear();
2849  // in streaming port only SET command can be sent, so it is implicit
2850  c.head.addVocab32(VOCAB_PWMCONTROL_INTERFACE);
2851  c.head.addVocab32(VOCAB_PWMCONTROL_REF_PWM);
2852  c.head.addInt32(j);
2853 
2854  c.body.clear();
2855  c.body.resize(1);
2856  c.body[0] = v;
2857  command_buffer.write(writeStrict_singleJoint);
2858  return true;
2859 }
2860 
2862 {
2863  // using the streaming port
2864  if (!isLive()) {
2865  return false;
2866  }
2867  CommandMessage& c = command_buffer.get();
2868  c.head.clear();
2869  c.head.addVocab32(VOCAB_PWMCONTROL_INTERFACE);
2870  c.head.addVocab32(VOCAB_PWMCONTROL_REF_PWMS);
2871 
2872  c.body.resize(nj);
2873 
2874  memcpy(&(c.body[0]), v, sizeof(double)*nj);
2875 
2876  command_buffer.write(writeStrict_moreJoints);
2877 
2878  return true;
2879 }
2880 
2881 bool RemoteControlBoard::getRefDutyCycle(int j, double *ref)
2882 {
2883  Bottle cmd, response;
2884  cmd.addVocab32(VOCAB_GET);
2887  cmd.addInt32(j);
2888  response.clear();
2889 
2890  bool ok = rpc_p.write(cmd, response);
2891 
2892  if (CHECK_FAIL(ok, response))
2893  {
2894  // ok
2895  *ref = response.get(2).asFloat64();
2896 
2897  getTimeStamp(response, lastStamp);
2898  return true;
2899  } else {
2900  return false;
2901  }
2902 }
2903 
2905 {
2906  return get2V1DA(VOCAB_PWMCONTROL_INTERFACE, VOCAB_PWMCONTROL_REF_PWMS, refs);
2907 }
2908 
2909 bool RemoteControlBoard::getDutyCycle(int j, double *out)
2910 {
2911  double localArrivalTime = 0.0;
2912  extendedPortMutex.lock();
2913  bool ret = extendedIntputStatePort.getLastSingle(j, VOCAB_PWMCONTROL_PWM_OUTPUT, out, lastStamp, localArrivalTime);
2914  extendedPortMutex.unlock();
2915  return ret;
2916 }
2917 
2919 {
2920  double localArrivalTime = 0.0;
2921  extendedPortMutex.lock();
2922  bool ret = extendedIntputStatePort.getLastVector(VOCAB_PWMCONTROL_PWM_OUTPUTS, outs, lastStamp, localArrivalTime);
2923  extendedPortMutex.unlock();
2924  return ret;
2925 }
2926 // END IPWMControl
constexpr yarp::conf::vocab32_t VOCAB_PARK_SINGLE_JOINT
constexpr yarp::conf::vocab32_t VOCAB_REMOTE_CALIBRATOR_INTERFACE
constexpr yarp::conf::vocab32_t VOCAB_HOMING_WHOLE_PART
constexpr yarp::conf::vocab32_t VOCAB_PARK_WHOLE_PART
constexpr yarp::conf::vocab32_t VOCAB_QUIT_PARK
constexpr yarp::conf::vocab32_t VOCAB_IS_CALIBRATOR_PRESENT
constexpr yarp::conf::vocab32_t VOCAB_CALIBRATE_SINGLE_JOINT
constexpr yarp::conf::vocab32_t VOCAB_HOMING_SINGLE_JOINT
constexpr yarp::conf::vocab32_t VOCAB_CALIBRATE_WHOLE_PART
constexpr yarp::conf::vocab32_t VOCAB_QUIT_CALIBRATE
define control board standard interfaces
constexpr yarp::conf::vocab32_t VOCAB_TIMESTAMP
constexpr yarp::conf::vocab32_t VOCAB_VELOCITY_MOVE
constexpr yarp::conf::vocab32_t VOCAB_REF_SPEED
constexpr yarp::conf::vocab32_t VOCAB_STOPS
constexpr yarp::conf::vocab32_t VOCAB_MOTION_DONE
constexpr yarp::conf::vocab32_t VOCAB_STOP
constexpr yarp::conf::vocab32_t VOCAB_REF_ACCELERATIONS
constexpr yarp::conf::vocab32_t VOCAB_MOTION_DONES
constexpr yarp::conf::vocab32_t VOCAB_PROTOCOL_VERSION
constexpr yarp::conf::vocab32_t VOCAB_POSITION_MOVE
constexpr yarp::conf::vocab32_t VOCAB_REF_ACCELERATION
constexpr yarp::conf::vocab32_t VOCAB_VELOCITY_MOVES
constexpr yarp::conf::vocab32_t VOCAB_RELATIVE_MOVE
constexpr yarp::conf::vocab32_t VOCAB_REF_SPEEDS
constexpr yarp::conf::vocab32_t VOCAB_RELATIVE_MOVES
constexpr yarp::conf::vocab32_t VOCAB_POSITION_MOVES
constexpr int PROTOCOL_VERSION_TWEAK
constexpr int PROTOCOL_VERSION_MINOR
constexpr int PROTOCOL_VERSION_MAJOR
float t
constexpr yarp::conf::vocab32_t VOCAB_LIM
Definition: GenericVocabs.h:27
constexpr yarp::conf::vocab32_t VOCAB_OUTPUTS
Definition: GenericVocabs.h:33
constexpr yarp::conf::vocab32_t VOCAB_ENABLE
Definition: GenericVocabs.h:31
constexpr yarp::conf::vocab32_t VOCAB_DISABLE
Definition: GenericVocabs.h:30
constexpr yarp::conf::vocab32_t VOCAB_REF
Definition: GenericVocabs.h:24
constexpr yarp::conf::vocab32_t VOCAB_ERRS
Definition: GenericVocabs.h:18
constexpr yarp::conf::vocab32_t VOCAB_GET
Definition: GenericVocabs.h:13
constexpr yarp::conf::vocab32_t VOCAB_OUTPUT
Definition: GenericVocabs.h:32
constexpr yarp::conf::vocab32_t VOCAB_ERR
Definition: GenericVocabs.h:17
constexpr yarp::conf::vocab32_t VOCAB_REFS
Definition: GenericVocabs.h:25
constexpr yarp::conf::vocab32_t VOCAB_RESET
Definition: GenericVocabs.h:29
constexpr yarp::conf::vocab32_t VOCAB_AXES
Definition: GenericVocabs.h:36
constexpr yarp::conf::vocab32_t VOCAB_SET
Definition: GenericVocabs.h:12
constexpr yarp::conf::vocab32_t VOCAB_OFFSET
Definition: GenericVocabs.h:23
constexpr yarp::conf::vocab32_t VOCAB_LIMS
Definition: GenericVocabs.h:28
constexpr yarp::conf::vocab32_t VOCAB_AMP_DISABLE
constexpr yarp::conf::vocab32_t VOCAB_AMP_PEAK_CURRENT
constexpr yarp::conf::vocab32_t VOCAB_AMP_ENABLE
constexpr yarp::conf::vocab32_t VOCAB_AMP_VOLTAGE_SUPPLY
constexpr yarp::conf::vocab32_t VOCAB_AMP_CURRENT
constexpr yarp::conf::vocab32_t VOCAB_AMP_MAXCURRENT
constexpr yarp::conf::vocab32_t VOCAB_AMP_STATUS_SINGLE
constexpr yarp::conf::vocab32_t VOCAB_AMP_STATUS
constexpr yarp::conf::vocab32_t VOCAB_AMP_NOMINAL_CURRENT
constexpr yarp::conf::vocab32_t VOCAB_AMP_CURRENTS
constexpr yarp::conf::vocab32_t VOCAB_AMP_PWM_LIMIT
constexpr yarp::conf::vocab32_t VOCAB_INFO_TYPE
Definition: IAxisInfo.h:90
constexpr yarp::conf::vocab32_t VOCAB_INFO_NAME
Definition: IAxisInfo.h:89
constexpr yarp::conf::vocab32_t VOCAB_ABORTCALIB
constexpr yarp::conf::vocab32_t VOCAB_CALIBRATE_JOINT_PARAMS
constexpr yarp::conf::vocab32_t VOCAB_ABORTPARK
constexpr yarp::conf::vocab32_t VOCAB_CALIBRATE_DONE
constexpr yarp::conf::vocab32_t VOCAB_CALIBRATE_JOINT
constexpr yarp::conf::vocab32_t VOCAB_CALIBRATE
constexpr yarp::conf::vocab32_t VOCAB_PARK
constexpr yarp::conf::vocab32_t VOCAB_LIMITS
constexpr yarp::conf::vocab32_t VOCAB_VEL_LIMITS
constexpr yarp::conf::vocab32_t VOCAB_CM_CONTROL_MODE_GROUP
Definition: IControlMode.h:118
constexpr yarp::conf::vocab32_t VOCAB_CM_CONTROL_MODES
Definition: IControlMode.h:119
constexpr yarp::conf::vocab32_t VOCAB_CM_CONTROL_MODE
Definition: IControlMode.h:117
constexpr yarp::conf::vocab32_t VOCAB_ICONTROLMODE
Definition: IControlMode.h:115
constexpr yarp::conf::vocab32_t VOCAB_CURRENT_REF_GROUP
constexpr yarp::conf::vocab32_t VOCAB_CURRENT_REFS
constexpr yarp::conf::vocab32_t VOCAB_CURRENT_RANGE
constexpr yarp::conf::vocab32_t VOCAB_CURRENTCONTROL_INTERFACE
constexpr yarp::conf::vocab32_t VOCAB_CURRENT_REF
constexpr yarp::conf::vocab32_t VOCAB_CURRENT_RANGES
constexpr yarp::conf::vocab32_t VOCAB_E_RESET
Definition: IEncoders.h:206
constexpr yarp::conf::vocab32_t VOCAB_ENCODER_ACCELERATIONS
Definition: IEncoders.h:215
constexpr yarp::conf::vocab32_t VOCAB_ENCODER
Definition: IEncoders.h:208
constexpr yarp::conf::vocab32_t VOCAB_ENCODER_SPEEDS
Definition: IEncoders.h:213
constexpr yarp::conf::vocab32_t VOCAB_E_RESETS
Definition: IEncoders.h:207
constexpr yarp::conf::vocab32_t VOCAB_ENCODER_SPEED
Definition: IEncoders.h:212
constexpr yarp::conf::vocab32_t VOCAB_ENCODER_ACCELERATION
Definition: IEncoders.h:214
constexpr yarp::conf::vocab32_t VOCAB_ENCODERS
Definition: IEncoders.h:209
constexpr yarp::conf::vocab32_t VOCAB_IMPEDANCE
constexpr yarp::conf::vocab32_t VOCAB_INTERACTION_MODES
constexpr yarp::conf::vocab32_t VOCAB_INTERACTION_MODE_GROUP
constexpr yarp::conf::vocab32_t VOCAB_INTERACTION_MODE
constexpr yarp::conf::vocab32_t VOCAB_INTERFACE_INTERACTION_MODE
constexpr yarp::conf::vocab32_t VOCAB_MOTOR_ENCODER_SPEED
constexpr yarp::conf::vocab32_t VOCAB_MOTOR_ENCODER_ACCELERATION
constexpr yarp::conf::vocab32_t VOCAB_MOTOR_ENCODER
constexpr yarp::conf::vocab32_t VOCAB_MOTOR_ENCODER_SPEEDS
constexpr yarp::conf::vocab32_t VOCAB_MOTOR_ENCODER_NUMBER
constexpr yarp::conf::vocab32_t VOCAB_MOTOR_E_RESETS
constexpr yarp::conf::vocab32_t VOCAB_MOTOR_E_RESET
constexpr yarp::conf::vocab32_t VOCAB_MOTOR_ENCODERS
constexpr yarp::conf::vocab32_t VOCAB_MOTOR_CPR
constexpr yarp::conf::vocab32_t VOCAB_TEMPERATURES
Definition: IMotor.h:164
constexpr yarp::conf::vocab32_t VOCAB_TEMPERATURE_LIMIT
Definition: IMotor.h:165
constexpr yarp::conf::vocab32_t VOCAB_TEMPERATURE
Definition: IMotor.h:162
constexpr yarp::conf::vocab32_t VOCAB_GEARBOX_RATIO
Definition: IMotor.h:163
constexpr yarp::conf::vocab32_t VOCAB_MOTORS_NUMBER
Definition: IMotor.h:161
constexpr yarp::conf::vocab32_t VOCAB_PWMCONTROL_INTERFACE
Definition: IPWMControl.h:141
constexpr yarp::conf::vocab32_t VOCAB_PWMCONTROL_PWM_OUTPUTS
Definition: IPWMControl.h:146
constexpr yarp::conf::vocab32_t VOCAB_PWMCONTROL_REF_PWMS
Definition: IPWMControl.h:144
constexpr yarp::conf::vocab32_t VOCAB_PWMCONTROL_REF_PWM
Definition: IPWMControl.h:143
constexpr yarp::conf::vocab32_t VOCAB_PWMCONTROL_PWM_OUTPUT
Definition: IPWMControl.h:145
constexpr yarp::conf::vocab32_t VOCAB_PIDS
Definition: IPidControl.h:382
constexpr yarp::conf::vocab32_t VOCAB_PID
Definition: IPidControl.h:381
constexpr yarp::conf::vocab32_t VOCAB_REF_ACCELERATION_GROUP
constexpr yarp::conf::vocab32_t VOCAB_STOP_GROUP
constexpr yarp::conf::vocab32_t VOCAB_RELATIVE_MOVE_GROUP
constexpr yarp::conf::vocab32_t VOCAB_POSITION_MOVE_GROUP
constexpr yarp::conf::vocab32_t VOCAB_MOTION_DONE_GROUP
constexpr yarp::conf::vocab32_t VOCAB_REF_SPEED_GROUP
constexpr yarp::conf::vocab32_t VOCAB_POSITION_DIRECTS
constexpr yarp::conf::vocab32_t VOCAB_POSITION_DIRECT
constexpr yarp::conf::vocab32_t VOCAB_POSITION_DIRECT_GROUP
constexpr yarp::conf::vocab32_t VOCAB_LIST_VARIABLES
constexpr yarp::conf::vocab32_t VOCAB_VARIABLE
constexpr yarp::conf::vocab32_t VOCAB_REMOTE_VARIABILE_INTERFACE
constexpr yarp::conf::vocab32_t VOCAB_TORQUE
constexpr yarp::conf::vocab32_t VOCAB_TRQ
constexpr yarp::conf::vocab32_t VOCAB_TORQUES_DIRECTS
constexpr yarp::conf::vocab32_t VOCAB_TRQS
constexpr yarp::conf::vocab32_t VOCAB_RANGE
constexpr yarp::conf::vocab32_t VOCAB_IMP_OFFSET
constexpr yarp::conf::vocab32_t VOCAB_MOTOR_PARAMS
constexpr yarp::conf::vocab32_t VOCAB_IMP_PARAM
constexpr yarp::conf::vocab32_t VOCAB_TORQUES_DIRECT_GROUP
constexpr yarp::conf::vocab32_t VOCAB_RANGES
constexpr yarp::conf::vocab32_t VOCAB_TORQUES_DIRECT
constexpr yarp::conf::vocab32_t VOCAB_VELOCITY_MOVE_GROUP
bool ret
const yarp::os::LogComponent & REMOTECONTROLBOARD()
void run() override
Loop function.
void setOwner(StateExtendedInputPort *o)
bool setPidReferences(const PidControlTypeEnum &pidtype, const double *refs) override
Set the controller reference, multiple axes.
bool getTorques(double *t) override
Get the value of the torque for all joints (this is the feedback if you have torque sensors).
bool relativeMove(int j, double delta) override
Set relative position.
bool getCurrentImpedanceLimit(int j, double *min_stiff, double *max_stiff, double *min_damp, double *max_damp) override
Get the current impedandance limits for a specific joint.
bool getRefSpeeds(const int n_joint, const int *joints, double *spds) override
Get reference speed of all joints.
bool get1V1I1B(int v, int j, bool &val)
Helper method used to get a double value from the remote peer.
bool quitCalibrate() override
quitCalibrate: interrupt the calibration procedure
bool getRefPositions(double *refs) override
Get the last position reference for all axes.
bool get1V1I1IA1B(int v, const int len, const int *val1, bool &retVal)
bool open(Searchable &config) override
Open the DeviceDriver.
bool getEncoder(int j, double *v) override
Read the value of an encoder.
bool send2V1I(int v1, int v2, int axis)
bool setPositions(const int n_joint, const int *joints, const double *refs) override
Set new reference point for all axes.
bool setControlMode(const int j, const int mode) override
Set the current control mode.
bool isPidEnabled(const PidControlTypeEnum &pidtype, int j, bool *enabled) override
Get the current status (enabled/disabled) of the pid.
bool getPeakCurrent(int m, double *val) override
bool getLimits(int axis, double *min, double *max) override
Get the software limits for a particular axis.
bool getPWM(int m, double *val) override
bool get1VDA(int v, double *val)
Helper method to get an array of double from the remote peer.
bool set2V1DA(int v1, int v2, const double *val)
bool get1V1I(int code, int &v) const
Send a GET command expecting an integer value in return.
bool getNominalCurrent(int m, double *val) override
bool resetPid(const PidControlTypeEnum &pidtype, int j) override
Reset the controller of a given joint, usually sets the current status of the joint as the reference ...
bool setPeakCurrent(int m, const double val) override
bool getPidOutputs(const PidControlTypeEnum &pidtype, double *outs) override
Get the output of the controllers (e.g.
bool send2V(int v1, int v2)
bool set1V1I(int code, int v)
Send a SET command with an additional integer valued variable and then wait for a reply.
bool setInteractionMode(int axis, yarp::dev::InteractionModeEnum mode) override
Set the interaction mode of the robot, values can be stiff or compliant.
bool getTemperatureLimit(int m, double *val) override
Retreives the current temperature limit for a specific motor.
bool getPidError(const PidControlTypeEnum &pidtype, int j, double *err) override
Get the current error for a joint.
bool getPidReference(const PidControlTypeEnum &pidtype, int j, double *ref) override
Get the current reference of the pid controller for a specific joint.
bool homingSingleJoint(int j) override
homingSingleJoint: call the homing procedure for a single joint
bool checkMotionDone(int j, bool *flag) override
Check if the current trajectory is terminated.
bool getMotorEncoderCountsPerRevolution(int m, double *cpr) override
Gets number of counts per revolution for motor encoder m.
bool setMotorEncoderCountsPerRevolution(int m, const double cpr) override
Sets number of counts per revolution for motor encoder m.
bool set2V1I(int v1, int v2, int axis)
bool setRefDutyCycle(int j, double v) override
Sets the reference dutycycle to a single motor.
bool getRefAccelerations(const int n_joint, const int *joints, double *accs) override
Get reference acceleration for a joint.
bool setPidErrorLimit(const PidControlTypeEnum &pidtype, int j, double limit) override
Set the error limit for the controller on a specifi joint.
bool setMaxCurrent(int j, double v) override
bool getPowerSupplyVoltage(int m, double *val) override
bool getRefVelocity(const int joint, double *vel) override
Get the last reference speed set by velocityMove for single joint.
bool getPidOutput(const PidControlTypeEnum &pidtype, int j, double *out) override
Get the output of the controller (e.g.
bool get1V1I1IA1DA(int v, const int len, const int *val1, double *val2)
bool get1V1DA(int v1, double *val)
Helper method to get an array of double from the remote peer.
bool setRefSpeed(int j, double sp) override
Set reference speed for a joint, this is the speed used during the interpolation of the trajectory.
bool setInteractionModes(int n_joints, int *joints, yarp::dev::InteractionModeEnum *modes) override
Set the interaction mode of the robot for a set of joints, values can be stiff or compliant.
bool getRefCurrent(int j, double *t) override
Get the reference value of the current for a single motor.
bool getEncoders(double *encs) override
Read the position of all axes.
bool get1V1I1S(int code, int j, std::string &name)
bool set1V(int code)
Send a SET command without parameters and wait for a reply.
Stamp getLastInputStamp() override
Get the time stamp for the last read data.
bool getMotorEncoder(int j, double *v) override
Read the value of a motor encoder.
bool getTemperature(int m, double *val) override
Get temperature of a motor.
bool setPidReference(const PidControlTypeEnum &pidtype, int j, double ref) override
Set the controller reference for a given axis.
bool setImpedance(int j, double stiffness, double damping) override
Set current impedance gains (stiffness,damping) for a specific joint.
bool getMotorEncoderTimed(int j, double *v, double *t) override
Read the instantaneous position of a motor encoder.
bool getDutyCycles(double *outs) override
Gets the current dutycycle of the output of the amplifier (i.e.
bool setRefCurrent(int j, double ref) override
Set the reference value of the current for a single motor.
bool setControlModes(const int n_joint, const int *joints, int *modes) override
Set the current control mode for a subset of axes.
bool setPid(const PidControlTypeEnum &pidtype, int j, const Pid &pid) override
Set new pid value for a joint axis.
bool set1V1I2D(int code, int j, double val1, double val2)
bool getPidErrors(const PidControlTypeEnum &pidtype, double *errs) override
Get the error of all joints.
bool close() override
Close the device driver and stop the port connections.
bool parkSingleJoint(int j, bool _wait=true) override
parkSingleJoint(): start the parking procedure for the single joint
bool setMotorEncoders(const double *vals) override
Set the value of all motor encoders.
bool getTargetPositions(double *refs) override
Get the last position reference for all axes.
bool setEncoders(const double *vals) override
Set the value of all encoders.
bool set1VDA(int v, const double *val)
Helper method used to set an array of double to all axes.
bool getPid(const PidControlTypeEnum &pidtype, int j, Pid *pid) override
Get current pid value for a specific joint.
bool setPosition(int j, double ref) override
Set new position for a single axis.
bool get2V1I2D(int v1, int v2, int j, double *val1, double *val2)
bool getJointType(int j, yarp::dev::JointTypeEnum &type) override
bool resetMotorEncoder(int j) override
Reset motor encoder, single motor.
bool getEncoderSpeed(int j, double *sp) override
Read the istantaneous speed of an axis.
bool setGearboxRatio(int m, const double val) override
Set the gearbox ratio for a specific motor.
bool resetMotorEncoders() override
Reset motor encoders.
bool getCurrentRanges(double *min, double *max) override
Get the full scale of the current measurements for all motors motor (e.g.
bool getAmpStatus(int *st) override
bool setRefTorque(int j, double v) override
Set the reference value of the torque for a given joint.
bool enablePid(const PidControlTypeEnum &pidtype, int j) override
Enable the pid computation for a joint.
bool calibrateWholePart() override
calibrateWholePart: call the procedure for calibrating the whole device
bool getImpedance(int j, double *stiffness, double *damping) override
Get current impedance gains (stiffness,damping,offset) for a specific joint.
bool getPidErrorLimits(const PidControlTypeEnum &pidtype, double *limits) override
Get the error limit for all controllers.
bool getMotorEncoders(double *encs) override
Read the position of all motor encoders.
bool setPids(const PidControlTypeEnum &pidtype, const Pid *pids) override
Set new pid value on multiple axes.
bool setMotorEncoder(int j, const double val) override
Set the value of the motor encoder for a given motor.
bool velocityMove(int j, double v) override
Start motion at a given speed, single joint.
bool setRemoteVariable(std::string key, const yarp::os::Bottle &val) override
bool setPidErrorLimits(const PidControlTypeEnum &pidtype, const double *limits) override
Get the error limit for the controller on all joints.
bool calibrationDone(int j) override
Check if the calibration is terminated, on a particular joint.
bool setPidOffset(const PidControlTypeEnum &pidtype, int j, double v) override
Set offset value for a given controller.
bool get2V1I1D(int v1, int v2, int j, double *val)
bool abortCalibration() override
bool setRefCurrents(const double *refs) override
Set the reference value of the currents for all motors.
bool getMotorEncoderAcceleration(int j, double *acc) override
Read the instantaneous acceleration of a motor encoder.
bool setRefTorques(const double *t) override
Set the reference value of the torque for all joints.
bool getNumberOfMotors(int *num) override
Retrieves the number of controlled axes from the current physical interface.
bool getInteractionModes(int n_joints, int *joints, yarp::dev::InteractionModeEnum *modes) override
Get the current interaction mode of the robot for a set of joints, values can be stiff or compliant.
bool get1VIA(int v, int *val)
Helper method to get an array of integers from the remote peer.
bool set1V1I1IA1DA(int v, const int len, const int *val1, const double *val2)
bool getInteractionMode(int axis, yarp::dev::InteractionModeEnum *mode) override
Get the current interaction mode of the robot, values can be stiff or compliant.
bool getCurrentRange(int j, double *min, double *max) override
Get the full scale of the current measurement for a given motor (e.g.
bool getEncoderAcceleration(int j, double *acc) override
Read the instantaneous acceleration of an axis.
bool get1V1B(int v, bool &val)
bool getVelLimits(int axis, double *min, double *max) override
Get the software speed limits for a particular axis.
bool setEncoder(int j, double val) override
Set the value of the encoder for a given joint.
bool send1V1I(int v, int axis)
bool get1V1I2D(int code, int axis, double *v1, double *v2)
bool resetEncoders() override
Reset encoders.
bool checkProtocolVersion(bool ignore)
bool setImpedanceOffset(int j, double offset) override
Set current force Offset for a specific joint.
bool get2V1I1IA1DA(int v1, int v2, const int n_joints, const int *joints, double *retVals, std::string functionName="")
bool getGearboxRatio(int m, double *val) override
Get the gearbox ratio for a specific motor.
bool getRefAcceleration(int j, double *acc) override
Get reference acceleration for a joint.
bool getMaxCurrent(int j, double *v) override
Returns the maximum electric current allowed for a given motor.
bool set2V2DA(int v1, int v2, const double *val1, const double *val2)
bool get2V1DA(int v1, int v2, double *val)
Helper method to get an array of double from the remote peer.
bool setRefAccelerations(const int n_joint, const int *joints, const double *accs) override
Set reference acceleration on all joints.
bool setNominalCurrent(int m, const double val) override
bool getMotorTorqueParams(int j, MotorTorqueParameters *params) override
Get a subset of motor parameters (bemf, ktau etc) useful for torque control.
bool getRefTorques(double *t) override
Get the reference value of the torque for all joints.
bool getTorque(int j, double *t) override
Get the value of the torque on a given joint (this is the feedback if you have a torque sensor).
bool getRemoteVariable(std::string key, yarp::os::Bottle &val) override
bool getRefDutyCycles(double *refs) override
Gets the last reference sent using the setRefDutyCycles function.
bool set1V2D(int code, double v)
Send a SET command and an additional double valued variable and then wait for a reply.
bool getRemoteVariablesList(yarp::os::Bottle *listOfKeys) override
bool getMotorEncoderSpeed(int j, double *sp) override
Read the istantaneous speed of a motor encoder.
bool getTemperatures(double *vals) override
Get temperature of all the motors.
bool get2V2DA(int v1, int v2, double *val1, double *val2)
bool get1V1D(int code, double &v) const
Send a GET command expecting a double value in return.
bool setRefSpeeds(const int n_joint, const int *joints, const double *spds) override
Set reference speed on all joints.
bool getControlMode(int j, int *mode) override
Get the current control mode.
bool isCalibratorDevicePresent(bool *isCalib) override
isCalibratorDevicePresent: check if a calibrator device has been set
bool homingWholePart() override
homingWholePart: call the homing procedure for a the whole part/device
bool set2V1I1D(int v1, int v2, int axis, double val)
bool parkWholePart() override
parkWholePart: start the parking procedure for the whole part
bool calibrateRobot() override
Calibrate robot by using an external calibrator.
bool getControlModes(int *modes) override
Get the current control mode (multiple joints).
bool getMotorEncoderAccelerations(double *accs) override
Read the instantaneous acceleration of all motor encoders.
bool resetEncoder(int j) override
Reset encoder, single joint.
bool getDutyCycle(int j, double *out) override
Gets the current dutycycle of the output of the amplifier (i.e.
bool getTargetPosition(const int joint, double *ref) override
Get the last position reference for the specified axis.
bool send3V1I(int v1, int v2, int v3, int j)
bool getRefVelocities(double *vels) override
Get the last reference speed set by velocityMove for all joints.
bool getCurrent(int j, double *val) override
bool getAxes(int *ax) override
Get the number of controlled axes.
bool getPidErrorLimit(const PidControlTypeEnum &pidtype, int j, double *limit) override
Get the error limit for the controller on a specific joint.
bool stop() override
Stop motion, multiple joints.
bool setPWMLimit(int m, const double val) override
bool getRefSpeed(int j, double *ref) override
Get reference speed for a joint.
bool getRefPosition(const int joint, double *ref) override
Get the last position reference for the specified axis.
bool set1V1I1D(int code, int j, double val)
Helper method to set a double value to a single axis.
bool getEncoderTimed(int j, double *v, double *t) override
Read the instantaneous acceleration of all axes.
bool setCalibrationParameters(int j, const CalibrationParameters &params) override
Start calibration, this method is very often platform specific.
bool getRefTorque(int j, double *t) override
Get the reference value of the torque for a given joint.
bool setTemperatureLimit(int m, const double val) override
Set the temperature limit for a specific motor.
bool setValWithPidType(int voc, PidControlTypeEnum type, int axis, double val)
bool calibrateSingleJoint(int j) override
calibrateSingleJoint: call the calibration procedure for the single joint
bool enableAmp(int j) override
Enable the amplifier on a specific joint.
bool getEncoderSpeeds(double *spds) override
Read the instantaneous speed of all axes.
bool getTorqueRanges(double *min, double *max) override
Get the full scale of the torque sensors of all joints.
bool park(bool wait=true) override
bool setRefAcceleration(int j, double acc) override
Set reference acceleration for a joint.
bool getRefDutyCycle(int j, double *ref) override
Gets the last reference sent using the setRefDutyCycle function.
bool getMotorEncodersTimed(double *encs, double *ts) override
Read the instantaneous position of all motor encoders.
bool getImpedanceOffset(int j, double *offset) override
Get current force Offset for a specific joint.
bool getValWithPidType(int voc, PidControlTypeEnum type, int j, double *val)
bool calibrateAxisWithParams(int j, unsigned int ui, double v1, double v2, double v3) override
Start calibration, this method is very often platform specific.
bool getNumberOfMotorEncoders(int *num) override
Get the number of available motor encoders.
bool disablePid(const PidControlTypeEnum &pidtype, int j) override
Disable the pid computation for a joint.
bool getMotorEncoderSpeeds(double *spds) override
Read the instantaneous speed of all motor encoders.
bool getPWMLimit(int m, double *val) override
bool getCurrents(double *vals) override
bool disableAmp(int j) override
Disable the amplifier on a specific joint.
bool setVelLimits(int axis, double min, double max) override
Set the software speed limits for a particular axis, the behavior of the control card when these limi...
bool getEncodersTimed(double *encs, double *ts) override
Read the instantaneous acceleration of all axes.
bool getPids(const PidControlTypeEnum &pidtype, Pid *pids) override
Get current pid value for a specific joint.
bool get1V1I1D(int v, int j, double *val)
Helper method used to get a double value from the remote peer.
bool getEncoderAccelerations(double *accs) override
Read the instantaneous acceleration of all axes.
bool setMotorTorqueParams(int j, const MotorTorqueParameters params) override
Set a subset of motor parameters (bemf, ktau etc) useful for torque control.
bool setLimits(int axis, double min, double max) override
Set the software limits for a particular axis, the behavior of the control card when these limits are...
bool getTorqueRange(int j, double *min, double *max) override
Get the full scale of the torque sensor of a given joint.
bool setRefDutyCycles(const double *v) override
Sets the reference dutycycle for all the motors.
bool positionMove(int j, double ref) override
Set new reference point for a single axis.
bool quitPark() override
quitPark: interrupt the park procedure
bool get1V1I1I(int v, int j, int *val)
Helper method used to get an integer value from the remote peer.
bool getAxisName(int j, std::string &name) override
bool getPidReferences(const PidControlTypeEnum &pidtype, double *refs) override
Get the current reference of all pid controllers.
bool getRefCurrents(double *t) override
Get the reference value of the currents for all motors.
Contains the parameters for a PID.
double kd
derivative gain
double scale
scale for the pid output
double offset
pwm offset added to the pid output
double stiction_down_val
down stiction offset added to the pid output
double stiction_up_val
up stiction offset added to the pid output
double max_output
max output
double kff
feedforward gain
double ki
integrative gain
double max_int
saturation threshold for the integrator
double kp
proportional gain
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:74
void addVocab32(yarp::conf::vocab32_t x)
Places a vocabulary item in the bottle, at the end of the list.
Definition: Bottle.cpp:164
void append(const Bottle &alt)
Append the content of the given bottle to the current list.
Definition: Bottle.cpp:380
Bottle & addList()
Places an empty nested list in the bottle, at the end of the list.
Definition: Bottle.cpp:182
size_type size() const
Gets the number of elements in the bottle.
Definition: Bottle.cpp:251
void addFloat64(yarp::conf::float64_t x)
Places a 64-bit floating point number in the bottle, at the end of the list.
Definition: Bottle.cpp:158
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
Definition: Bottle.cpp:246
bool check(const std::string &key) const override
Check if there exists a property of the given name.
Definition: Bottle.cpp:277
void clear()
Empties the bottle of any objects it contains.
Definition: Bottle.cpp:121
void addInt32(std::int32_t x)
Places a 32-bit integer in the bottle, at the end of the list.
Definition: Bottle.cpp:140
void addString(const char *str)
Places a string in the bottle, at the end of the list.
Definition: Bottle.cpp:170
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
Definition: Bottle.cpp:287
std::string getName() const override
Get name of port.
static bool connect(const std::string &src, const std::string &dest, const std::string &carrier="", bool quiet=true)
Request that an output port connect to an input port.
Definition: Network.cpp:682
static bool setConnectionQos(const std::string &src, const std::string &dest, const QosStyle &srcStyle, const QosStyle &destStyle, bool quiet=true)
Adjust the Qos preferences of a connection.
Definition: Network.cpp:1079
An abstraction for a periodic thread.
PeriodicThread(double period, ShouldUseSystemClock useSystemClock=ShouldUseSystemClock::No, PeriodicThreadClock clockAccuracy=PeriodicThreadClock::Relative)
Constructor.
Group a pair of objects to be sent and received together.
Definition: PortablePair.h:48
BODY body
An object of the second type (BODY).
Definition: PortablePair.h:58
HEAD head
An object of the first type (HEAD).
Definition: PortablePair.h:53
Preferences for the port's Quality of Service.
Definition: QosStyle.h:24
void setThreadPriority(int priority)
sets the communication thread priority level
Definition: QosStyle.h:128
bool setPacketPriority(const std::string &priority)
sets the packet priority from a string.
Definition: QosStyle.cpp:39
void setThreadPolicy(int policy)
sets the communication thread scheduling policy
Definition: QosStyle.h:138
A base class for nested structures that can be searched.
Definition: Searchable.h:66
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
virtual Bottle & findGroup(const std::string &key) const =0
Gets a list corresponding to a given keyword.
An abstraction for a time stamp and/or sequence number.
Definition: Stamp.h:22
A single value (typically within a Bottle).
Definition: Value.h:45
virtual yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
Definition: Value.cpp:222
virtual yarp::conf::vocab32_t asVocab32() const
Get vocabulary identifier as an integer.
Definition: Value.cpp:228
virtual bool asBool() const
Get boolean value.
Definition: Value.cpp:186
virtual std::int32_t asInt32() const
Get 32-bit integer value.
Definition: Value.cpp:204
virtual Bottle * asList() const
Get list value.
Definition: Value.cpp:240
virtual std::string asString() const
Get string value.
Definition: Value.cpp:234
#define yCInfo(component,...)
Definition: LogComponent.h:132
#define yCError(component,...)
Definition: LogComponent.h:154
#define yCAssert(component, x)
Definition: LogComponent.h:169
#define yCWarning(component,...)
Definition: LogComponent.h:143
#define yCDebug(component,...)
Definition: LogComponent.h:109
An interface for the device drivers.
PidControlTypeEnum
Definition: PidEnums.h:18
An interface to the operating system, including Port based communication.
Signal processing.
Definition: Image.h:22