YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
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
10
11#include <cstring>
12
15#include <yarp/os/Time.h>
16#include <yarp/os/Network.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
33using namespace yarp::os;
34using namespace yarp::dev;
35using namespace yarp::sig;
36
37namespace {
38
39constexpr int PROTOCOL_VERSION_MAJOR = 1;
40constexpr int PROTOCOL_VERSION_MINOR = 9;
41constexpr int PROTOCOL_VERSION_TWEAK = 0;
42
43constexpr double DIAGNOSTIC_THREAD_PERIOD = 1.000;
44
45inline 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
67public:
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 {
106 int axes = 0;
107 bool ok = get1V1I(VOCAB_AXES, axes);
108 if (axes >= 0 && ok)
109 {
110 nj = axes;
111 njIsKnown = true;
112 }
113 }
114 return njIsKnown;
115}
116
118{
119 if (!parseParams(config)) { return false; }
120
122
123 //handle local Qos
126 {
127 localQos.setThreadPriority(m_local_qos_thread_priority);
128 localQos.setThreadPolicy(m_local_qos_thread_policy);
129 localQos.setPacketPriority(m_local_qos_packet_priority);
130 }
131
132 //handle remote Qos
135 {
136 remoteQos.setThreadPriority(m_remote_qos_thread_priority);
137 remoteQos.setThreadPolicy(m_remote_qos_thread_policy);
138 remoteQos.setPacketPriority(m_remote_qos_packet_priority);
139 }
140
141 //handle param writeStrict
142 if (m_writeStrict == "on")
143 {
146 yCInfo(REMOTECONTROLBOARD, "RemoteControlBoard is ENABLING the writeStrict option for all commands");
147 }
148 else if(m_writeStrict == "off")
149 {
152 yCInfo(REMOTECONTROLBOARD, "RemoteControlBoard is DISABLING the writeStrict option for all commands");
153 }
154 else if (m_writeStrict.empty())
155 {
156 //leave the default values
157 }
158 else
159 {
160 yCError(REMOTECONTROLBOARD, "Found writeStrict option with wrong value. Accepted options are 'on' or 'off'");
161 return false;
162 }
163
164 //open ports
165 bool portProblem = false;
166 if (m_local != "") {
167 std::string s1 = m_local;
168 s1 += "/rpc:o";
169 if (!rpc_p.open(s1)) { portProblem = true; }
170 s1 = m_local;
171 s1 += "/command:o";
172 if (!command_p.open(s1)) { portProblem = true; }
173 s1 = m_local;
174 s1 += "/stateExt:i";
175 if (!extendedIntputStatePort.open(s1)) { portProblem = true; }
176 if (!portProblem)
177 {
179 }
180 }
181
182 bool connectionProblem = false;
183 if (m_remote != "" && !portProblem)
184 {
185 std::string s1 = m_remote;
186 s1 += "/rpc:i";
187 std::string s2 = m_local;
188 s2 += "/rpc:o";
189 bool ok = false;
190 // RPC port needs to be tcp, therefore no carrier option is added here
191 // ok=Network::connect(s2.c_str(), s1.c_str()); //This doesn't take into consideration possible YARP_PORT_PREFIX on local ports
192 // 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
193 std::string dummy = rpc_p.getName();
194 ok=rpc_p.addOutput(s1); //This works because we are manipulating only remote side and let yarp handle the local side
195 if (!ok) {
196 yCError(REMOTECONTROLBOARD, "Problem connecting to %s, is the remote device available?", s1.c_str());
197 connectionProblem = true;
198 }
199
200 s1 = m_remote;
201 s1 += "/command:i";
202 s2 = m_local;
203 s2 += "/command:o";
204 //ok = Network::connect(s2.c_str(), s1.c_str(), carrier);
205 // ok=Network::connect(command_p.getName(), s1.c_str(), carrier); //doesn't take into consideration possible YARP_PORT_PREFIX on local ports
207 if (!ok) {
208 yCError(REMOTECONTROLBOARD, "Problem connecting to %s, is the remote device available?", s1.c_str());
209 connectionProblem = true;
210 }
211 // set the QoS preferences for the 'command' port
214 }
215
216 s1 = m_remote;
217 s1 += "/stateExt:o";
218 s2 = m_local;
219 s2 += "/stateExt:i";
220 // not checking return value for now since it is wip (different machines can have different compilation flags
221 ok = Network::connect(s1, extendedIntputStatePort.getName(), m_carrier);
222 if (ok)
223 {
224 // set the QoS preferences for the 'state' port
227 }
228 }
229 else
230 {
231 yCError(REMOTECONTROLBOARD, "Problem connecting to %s, is the remote device available?", s1.c_str());
232 connectionProblem = true;
233 }
234 }
235
237
238 rpc_p.close();
241 return false;
242 }
243
244 state_buffer.setStrict(false);
246
247 // open rpc port
248 std::string local_rpc_portname = m_local + "/nwc/rpc";
250 yCError(REMOTECONTROLBOARD, "open() error could not open rpc port %s, check network\n", local_rpc_portname.c_str());
251 return false;
252 }
253
254 //Attach the ControlBoardMsgs to the port
256 {
257 yCError(REMOTECONTROLBOARD, "Error! Cannot attach the port as a client");
258 return false;
259 }
260
261 // connection for the rpc port
262 std::string nws_rpc_portname = m_remote + "/nws/rpc";
263 if (!Network::connect(local_rpc_portname, nws_rpc_portname))
264 {
265 yCError(REMOTECONTROLBOARD, "open() error could not connect to %s\n", nws_rpc_portname.c_str());
266 return false;
267 }
268
269 // Check the protocol version
271 {
272 return false;
273 }
274
275 if (!isLive())
276 {
277 if (m_remote!="") {
278 yCError(REMOTECONTROLBOARD, "Problems with obtaining the number of controlled axes");
279 return false;
280 }
281 }
282
283 if (m_diagnostic)
284 {
288 }
289
290 // allocate memory for helper struct
291 // single joint
303
304 // whole part (safe here because we already got the nj
316 return true;
317}
318
320{
321 if (diagnosticThread!=nullptr)
322 {
324 delete diagnosticThread;
325 }
326
327 command_buffer.detach(); //TBC
328
329 rpc_p.interrupt(); // TBC
330 command_p.interrupt(); // TBC
332
333 rpc_p.close();
336 return true;
337}
338
339// BEGIN Helpers functions
340
342{
343 Bottle cmd, response;
344 cmd.addVocab32(v);
345 bool ok=rpc_p.write(cmd, response);
346 if (CHECK_FAIL(ok, response)) {
347 return true;
348 }
349 return false;
350}
351
353{
354 Bottle cmd, response;
355 cmd.addVocab32(v1);
356 cmd.addVocab32(v2);
357 bool ok=rpc_p.write(cmd, response);
358 if (CHECK_FAIL(ok, response)) {
359 return true;
360 }
361 return false;
362}
363
365{
366 Bottle cmd, response;
367 cmd.addVocab32(v1);
368 cmd.addVocab32(v2);
369 cmd.addInt32(axis);
370 bool ok=rpc_p.write(cmd, response);
371 if (CHECK_FAIL(ok, response)) {
372 return true;
373 }
374 return false;
375}
376
378{
379 Bottle cmd, response;
380 cmd.addVocab32(v);
381 cmd.addInt32(axis);
382 bool ok=rpc_p.write(cmd, response);
383 if (CHECK_FAIL(ok, response)) {
384 return true;
385 }
386 return false;
387}
388
389bool RemoteControlBoard::send3V1I(int v1, int v2, int v3, int j)
390{
391 Bottle cmd, response;
392 cmd.addVocab32(v1);
393 cmd.addVocab32(v2);
394 cmd.addVocab32(v3);
395 cmd.addInt32(j);
396 bool ok=rpc_p.write(cmd, response);
397 if (CHECK_FAIL(ok, response)) {
398 return true;
399 }
400 return false;
401}
402
404{
405 Bottle cmd, response;
407 cmd.addVocab32(code);
408
409 bool ok = rpc_p.write(cmd, response);
410 return CHECK_FAIL(ok, response);
411}
412
413bool RemoteControlBoard::set1V2D(int code, double v)
414{
415 Bottle cmd, response;
417 cmd.addVocab32(code);
418 cmd.addFloat64(v);
419
420 bool ok = rpc_p.write(cmd, response);
421
422 return CHECK_FAIL(ok, response);
423}
424
425bool RemoteControlBoard::set1V1I(int code, int v)
426{
427 Bottle cmd, response;
429 cmd.addVocab32(code);
430 cmd.addInt32(v);
431
432 bool ok = rpc_p.write(cmd, response);
433
434 return CHECK_FAIL(ok, response);
435}
436
437bool RemoteControlBoard::get1V1D(int code, double& v) const
438{
439 Bottle cmd;
440 Bottle response;
442 cmd.addVocab32(code);
443
444 bool ok = rpc_p.write(cmd, response);
445
446 if (CHECK_FAIL(ok, response)) {
447 // response should be [cmd] [name] value
448 v = response.get(2).asFloat64();
449
450 getTimeStamp(response, lastStamp);
451 return true;
452 }
453
454 return false;
455}
456
457bool RemoteControlBoard::get1V1I(int code, int& v) const
458{
459 Bottle cmd;
460 Bottle response;
462 cmd.addVocab32(code);
463
464 bool ok = rpc_p.write(cmd, response);
465
466 if (CHECK_FAIL(ok, response)) {
467 // response should be [cmd] [name] value
468 v = response.get(2).asInt32();
469
470 getTimeStamp(response, lastStamp);
471 return true;
472 }
473
474 return false;
475}
476
477bool RemoteControlBoard::set1V1I1D(int code, int j, double val)
478{
479 Bottle cmd, response;
481 cmd.addVocab32(code);
482 cmd.addInt32(j);
483 cmd.addFloat64(val);
484 bool ok = rpc_p.write(cmd, response);
485 return CHECK_FAIL(ok, response);
486}
487
488bool RemoteControlBoard::set1V1I2D(int code, int j, double val1, double val2)
489{
490 Bottle cmd, response;
492 cmd.addVocab32(code);
493 cmd.addInt32(j);
494 cmd.addFloat64(val1);
495 cmd.addFloat64(val2);
496
497 bool ok = rpc_p.write(cmd, response);
498 return CHECK_FAIL(ok, response);
499}
500
501bool RemoteControlBoard::set1VDA(int v, const double *val)
502{
503 if (!isLive()) {
504 return false;
505 }
506 Bottle cmd, response;
508 cmd.addVocab32(v);
509 Bottle& l = cmd.addList();
510 for (size_t i = 0; i < nj; i++) {
511 l.addFloat64(val[i]);
512 }
513 bool ok = rpc_p.write(cmd, response);
514 return CHECK_FAIL(ok, response);
515}
516
517bool RemoteControlBoard::set2V1DA(int v1, int v2, const double *val)
518{
519 if (!isLive()) {
520 return false;
521 }
522 Bottle cmd, response;
524 cmd.addVocab32(v1);
525 cmd.addVocab32(v2);
526 Bottle& l = cmd.addList();
527 for (size_t i = 0; i < nj; i++) {
528 l.addFloat64(val[i]);
529 }
530 bool ok = rpc_p.write(cmd, response);
531 return CHECK_FAIL(ok, response);
532}
533
534bool RemoteControlBoard::set2V2DA(int v1, int v2, const double *val1, const double *val2)
535{
536 if (!isLive()) {
537 return false;
538 }
539 Bottle cmd, response;
541 cmd.addVocab32(v1);
542 cmd.addVocab32(v2);
543 Bottle& l1 = cmd.addList();
544 for (size_t i = 0; i < nj; i++) {
545 l1.addFloat64(val1[i]);
546 }
547 Bottle& l2 = cmd.addList();
548 for (size_t i = 0; i < nj; i++) {
549 l2.addFloat64(val2[i]);
550 }
551 bool ok = rpc_p.write(cmd, response);
552 return CHECK_FAIL(ok, response);
553}
554
555bool RemoteControlBoard::set1V1I1IA1DA(int v, const int len, const int *val1, const double *val2)
556{
557 if (!isLive()) {
558 return false;
559 }
560 Bottle cmd, response;
562 cmd.addVocab32(v);
563 cmd.addInt32(len);
564 int i;
565 Bottle& l1 = cmd.addList();
566 for (i = 0; i < len; i++) {
567 l1.addInt32(val1[i]);
568 }
569 Bottle& l2 = cmd.addList();
570 for (i = 0; i < len; i++) {
571 l2.addFloat64(val2[i]);
572 }
573 bool ok = rpc_p.write(cmd, response);
574 return CHECK_FAIL(ok, response);
575}
576
577bool RemoteControlBoard::set2V1I1D(int v1, int v2, int axis, double val)
578{
579 Bottle cmd, response;
581 cmd.addVocab32(v1);
582 cmd.addVocab32(v2);
583 cmd.addInt32(axis);
584 cmd.addFloat64(val);
585 bool ok = rpc_p.write(cmd, response);
586 return CHECK_FAIL(ok, response);
587}
588
590{
591 if (!isLive()) {
592 return false;
593 }
594 Bottle cmd, response;
597 cmd.addVocab32(voc);
598 cmd.addVocab32(type);
599 cmd.addInt32(axis);
600 cmd.addFloat64(val);
601 bool ok = rpc_p.write(cmd, response);
602 return CHECK_FAIL(ok, response);
603}
604
606{
607 if (!isLive()) {
608 return false;
609 }
610 Bottle cmd, response;
613 cmd.addVocab32(voc);
614 cmd.addVocab32(type);
615 Bottle& l = cmd.addList();
616 for (size_t i = 0; i < nj; i++) {
617 l.addFloat64(val_arr[i]);
618 }
619 bool ok = rpc_p.write(cmd, response);
620 return CHECK_FAIL(ok, response);
621}
622
624{
625 Bottle cmd, response;
628 cmd.addVocab32(voc);
629 cmd.addVocab32(type);
630 cmd.addInt32(j);
631 bool ok = rpc_p.write(cmd, response);
632
633 if (CHECK_FAIL(ok, response))
634 {
635 *val = response.get(2).asFloat64();
636 getTimeStamp(response, lastStamp);
637 return true;
638 }
639 return false;
640}
641
643{
644 if (!isLive()) {
645 return false;
646 }
647 Bottle cmd, response;
650 cmd.addVocab32(voc);
651 cmd.addVocab32(type);
652 bool ok = rpc_p.write(cmd, response);
653 if (CHECK_FAIL(ok, response))
654 {
655 Bottle* lp = response.get(2).asList();
656 if (lp == nullptr) {
657 return false;
658 }
659 Bottle& l = *lp;
660 yCAssert(REMOTECONTROLBOARD, nj == l.size());
661 for (size_t i = 0; i < nj; i++) {
662 val[i] = l.get(i).asFloat64();
663 }
664 getTimeStamp(response, lastStamp);
665 return true;
666 }
667 return false;
668}
669
671{
672 Bottle cmd, response;
674 cmd.addVocab32(v1);
675 cmd.addVocab32(v2);
676 cmd.addInt32(axis);
677 bool ok = rpc_p.write(cmd, response);
678 return CHECK_FAIL(ok, response);
679}
680
681bool RemoteControlBoard::get1V1I1D(int v, int j, double *val)
682{
683 Bottle cmd, response;
685 cmd.addVocab32(v);
686 cmd.addInt32(j);
687 bool ok = rpc_p.write(cmd, response);
688
689 if (CHECK_FAIL(ok, response)) {
690 // ok
691 *val = response.get(2).asFloat64();
692
693 getTimeStamp(response, lastStamp);
694 return true;
695 }
696 return false;
697}
698
699bool RemoteControlBoard::get1V1I1I(int v, int j, int *val)
700{
701 Bottle cmd, response;
703 cmd.addVocab32(v);
704 cmd.addInt32(j);
705 bool ok = rpc_p.write(cmd, response);
706 if (CHECK_FAIL(ok, response)) {
707 // ok
708 *val = response.get(2).asInt32();
709
710 getTimeStamp(response, lastStamp);
711 return true;
712 }
713 return false;
714}
715
716bool RemoteControlBoard::get2V1I1D(int v1, int v2, int j, double *val)
717{
718 Bottle cmd, response;
720 cmd.addVocab32(v1);
721 cmd.addVocab32(v2);
722 cmd.addInt32(j);
723 bool ok = rpc_p.write(cmd, response);
724
725 if (CHECK_FAIL(ok, response)) {
726 // ok
727 *val = response.get(2).asFloat64();
728
729 getTimeStamp(response, lastStamp);
730 return true;
731 }
732 return false;
733}
734
735bool RemoteControlBoard::get2V1I2D(int v1, int v2, int j, double *val1, double *val2)
736{
737 Bottle cmd, response;
739 cmd.addVocab32(v1);
740 cmd.addVocab32(v2);
741 cmd.addInt32(j);
742 bool ok = rpc_p.write(cmd, response);
743 if (CHECK_FAIL(ok, response)) {
744 // ok
745 *val1 = response.get(2).asFloat64();
746 *val2 = response.get(3).asFloat64();
747
748 getTimeStamp(response, lastStamp);
749 return true;
750 }
751 return false;
752}
753
754bool RemoteControlBoard::get1V1I2D(int code, int axis, double *v1, double *v2)
755{
756 Bottle cmd, response;
758 cmd.addVocab32(code);
759 cmd.addInt32(axis);
760
761 bool ok = rpc_p.write(cmd, response);
762
763 if (CHECK_FAIL(ok, response)) {
764 *v1 = response.get(2).asFloat64();
765 *v2 = response.get(3).asFloat64();
766 return true;
767 }
768 return false;
769}
770
771bool RemoteControlBoard::get1V1I1B(int v, int j, bool &val)
772{
773 Bottle cmd, response;
775 cmd.addVocab32(v);
776 cmd.addInt32(j);
777 bool ok = rpc_p.write(cmd, response);
778 if (CHECK_FAIL(ok, response)) {
779 val = (response.get(2).asInt32()!=0);
780 getTimeStamp(response, lastStamp);
781 return true;
782 }
783 return false;
784}
785
786bool RemoteControlBoard::get1V1I1IA1B(int v, const int len, const int *val1, bool &retVal)
787{
788 Bottle cmd, response;
790 cmd.addVocab32(v);
791 cmd.addInt32(len);
792 Bottle& l1 = cmd.addList();
793 for (int i = 0; i < len; i++) {
794 l1.addInt32(val1[i]);
795 }
796
797 bool ok = rpc_p.write(cmd, response);
798
799 if (CHECK_FAIL(ok, response)) {
800 retVal = (response.get(2).asInt32()!=0);
801 getTimeStamp(response, lastStamp);
802 return true;
803 }
804 return false;
805}
806
807bool RemoteControlBoard::get2V1I1IA1DA(int v1, int v2, const int n_joints, const int *joints, double *retVals, std::string functionName)
808{
809 Bottle cmd, response;
810 if (!isLive()) {
811 return false;
812 }
813
815 cmd.addVocab32(v1);
816 cmd.addVocab32(v2);
817 cmd.addInt32(n_joints);
818
819 Bottle& l1 = cmd.addList();
820 for (int i = 0; i < n_joints; i++) {
821 l1.addInt32(joints[i]);
822 }
823
824 bool ok = rpc_p.write(cmd, response);
825
826 if (CHECK_FAIL(ok, response))
827 {
828 int i;
829 Bottle& list = *(response.get(0).asList());
830 yCAssert(REMOTECONTROLBOARD, list.size() >= (size_t) n_joints)
831
832 if (list.size() != (size_t )n_joints)
833 {
835 "%s length of response does not match: expected %d, received %zu\n ",
836 functionName.c_str(),
837 n_joints ,
838 list.size() );
839 return false;
840 }
841 else
842 {
843 for (i = 0; i < n_joints; i++)
844 {
845 retVals[i] = (double) list.get(i).asFloat64();
846 }
847 return true;
848 }
849 }
850 return false;
851}
852
853bool RemoteControlBoard::get1V1B(int v, bool &val)
854{
855 Bottle cmd, response;
857 cmd.addVocab32(v);
858 bool ok = rpc_p.write(cmd, response);
859 if (CHECK_FAIL(ok, response)) {
860 val = (response.get(2).asInt32()!=0);
861 getTimeStamp(response, lastStamp);
862 return true;
863 }
864 return false;
865}
866
867bool RemoteControlBoard::get1VIA(int v, int *val)
868{
869 if (!isLive()) {
870 return false;
871 }
872 Bottle cmd, response;
874 cmd.addVocab32(v);
875 bool ok = rpc_p.write(cmd, response);
876 if (CHECK_FAIL(ok, response)) {
877 Bottle* lp = response.get(2).asList();
878 if (lp == nullptr) {
879 return false;
880 }
881 Bottle& l = *lp;
882 yCAssert(REMOTECONTROLBOARD, nj == l.size());
883 for (size_t i = 0; i < nj; i++) {
884 val[i] = l.get(i).asInt32();
885 }
886
887 getTimeStamp(response, lastStamp);
888
889 return true;
890 }
891 return false;
892}
893
894bool RemoteControlBoard::get1VDA(int v, double *val)
895{
896 if (!isLive()) {
897 return false;
898 }
899 Bottle cmd, response;
901 cmd.addVocab32(v);
902 bool ok = rpc_p.write(cmd, response);
903 if (CHECK_FAIL(ok, response)) {
904 Bottle* lp = response.get(2).asList();
905 if (lp == nullptr) {
906 return false;
907 }
908 Bottle& l = *lp;
909 yCAssert(REMOTECONTROLBOARD, nj == l.size());
910 for (size_t i = 0; i < nj; i++) {
911 val[i] = l.get(i).asFloat64();
912 }
913
914 getTimeStamp(response, lastStamp);
915
916 return true;
917 }
918 return false;
919}
920
921bool RemoteControlBoard::get1V1DA(int v1, double *val)
922{
923 if (!isLive()) {
924 return false;
925 }
926 Bottle cmd, response;
928 cmd.addVocab32(v1);
929 bool ok = rpc_p.write(cmd, response);
930
931 if (CHECK_FAIL(ok, response)) {
932 Bottle* lp = response.get(2).asList();
933 if (lp == nullptr) {
934 return false;
935 }
936 Bottle& l = *lp;
937 yCAssert(REMOTECONTROLBOARD, nj == l.size());
938 for (size_t i = 0; i < nj; i++) {
939 val[i] = l.get(i).asFloat64();
940 }
941
942 getTimeStamp(response, lastStamp);
943 return true;
944 }
945 return false;
946}
947
948bool RemoteControlBoard::get2V1DA(int v1, int v2, double *val)
949{
950 if (!isLive()) {
951 return false;
952 }
953 Bottle cmd, response;
955 cmd.addVocab32(v1);
956 cmd.addVocab32(v2);
957 bool ok = rpc_p.write(cmd, response);
958
959 if (CHECK_FAIL(ok, response)) {
960 Bottle* lp = response.get(2).asList();
961 if (lp == nullptr) {
962 return false;
963 }
964 Bottle& l = *lp;
965 yCAssert(REMOTECONTROLBOARD, nj == l.size());
966 for (size_t i = 0; i < nj; i++) {
967 val[i] = l.get(i).asFloat64();
968 }
969
970 getTimeStamp(response, lastStamp);
971 return true;
972 }
973 return false;
974}
975
976bool RemoteControlBoard::get2V2DA(int v1, int v2, double *val1, double *val2)
977{
978 if (!isLive()) {
979 return false;
980 }
981 Bottle cmd, response;
983 cmd.addVocab32(v1);
984 cmd.addVocab32(v2);
985 bool ok = rpc_p.write(cmd, response);
986 if (CHECK_FAIL(ok, response)) {
987 Bottle* lp1 = response.get(2).asList();
988 if (lp1 == nullptr) {
989 return false;
990 }
991 Bottle& l1 = *lp1;
992 Bottle* lp2 = response.get(3).asList();
993 if (lp2 == nullptr) {
994 return false;
995 }
996 Bottle& l2 = *lp2;
997
998 size_t nj1 = l1.size();
999 size_t nj2 = l2.size();
1000 // yCAssert(REMOTECONTROLBOARD, nj == nj1);
1001 // yCAssert(REMOTECONTROLBOARD, nj == nj2);
1002
1003 for (size_t i = 0; i < nj1; i++) {
1004 val1[i] = l1.get(i).asFloat64();
1005 }
1006 for (size_t i = 0; i < nj2; i++) {
1007 val2[i] = l2.get(i).asFloat64();
1008 }
1009
1010 getTimeStamp(response, lastStamp);
1011 return true;
1012 }
1013 return false;
1014}
1015
1016bool RemoteControlBoard::get1V1I1S(int code, int j, std::string &name)
1017{
1018 Bottle cmd, response;
1019 cmd.addVocab32(VOCAB_GET);
1020 cmd.addVocab32(code);
1021 cmd.addInt32(j);
1022 bool ok = rpc_p.write(cmd, response);
1023
1024 if (CHECK_FAIL(ok, response)) {
1025 name = response.get(2).asString();
1026 return true;
1027 }
1028 return false;
1029}
1030
1031
1032bool RemoteControlBoard::get1V1I1IA1DA(int v, const int len, const int *val1, double *val2)
1033{
1034 if (!isLive()) {
1035 return false;
1036 }
1037
1038 Bottle cmd, response;
1039 cmd.addVocab32(VOCAB_GET);
1040 cmd.addVocab32(v);
1041 cmd.addInt32(len);
1042 Bottle &l1 = cmd.addList();
1043 for (int i = 0; i < len; i++) {
1044 l1.addInt32(val1[i]);
1045 }
1046
1047 bool ok = rpc_p.write(cmd, response);
1048
1049 if (CHECK_FAIL(ok, response)) {
1050 Bottle* lp2 = response.get(2).asList();
1051 if (lp2 == nullptr) {
1052 return false;
1053 }
1054 Bottle& l2 = *lp2;
1055
1056 size_t nj2 = l2.size();
1057 if(nj2 != (unsigned)len)
1058 {
1059 yCError(REMOTECONTROLBOARD, "received an answer with an unexpected number of entries!");
1060 return false;
1061 }
1062 for (size_t i = 0; i < nj2; i++) {
1063 val2[i] = l2.get(i).asFloat64();
1064 }
1065
1066 getTimeStamp(response, lastStamp);
1067 return true;
1068 }
1069 return false;
1070}
1071
1072// END Helpers functions
1073
1075{
1076 return get1V1I(VOCAB_AXES, *ax);
1077}
1078
1079// BEGIN IPidControl
1080
1082{
1083 Bottle cmd, response;
1084 cmd.addVocab32(VOCAB_SET);
1085 cmd.addVocab32(VOCAB_PID);
1086 cmd.addVocab32(VOCAB_PID);
1087 cmd.addVocab32(pidtype);
1088 cmd.addInt32(j);
1089 Bottle& l = cmd.addList();
1090 l.addFloat64(pid.kp);
1091 l.addFloat64(pid.kd);
1092 l.addFloat64(pid.ki);
1093 l.addFloat64(pid.max_int);
1094 l.addFloat64(pid.max_output);
1095 l.addFloat64(pid.offset);
1096 l.addFloat64(pid.scale);
1097 l.addFloat64(pid.stiction_up_val);
1098 l.addFloat64(pid.stiction_down_val);
1099 l.addFloat64(pid.kff);
1100 bool ok = rpc_p.write(cmd, response);
1101 return CHECK_FAIL(ok, response);
1102}
1103
1105{
1106 if (!isLive()) {
1107 return false;
1108 }
1109 Bottle cmd, response;
1110 cmd.addVocab32(VOCAB_SET);
1111 cmd.addVocab32(VOCAB_PID);
1113 cmd.addVocab32(pidtype);
1114 Bottle& l = cmd.addList();
1115 for (size_t i = 0; i < nj; i++) {
1116 Bottle& m = l.addList();
1117 m.addFloat64(pids[i].kp);
1118 m.addFloat64(pids[i].kd);
1119 m.addFloat64(pids[i].ki);
1120 m.addFloat64(pids[i].max_int);
1121 m.addFloat64(pids[i].max_output);
1122 m.addFloat64(pids[i].offset);
1123 m.addFloat64(pids[i].scale);
1124 m.addFloat64(pids[i].stiction_up_val);
1125 m.addFloat64(pids[i].stiction_down_val);
1126 m.addFloat64(pids[i].kff);
1127 }
1128
1129 bool ok = rpc_p.write(cmd, response);
1130 return CHECK_FAIL(ok, response);
1131}
1132
1134{
1135 return setValWithPidType(VOCAB_REF, pidtype, j, ref);
1136}
1137
1142
1147
1149{
1150 return setValWithPidType(VOCAB_LIMS, pidtype, limits);
1151}
1152
1154{
1155 return getValWithPidType(VOCAB_ERR, pidtype, j, err);
1156}
1157
1159{
1160 return getValWithPidType(VOCAB_ERRS, pidtype, errs);
1161}
1162
1164{
1165 Bottle cmd, response;
1166 cmd.addVocab32(VOCAB_GET);
1167 cmd.addVocab32(VOCAB_PID);
1168 cmd.addVocab32(VOCAB_PID);
1169 cmd.addVocab32(pidtype);
1170 cmd.addInt32(j);
1171 bool ok = rpc_p.write(cmd, response);
1172 if (CHECK_FAIL(ok, response)) {
1173 Bottle* lp = response.get(2).asList();
1174 if (lp == nullptr) {
1175 return false;
1176 }
1177 Bottle& l = *lp;
1178 pid->kp = l.get(0).asFloat64();
1179 pid->kd = l.get(1).asFloat64();
1180 pid->ki = l.get(2).asFloat64();
1181 pid->max_int = l.get(3).asFloat64();
1182 pid->max_output = l.get(4).asFloat64();
1183 pid->offset = l.get(5).asFloat64();
1184 pid->scale = l.get(6).asFloat64();
1185 pid->stiction_up_val = l.get(7).asFloat64();
1186 pid->stiction_down_val = l.get(8).asFloat64();
1187 pid->kff = l.get(9).asFloat64();
1188 return true;
1189 }
1190 return false;
1191}
1192
1194{
1195 if (!isLive()) {
1196 return false;
1197 }
1198 Bottle cmd, response;
1199 cmd.addVocab32(VOCAB_GET);
1200 cmd.addVocab32(VOCAB_PID);
1202 cmd.addVocab32(pidtype);
1203 bool ok = rpc_p.write(cmd, response);
1204 if (CHECK_FAIL(ok, response))
1205 {
1206 Bottle* lp = response.get(2).asList();
1207 if (lp == nullptr) {
1208 return false;
1209 }
1210 Bottle& l = *lp;
1211 yCAssert(REMOTECONTROLBOARD, nj == l.size());
1212 for (size_t i = 0; i < nj; i++)
1213 {
1214 Bottle* mp = l.get(i).asList();
1215 if (mp == nullptr) {
1216 return false;
1217 }
1218 pids[i].kp = mp->get(0).asFloat64();
1219 pids[i].kd = mp->get(1).asFloat64();
1220 pids[i].ki = mp->get(2).asFloat64();
1221 pids[i].max_int = mp->get(3).asFloat64();
1222 pids[i].max_output = mp->get(4).asFloat64();
1223 pids[i].offset = mp->get(5).asFloat64();
1224 pids[i].scale = mp->get(6).asFloat64();
1225 pids[i].stiction_up_val = mp->get(7).asFloat64();
1226 pids[i].stiction_down_val = mp->get(8).asFloat64();
1227 pids[i].kff = mp->get(9).asFloat64();
1228 }
1229 return true;
1230 }
1231 return false;
1232}
1233
1235{
1236 return getValWithPidType(VOCAB_REF, pidtype, j, ref);
1237}
1238
1243
1248
1250{
1251 return getValWithPidType(VOCAB_LIMS, pidtype, limits);
1252}
1253
1255{
1256 if (!isLive()) {
1257 return false;
1258 }
1259 Bottle cmd, response;
1260 cmd.addVocab32(VOCAB_SET);
1261 cmd.addVocab32(VOCAB_PID);
1263 cmd.addVocab32(pidtype);
1264 cmd.addInt32(j);
1265 bool ok = rpc_p.write(cmd, response);
1266 return CHECK_FAIL(ok, response);
1267}
1268
1270{
1271 if (!isLive()) {
1272 return false;
1273 }
1274 Bottle cmd, response;
1275 cmd.addVocab32(VOCAB_SET);
1276 cmd.addVocab32(VOCAB_PID);
1278 cmd.addVocab32(pidtype);
1279 cmd.addInt32(j);
1280 bool ok = rpc_p.write(cmd, response);
1281 return CHECK_FAIL(ok, response);
1282}
1283
1285{
1286 if (!isLive()) {
1287 return false;
1288 }
1289 Bottle cmd, response;
1290 cmd.addVocab32(VOCAB_SET);
1291 cmd.addVocab32(VOCAB_PID);
1293 cmd.addVocab32(pidtype);
1294 cmd.addInt32(j);
1295 bool ok = rpc_p.write(cmd, response);
1296 return CHECK_FAIL(ok, response);
1297}
1298
1300{
1301 Bottle cmd, response;
1302 cmd.addVocab32(VOCAB_GET);
1303 cmd.addVocab32(VOCAB_PID);
1305 cmd.addVocab32(pidtype);
1306 cmd.addInt32(j);
1307 bool ok = rpc_p.write(cmd, response);
1308 if (CHECK_FAIL(ok, response))
1309 {
1310 *enabled = response.get(2).asBool();
1311 return true;
1312 }
1313 return false;
1314}
1315
1317{
1318 return getValWithPidType(VOCAB_OUTPUT, pidtype, j, out);
1319}
1320
1325
1327{
1328 return setValWithPidType(VOCAB_OFFSET, pidtype, j, v);
1329}
1330
1331// END IPidControl
1332
1333// BEGIN IEncoder
1334
1336{
1337 return set1V1I(VOCAB_E_RESET, j);
1338}
1339
1344
1345bool RemoteControlBoard::setEncoder(int j, double val)
1346{
1347 return set1V1I1D(VOCAB_ENCODER, j, val);
1348}
1349
1351{
1352 return set1VDA(VOCAB_ENCODERS, vals);
1353}
1354
1356{
1357 double localArrivalTime = 0.0;
1358
1359 extendedPortMutex.lock();
1361 extendedPortMutex.unlock();
1362 return ret;
1363}
1364
1365bool RemoteControlBoard::getEncoderTimed(int j, double *v, double *t)
1366{
1367 double localArrivalTime = 0.0;
1368
1369 extendedPortMutex.lock();
1371 *t=lastStamp.getTime();
1372 extendedPortMutex.unlock();
1373 return ret;
1374}
1375
1377{
1378 double localArrivalTime = 0.0;
1379
1380 extendedPortMutex.lock();
1382 extendedPortMutex.unlock();
1383
1384 return ret;
1385}
1386
1387bool RemoteControlBoard::getEncodersTimed(double *encs, double *ts)
1388{
1389 double localArrivalTime=0.0;
1390
1391 extendedPortMutex.lock();
1393 std::fill_n(ts, nj, lastStamp.getTime());
1394 extendedPortMutex.unlock();
1395 return ret;
1396}
1397
1399{
1400 double localArrivalTime=0.0;
1401
1402 extendedPortMutex.lock();
1404 extendedPortMutex.unlock();
1405 return ret;
1406}
1407
1417
1419{
1420 double localArrivalTime=0.0;
1421 extendedPortMutex.lock();
1423 extendedPortMutex.unlock();
1424 return ret;
1425}
1426
1435
1436// END IEncoder
1437
1438// BEGIN IRemoteVariable
1439
1441{
1442 Bottle cmd, response;
1443 cmd.addVocab32(VOCAB_GET);
1446 cmd.addString(key);
1447 bool ok = rpc_p.write(cmd, response);
1448 if (CHECK_FAIL(ok, response))
1449 {
1450 val = *(response.get(2).asList());
1451 return true;
1452 }
1453 return false;
1454}
1455
1457{
1458 Bottle cmd, response;
1459 cmd.addVocab32(VOCAB_SET);
1462 cmd.addString(key);
1463 cmd.append(val);
1464 //std::string s = cmd.toString();
1465 bool ok = rpc_p.write(cmd, response);
1466
1467 return CHECK_FAIL(ok, response);
1468}
1469
1470
1472{
1473 Bottle cmd, response;
1474 cmd.addVocab32(VOCAB_GET);
1477 bool ok = rpc_p.write(cmd, response);
1478 //std::string s = response.toString();
1479 if (CHECK_FAIL(ok, response))
1480 {
1481 *listOfKeys = *(response.get(2).asList());
1482 //std::string s = listOfKeys->toString();
1483 return true;
1484 }
1485 return false;
1486}
1487
1488// END IRemoteVariable
1489
1490// BEGIN IMotor
1491
1496
1498{
1499 double localArrivalTime = 0.0;
1500
1501 extendedPortMutex.lock();
1503 extendedPortMutex.unlock();
1504 return ret;
1505}
1506
1508{
1509 double localArrivalTime = 0.0;
1510
1511 extendedPortMutex.lock();
1513 extendedPortMutex.unlock();
1514
1515 return ret;
1516}
1517
1519{
1520 return get1V1I1D(VOCAB_TEMPERATURE_LIMIT, m, val);
1521}
1522
1523bool RemoteControlBoard::setTemperatureLimit (int m, const double val)
1524{
1525 return set1V1I1D(VOCAB_TEMPERATURE_LIMIT, m, val);
1526}
1527
1529{
1530 return get1V1I1D(VOCAB_GEARBOX_RATIO, m, val);
1531}
1532
1533bool RemoteControlBoard::setGearboxRatio(int m, const double val)
1534{
1535 return set1V1I1D(VOCAB_GEARBOX_RATIO, m, val);
1536}
1537
1538// END IMotor
1539
1540// BEGIN IMotorEncoder
1541
1546
1551
1552bool RemoteControlBoard::setMotorEncoder(int j, const double val)
1553{
1554 return set1V1I1D(VOCAB_MOTOR_ENCODER, j, val);
1555}
1556
1561
1566
1568{
1570}
1571
1573{
1574 double localArrivalTime = 0.0;
1575
1576 extendedPortMutex.lock();
1578 extendedPortMutex.unlock();
1579 return ret;
1580}
1581
1582bool RemoteControlBoard::getMotorEncoderTimed(int j, double *v, double *t)
1583{
1584 double localArrivalTime = 0.0;
1585
1586 extendedPortMutex.lock();
1588 *t=lastStamp.getTime();
1589 extendedPortMutex.unlock();
1590 return ret;
1591}
1592
1594{
1595 double localArrivalTime=0.0;
1596
1597 extendedPortMutex.lock();
1599 extendedPortMutex.unlock();
1600
1601 return ret;
1602}
1603
1604bool RemoteControlBoard::getMotorEncodersTimed(double *encs, double *ts)
1605{
1606 double localArrivalTime=0.0;
1607
1608 extendedPortMutex.lock();
1610 std::fill_n(ts, nj, lastStamp.getTime());
1611 extendedPortMutex.unlock();
1612 return ret;
1613}
1614
1623
1632
1641
1650
1655
1656// END IMotorEncoder
1657
1658// BEGIN IPreciselyTimed
1659
1665{
1666 Stamp ret;
1667// mutex.lock();
1668 ret = lastStamp;
1669// mutex.unlock();
1670 return ret;
1671}
1672
1673// END IPreciselyTimed
1674
1675// BEGIN IPositionControl
1676
1678{
1679 return set1V1I1D(VOCAB_POSITION_MOVE, j, ref);
1680}
1681
1682bool RemoteControlBoard::positionMove(const int n_joint, const int *joints, const double *refs)
1683{
1685}
1686
1688{
1690}
1691
1693{
1694 return get1V1I1D(VOCAB_POSITION_MOVE, joint, ref);
1695}
1696
1701
1706
1708{
1710}
1711
1712bool RemoteControlBoard::relativeMove(const int n_joint, const int *joints, const double *refs)
1713{
1715}
1716
1718{
1720}
1721
1723{
1724 return get1V1I1B(VOCAB_MOTION_DONE, j, *flag);
1725}
1726
1727bool RemoteControlBoard::checkMotionDone(const int n_joint, const int *joints, bool *flag)
1728{
1730}
1731
1736
1738{
1739 return set1V1I1D(VOCAB_REF_SPEED, j, sp);
1740}
1741
1742bool RemoteControlBoard::setRefSpeeds(const int n_joint, const int *joints, const double *spds)
1743{
1745}
1746
1748{
1749 return set1VDA(VOCAB_REF_SPEEDS, spds);
1750}
1751
1753{
1754 return set1V1I1D(VOCAB_REF_ACCELERATION, j, acc);
1755}
1756
1757bool RemoteControlBoard::setRefAccelerations(const int n_joint, const int *joints, const double *accs)
1758{
1760}
1761
1766
1767bool RemoteControlBoard::getRefSpeed(int j, double *ref)
1768{
1769 return get1V1I1D(VOCAB_REF_SPEED, j, ref);
1770}
1771
1772bool RemoteControlBoard::getRefSpeeds(const int n_joint, const int *joints, double *spds)
1773{
1775}
1776
1778{
1779 return get1VDA(VOCAB_REF_SPEEDS, spds);
1780}
1781
1783{
1784 return get1V1I1D(VOCAB_REF_ACCELERATION, j, acc);
1785}
1786
1791
1796
1798{
1799 return set1V1I(VOCAB_STOP, j);
1800}
1801
1802bool RemoteControlBoard::stop(const int len, const int *val1)
1803{
1804 if (!isLive()) {
1805 return false;
1806 }
1807 Bottle cmd, response;
1808 cmd.addVocab32(VOCAB_SET);
1810 cmd.addInt32(len);
1811 int i;
1812 Bottle& l1 = cmd.addList();
1813 for (i = 0; i < len; i++) {
1814 l1.addInt32(val1[i]);
1815 }
1816
1817 bool ok = rpc_p.write(cmd, response);
1818 return CHECK_FAIL(ok, response);
1819}
1820
1822{
1823 return set1V(VOCAB_STOPS);
1824}
1825
1826// END IPositionControl
1827
1828// BEGIN IJoint Fault
1829bool RemoteControlBoard::getLastJointFault(int j, int& fault, std::string& message)
1830{
1831 Bottle cmd, response;
1832
1833 cmd.addVocab32(VOCAB_GET);
1836 cmd.addInt32(j);
1837
1838 bool ok = rpc_p.write(cmd, response);
1839
1840 std::string ss = response.toString();
1841
1842 if (CHECK_FAIL(ok, response))
1843 {
1844 fault = response.get(1).asInt32();
1845 message = response.get(2).asString();
1846 return true;
1847 }
1848 return false;
1849}
1850// END IJointFault
1851
1852// BEGIN IVelocityControl
1853
1855{
1856 if (!isLive()) {
1857 return false;
1858 }
1860 c.head.clear();
1861 c.head.addVocab32(VOCAB_VELOCITY_MOVE);
1862 c.head.addInt32(j);
1863 c.body.resize(1);
1864 memcpy(&(c.body[0]), &v, sizeof(double));
1866 return true;
1867}
1868
1870{
1871 if (!isLive()) {
1872 return false;
1873 }
1875 c.head.clear();
1876 c.head.addVocab32(VOCAB_VELOCITY_MOVES);
1877 c.body.resize(nj);
1878 memcpy(&(c.body[0]), v, sizeof(double)*nj);
1880 return true;
1881}
1882
1883// END IVelocityControl
1884
1885// BEGIN IAmplifierControl
1886
1888{
1889 return set1V1I(VOCAB_AMP_ENABLE, j);
1890}
1891
1893{
1894 return set1V1I(VOCAB_AMP_DISABLE, j);
1895}
1896
1898{
1899 return get1VIA(VOCAB_AMP_STATUS, st);
1900}
1901
1903{
1905}
1906
1908{
1909 return set1V1I1D(VOCAB_AMP_MAXCURRENT, j, v);
1910}
1911
1913{
1914 return get1V1I1D(VOCAB_AMP_MAXCURRENT, j, v);
1915}
1916
1918{
1920}
1921
1922bool RemoteControlBoard::setNominalCurrent(int m, const double val)
1923{
1925}
1926
1928{
1929 return get1V1I1D(VOCAB_AMP_PEAK_CURRENT, m, val);
1930}
1931
1932bool RemoteControlBoard::setPeakCurrent(int m, const double val)
1933{
1934 return set1V1I1D(VOCAB_AMP_PEAK_CURRENT, m, val);
1935}
1936
1937bool RemoteControlBoard::getPWM(int m, double* val)
1938{
1939 double localArrivalTime = 0.0;
1940 extendedPortMutex.lock();
1942 extendedPortMutex.unlock();
1943 return ret;
1944}
1945
1947{
1948 return get1V1I1D(VOCAB_AMP_PWM_LIMIT, m, val);
1949}
1950
1951bool RemoteControlBoard::setPWMLimit(int m, const double val)
1952{
1953 return set1V1I1D(VOCAB_AMP_PWM_LIMIT, m, val);
1954}
1955
1957{
1958 return get1V1I1D(VOCAB_AMP_VOLTAGE_SUPPLY, m, val);
1959}
1960
1961// END IAmplifierControl
1962
1963// BEGIN IControlLimits
1964
1965bool RemoteControlBoard::setLimits(int axis, double min, double max)
1966{
1967 return set1V1I2D(VOCAB_LIMITS, axis, min, max);
1968}
1969
1970bool RemoteControlBoard::getLimits(int axis, double *min, double *max)
1971{
1972 return get1V1I2D(VOCAB_LIMITS, axis, min, max);
1973}
1974
1975bool RemoteControlBoard::setVelLimits(int axis, double min, double max)
1976{
1977 return set1V1I2D(VOCAB_VEL_LIMITS, axis, min, max);
1978}
1979
1980bool RemoteControlBoard::getVelLimits(int axis, double *min, double *max)
1981{
1982 return get1V1I2D(VOCAB_VEL_LIMITS, axis, min, max);
1983}
1984
1985// END IControlLimits
1986
1987// BEGIN IAxisInfo
1988
1989bool RemoteControlBoard::getAxisName(int j, std::string& name)
1990{
1991 return get1V1I1S(VOCAB_INFO_NAME, j, name);
1992}
1993
1995{
1996 return get1V1I1I(VOCAB_INFO_TYPE, j, (int*)&type);
1997}
1998
1999// END IAxisInfo
2000
2001// BEGIN IControlCalibration
2006
2011
2016
2018{
2019 return send1V(VOCAB_PARK);
2020}
2021
2022bool RemoteControlBoard::calibrateAxisWithParams(int j, unsigned int ui, double v1, double v2, double v3)
2023{
2024 Bottle cmd, response;
2025
2027 cmd.addInt32(j);
2028 cmd.addInt32(ui);
2029 cmd.addFloat64(v1);
2030 cmd.addFloat64(v2);
2031 cmd.addFloat64(v3);
2032
2033 bool ok = rpc_p.write(cmd, response);
2034
2035 if (CHECK_FAIL(ok, response)) {
2036 return true;
2037 }
2038 return false;
2039}
2040
2042{
2043 Bottle cmd, response;
2044
2046 cmd.addInt32(j);
2047 cmd.addInt32(params.type);
2048 cmd.addFloat64(params.param1);
2049 cmd.addFloat64(params.param2);
2050 cmd.addFloat64(params.param3);
2051 cmd.addFloat64(params.param4);
2052
2053 bool ok = rpc_p.write(cmd, response);
2054
2055 if (CHECK_FAIL(ok, response)) {
2056 return true;
2057 }
2058 return false;
2059}
2060
2065
2066// END IControlCalibration
2067
2068// BEGIN ITorqueControl
2069
2071{
2072 return get2V1I1D(VOCAB_TORQUE, VOCAB_REF, j, t);
2073}
2074
2076{
2077 return get2V1DA(VOCAB_TORQUE, VOCAB_REFS, t);
2078}
2079
2081{
2082 //Now we use streaming instead of rpc
2083 //return set2V1DA(VOCAB_TORQUE, VOCAB_REFS, t);
2084 if (!isLive()) {
2085 return false;
2086 }
2088 c.head.clear();
2089 c.head.addVocab32(VOCAB_TORQUES_DIRECTS);
2090
2091 c.body.resize(nj);
2092
2093 memcpy(c.body.data(), t, sizeof(double) * nj);
2094
2096 return true;
2097}
2098
2100{
2101 //return set2V1I1D(VOCAB_TORQUE, VOCAB_REF, j, v);
2102 // use the streaming port!
2103 if (!isLive()) {
2104 return false;
2105 }
2107 c.head.clear();
2108 // in streaming port only SET command can be sent, so it is implicit
2109 c.head.addVocab32(VOCAB_TORQUES_DIRECT);
2110 c.head.addInt32(j);
2111
2112 c.body.clear();
2113 c.body.resize(1);
2114 c.body[0] = v;
2116 return true;
2117}
2118
2119bool RemoteControlBoard::setRefTorques(const int n_joint, const int *joints, const double *t)
2120{
2121 //return set2V1I1D(VOCAB_TORQUE, VOCAB_REF, j, v);
2122 // use the streaming port!
2123 if (!isLive()) {
2124 return false;
2125 }
2127 c.head.clear();
2128 // in streaming port only SET command can be sent, so it is implicit
2129 c.head.addVocab32(VOCAB_TORQUES_DIRECT_GROUP);
2130 c.head.addInt32(n_joint);
2131 Bottle &jointList = c.head.addList();
2132 for (int i = 0; i < n_joint; i++) {
2133 jointList.addInt32(joints[i]);
2134 }
2135 c.body.resize(n_joint);
2136 memcpy(&(c.body[0]), t, sizeof(double)*n_joint);
2138 return true;
2139}
2140
2142{
2143 Bottle cmd, response;
2144 cmd.addVocab32(VOCAB_SET);
2147 cmd.addInt32(j);
2148 Bottle& b = cmd.addList();
2149 b.addFloat64(params.bemf);
2150 b.addFloat64(params.bemf_scale);
2151 b.addFloat64(params.ktau);
2152 b.addFloat64(params.ktau_scale);
2153 b.addFloat64(params.viscousPos);
2154 b.addFloat64(params.viscousNeg);
2155 b.addFloat64(params.coulombPos);
2156 b.addFloat64(params.coulombNeg);
2157 b.addFloat64(params.velocityThres);
2158 bool ok = rpc_p.write(cmd, response);
2159 return CHECK_FAIL(ok, response);
2160}
2161
2163{
2164 Bottle cmd, response;
2165 cmd.addVocab32(VOCAB_GET);
2168 cmd.addInt32(j);
2169 bool ok = rpc_p.write(cmd, response);
2170 if (CHECK_FAIL(ok, response)) {
2171 Bottle* lp = response.get(2).asList();
2172 if (lp == nullptr) {
2173 return false;
2174 }
2175 Bottle& l = *lp;
2176 if (l.size() != 9)
2177 {
2178 yCError(REMOTECONTROLBOARD, "getMotorTorqueParams return value not understood, size != 9");
2179 return false;
2180 }
2181 params->bemf = l.get(0).asFloat64();
2182 params->bemf_scale = l.get(1).asFloat64();
2183 params->ktau = l.get(2).asFloat64();
2184 params->ktau_scale = l.get(3).asFloat64();
2185 params->viscousPos = l.get(4).asFloat64();
2186 params->viscousNeg = l.get(5).asFloat64();
2187 params->coulombPos = l.get(6).asFloat64();
2188 params->coulombNeg = l.get(7).asFloat64();
2189 params->velocityThres = l.get(8).asFloat64();
2190 return true;
2191 }
2192 return false;
2193}
2194
2195bool RemoteControlBoard::getTorque(int j, double *t)
2196{
2197 double localArrivalTime=0.0;
2198 extendedPortMutex.lock();
2200 extendedPortMutex.unlock();
2201 return ret;
2202}
2203
2205{
2206 double localArrivalTime=0.0;
2207 extendedPortMutex.lock();
2209 extendedPortMutex.unlock();
2210 return ret;
2211}
2212
2213bool RemoteControlBoard::getTorqueRange(int j, double *min, double* max)
2214{
2215 return get2V1I2D(VOCAB_TORQUE, VOCAB_RANGE, j, min, max);
2216}
2217
2218bool RemoteControlBoard::getTorqueRanges(double *min, double *max)
2219{
2220 return get2V2DA(VOCAB_TORQUE, VOCAB_RANGES, min, max);
2221}
2222
2223// END ITorqueControl
2224
2225// BEGIN IImpedanceControl
2226
2227bool RemoteControlBoard::getImpedance(int j, double *stiffness, double *damping)
2228{
2229 Bottle cmd, response;
2230 cmd.addVocab32(VOCAB_GET);
2233 cmd.addInt32(j);
2234 bool ok = rpc_p.write(cmd, response);
2235 if (CHECK_FAIL(ok, response)) {
2236 Bottle* lp = response.get(2).asList();
2237 if (lp == nullptr) {
2238 return false;
2239 }
2240 Bottle& l = *lp;
2241 *stiffness = l.get(0).asFloat64();
2242 *damping = l.get(1).asFloat64();
2243 return true;
2244 }
2245 return false;
2246}
2247
2249{
2250 Bottle cmd, response;
2251 cmd.addVocab32(VOCAB_GET);
2254 cmd.addInt32(j);
2255 bool ok = rpc_p.write(cmd, response);
2256 if (CHECK_FAIL(ok, response)) {
2257 Bottle* lp = response.get(2).asList();
2258 if (lp == nullptr) {
2259 return false;
2260 }
2261 Bottle& l = *lp;
2262 *offset = l.get(0).asFloat64();
2263 return true;
2264 }
2265 return false;
2266}
2267
2268bool RemoteControlBoard::setImpedance(int j, double stiffness, double damping)
2269{
2270 Bottle cmd, response;
2271 cmd.addVocab32(VOCAB_SET);
2274 cmd.addInt32(j);
2275
2276 Bottle& b = cmd.addList();
2277 b.addFloat64(stiffness);
2278 b.addFloat64(damping);
2279
2280 bool ok = rpc_p.write(cmd, response);
2281 return CHECK_FAIL(ok, response);
2282}
2283
2285{
2286 Bottle cmd, response;
2287 cmd.addVocab32(VOCAB_SET);
2290 cmd.addInt32(j);
2291
2292 Bottle& b = cmd.addList();
2293 b.addFloat64(offset);
2294
2295 bool ok = rpc_p.write(cmd, response);
2296 return CHECK_FAIL(ok, response);
2297}
2298
2299bool RemoteControlBoard::getCurrentImpedanceLimit(int j, double *min_stiff, double *max_stiff, double *min_damp, double *max_damp)
2300{
2301 Bottle cmd, response;
2302 cmd.addVocab32(VOCAB_GET);
2305 cmd.addInt32(j);
2306 bool ok = rpc_p.write(cmd, response);
2307 if (CHECK_FAIL(ok, response)) {
2308 Bottle* lp = response.get(2).asList();
2309 if (lp == nullptr) {
2310 return false;
2311 }
2312 Bottle& l = *lp;
2313 *min_stiff = l.get(0).asFloat64();
2314 *max_stiff = l.get(1).asFloat64();
2315 *min_damp = l.get(2).asFloat64();
2316 *max_damp = l.get(3).asFloat64();
2317 return true;
2318 }
2319 return false;
2320}
2321
2322// END IImpedanceControl
2323
2324// BEGIN IControlMode
2325
2334
2343
2345{
2346 double localArrivalTime=0.0;
2347
2348 extendedPortMutex.lock();
2350 if(ret)
2351 {
2352 for (int i = 0; i < n_joint; i++) {
2354 }
2355 } else {
2356 ret = false;
2357 }
2358
2359 extendedPortMutex.unlock();
2360 return ret;
2361}
2362
2363bool RemoteControlBoard::setControlMode(const int j, const int mode)
2364{
2365 if (!isLive()) {
2366 return false;
2367 }
2368 Bottle cmd, response;
2369 cmd.addVocab32(VOCAB_SET);
2372 cmd.addInt32(j);
2373 cmd.addVocab32(mode);
2374
2375 bool ok = rpc_p.write(cmd, response);
2376 return CHECK_FAIL(ok, response);
2377}
2378
2380{
2381 if (!isLive()) {
2382 return false;
2383 }
2384 Bottle cmd, response;
2385 cmd.addVocab32(VOCAB_SET);
2388 cmd.addInt32(n_joint);
2389 int i;
2390 Bottle& l1 = cmd.addList();
2391 for (i = 0; i < n_joint; i++) {
2392 l1.addInt32(joints[i]);
2393 }
2394
2395 Bottle& l2 = cmd.addList();
2396 for (i = 0; i < n_joint; i++) {
2397 l2.addVocab32(modes[i]);
2398 }
2399
2400 bool ok = rpc_p.write(cmd, response);
2401 return CHECK_FAIL(ok, response);
2402}
2403
2405{
2406 if (!isLive()) {
2407 return false;
2408 }
2409 Bottle cmd, response;
2410 cmd.addVocab32(VOCAB_SET);
2413
2414 Bottle& l2 = cmd.addList();
2415 for (size_t i = 0; i < nj; i++) {
2416 l2.addVocab32(modes[i]);
2417 }
2418
2419 bool ok = rpc_p.write(cmd, response);
2420 return CHECK_FAIL(ok, response);
2421}
2422
2423// END IControlMode
2424
2425// BEGIN IPositionDirect
2426
2427bool RemoteControlBoard::setPosition(int j, double ref)
2428{
2429 if (!isLive()) {
2430 return false;
2431 }
2433 c.head.clear();
2434 c.head.addVocab32(VOCAB_POSITION_DIRECT);
2435 c.head.addInt32(j);
2436 c.body.resize(1);
2437 memcpy(&(c.body[0]), &ref, sizeof(double));
2439 return true;
2440}
2441
2442bool RemoteControlBoard::setPositions(const int n_joint, const int *joints, const double *refs)
2443{
2444 if (!isLive()) {
2445 return false;
2446 }
2448 c.head.clear();
2449 c.head.addVocab32(VOCAB_POSITION_DIRECT_GROUP);
2450 c.head.addInt32(n_joint);
2451 Bottle &jointList = c.head.addList();
2452 for (int i = 0; i < n_joint; i++) {
2453 jointList.addInt32(joints[i]);
2454 }
2455 c.body.resize(n_joint);
2456 memcpy(&(c.body[0]), refs, sizeof(double)*n_joint);
2458 return true;
2459}
2460
2462{
2463 if (!isLive()) {
2464 return false;
2465 }
2467 c.head.clear();
2468 c.head.addVocab32(VOCAB_POSITION_DIRECTS);
2469 c.body.resize(nj);
2470 memcpy(&(c.body[0]), refs, sizeof(double)*nj);
2472 return true;
2473}
2474
2475bool RemoteControlBoard::getRefPosition(const int joint, double* ref)
2476{
2478}
2479
2484
2489
2490// END IPositionDirect
2491
2492// BEGIN IVelocityControl
2493
2494bool RemoteControlBoard::velocityMove(const int n_joint, const int *joints, const double *spds)
2495{
2496 // streaming port
2497 if (!isLive()) {
2498 return false;
2499 }
2501 c.head.clear();
2502 c.head.addVocab32(VOCAB_VELOCITY_MOVE_GROUP);
2503 c.head.addInt32(n_joint);
2504 Bottle &jointList = c.head.addList();
2505 for (int i = 0; i < n_joint; i++) {
2506 jointList.addInt32(joints[i]);
2507 }
2508 c.body.resize(n_joint);
2509 memcpy(&(c.body[0]), spds, sizeof(double)*n_joint);
2511 return true;
2512}
2513
2514bool RemoteControlBoard::getRefVelocity(const int joint, double* vel)
2515{
2516 return get1V1I1D(VOCAB_VELOCITY_MOVE, joint, vel);
2517}
2518
2523
2528
2529// END IVelocityControl
2530
2531// BEGIN IInteractionMode
2532
2541
2543{
2544 double localArrivalTime=0.0;
2545
2546 extendedPortMutex.lock();
2548 if(ret)
2549 {
2550 for (int i = 0; i < n_joints; i++) {
2552 }
2553 } else {
2554 ret = false;
2555 }
2556
2557 extendedPortMutex.unlock();
2558 return ret;
2559}
2560
2569
2571{
2572 Bottle cmd, response;
2573 if (!isLive()) {
2574 return false;
2575 }
2576
2577 cmd.addVocab32(VOCAB_SET);
2580 cmd.addInt32(axis);
2581 cmd.addVocab32(mode);
2582
2583 bool ok = rpc_p.write(cmd, response);
2584 return CHECK_FAIL(ok, response);
2585}
2586
2588{
2589 Bottle cmd, response;
2590 if (!isLive()) {
2591 return false;
2592 }
2593
2594 cmd.addVocab32(VOCAB_SET);
2597 cmd.addInt32(n_joints);
2598
2599 Bottle& l1 = cmd.addList();
2600 for (int i = 0; i < n_joints; i++) {
2601 l1.addInt32(joints[i]);
2602 }
2603
2604 Bottle& l2 = cmd.addList();
2605 for (int i = 0; i < n_joints; i++)
2606 {
2607 l2.addVocab32(modes[i]);
2608 }
2609 bool ok = rpc_p.write(cmd, response);
2610 return CHECK_FAIL(ok, response);
2611}
2612
2614{
2615 Bottle cmd, response;
2616 if (!isLive()) {
2617 return false;
2618 }
2619
2620 cmd.addVocab32(VOCAB_SET);
2623
2624 Bottle& l1 = cmd.addList();
2625 for (size_t i = 0; i < nj; i++) {
2626 l1.addVocab32(modes[i]);
2627 }
2628
2629 bool ok = rpc_p.write(cmd, response);
2630 return CHECK_FAIL(ok, response);
2631}
2632
2633// END IInteractionMode
2634
2635// BEGIN IRemoteCalibrator
2636
2638{
2639 Bottle cmd, response;
2640 cmd.addVocab32(VOCAB_GET);
2643 bool ok = rpc_p.write(cmd, response);
2644 if(ok) {
2645 *isCalib = response.get(2).asInt32()!=0;
2646 } else {
2647 *isCalib = false;
2648 }
2649 return CHECK_FAIL(ok, response);
2650}
2651
2656
2658{
2659 Bottle cmd, response;
2660 cmd.addVocab32(VOCAB_SET);
2663 bool ok = rpc_p.write(cmd, response);
2664 return CHECK_FAIL(ok, response);
2665}
2666
2671
2673{
2674 Bottle cmd, response;
2675 cmd.addVocab32(VOCAB_SET);
2678 bool ok = rpc_p.write(cmd, response);
2679 yCDebug(REMOTECONTROLBOARD) << "Sent homing whole part message";
2680 return CHECK_FAIL(ok, response);
2681}
2682
2687
2689{
2690 Bottle cmd, response;
2691 cmd.addVocab32(VOCAB_SET);
2694 bool ok = rpc_p.write(cmd, response);
2695 return CHECK_FAIL(ok, response);
2696}
2697
2699{
2700 Bottle cmd, response;
2701 cmd.addVocab32(VOCAB_SET);
2704 bool ok = rpc_p.write(cmd, response);
2705 return CHECK_FAIL(ok, response);
2706}
2707
2709{
2710 Bottle cmd, response;
2711 cmd.addVocab32(VOCAB_SET);
2714 bool ok = rpc_p.write(cmd, response);
2715 return CHECK_FAIL(ok, response);
2716}
2717
2718// END IRemoteCalibrator
2719
2720// BEGIN ICurrentControl
2721
2726
2731
2733{
2734 if (!isLive()) {
2735 return false;
2736 }
2738 c.head.clear();
2739 c.head.addVocab32(VOCAB_CURRENTCONTROL_INTERFACE);
2740 c.head.addVocab32(VOCAB_CURRENT_REFS);
2741 c.body.resize(nj);
2742 memcpy(&(c.body[0]), refs, sizeof(double)*nj);
2744 return true;
2745}
2746
2748{
2749 if (!isLive()) {
2750 return false;
2751 }
2753 c.head.clear();
2754 c.head.addVocab32(VOCAB_CURRENTCONTROL_INTERFACE);
2755 c.head.addVocab32(VOCAB_CURRENT_REF);
2756 c.head.addInt32(j);
2757 c.body.resize(1);
2758 memcpy(&(c.body[0]), &ref, sizeof(double));
2760 return true;
2761}
2762
2763bool RemoteControlBoard::setRefCurrents(const int n_joint, const int *joints, const double *refs)
2764{
2765 if (!isLive()) {
2766 return false;
2767 }
2769 c.head.clear();
2770 c.head.addVocab32(VOCAB_CURRENTCONTROL_INTERFACE);
2771 c.head.addVocab32(VOCAB_CURRENT_REF_GROUP);
2772 c.head.addInt32(n_joint);
2773 Bottle &jointList = c.head.addList();
2774 for (int i = 0; i < n_joint; i++) {
2775 jointList.addInt32(joints[i]);
2776 }
2777 c.body.resize(n_joint);
2778 memcpy(&(c.body[0]), refs, sizeof(double)*n_joint);
2780 return true;
2781}
2782
2791
2792bool RemoteControlBoard::getCurrent(int j, double *val)
2793{
2794 double localArrivalTime=0.0;
2795 extendedPortMutex.lock();
2797 extendedPortMutex.unlock();
2798 return ret;
2799}
2800
2801bool RemoteControlBoard::getCurrentRange(int j, double *min, double *max)
2802{
2804}
2805
2806bool RemoteControlBoard::getCurrentRanges(double *min, double *max)
2807{
2809}
2810
2811// END ICurrentControl
2812
2813// BEGIN IPWMControl
2815{
2816 // using the streaming port
2817 if (!isLive()) {
2818 return false;
2819 }
2821 c.head.clear();
2822 // in streaming port only SET command can be sent, so it is implicit
2823 c.head.addVocab32(VOCAB_PWMCONTROL_INTERFACE);
2824 c.head.addVocab32(VOCAB_PWMCONTROL_REF_PWM);
2825 c.head.addInt32(j);
2826
2827 c.body.clear();
2828 c.body.resize(1);
2829 c.body[0] = v;
2831 return true;
2832}
2833
2835{
2836 // using the streaming port
2837 if (!isLive()) {
2838 return false;
2839 }
2841 c.head.clear();
2842 c.head.addVocab32(VOCAB_PWMCONTROL_INTERFACE);
2843 c.head.addVocab32(VOCAB_PWMCONTROL_REF_PWMS);
2844
2845 c.body.resize(nj);
2846
2847 memcpy(&(c.body[0]), v, sizeof(double)*nj);
2848
2850
2851 return true;
2852}
2853
2855{
2856 Bottle cmd, response;
2857 cmd.addVocab32(VOCAB_GET);
2860 cmd.addInt32(j);
2861 response.clear();
2862
2863 bool ok = rpc_p.write(cmd, response);
2864
2865 if (CHECK_FAIL(ok, response))
2866 {
2867 // ok
2868 *ref = response.get(2).asFloat64();
2869
2870 getTimeStamp(response, lastStamp);
2871 return true;
2872 } else {
2873 return false;
2874 }
2875}
2876
2881
2882bool RemoteControlBoard::getDutyCycle(int j, double *out)
2883{
2884 double localArrivalTime = 0.0;
2885 extendedPortMutex.lock();
2887 extendedPortMutex.unlock();
2888 return ret;
2889}
2890
2892{
2893 double localArrivalTime = 0.0;
2894 extendedPortMutex.lock();
2896 extendedPortMutex.unlock();
2897 return ret;
2898}
2899// END IPWMControl
2900
2901// BEGIN IJointBrake
2903{
2904 //std::lock_guard<std::mutex> lg(m_mutex);
2905 auto ret = m_RPC.isJointBrakedRPC(j);
2906 if (!ret.ret) {
2907 yCError(REMOTECONTROLBOARD, "Unable to isJointBraked");
2908 return ret.ret;
2909 }
2910 braked = ret.isBraked;
2911 return ret.ret;
2912}
2913
2915{
2916 // std::lock_guard<std::mutex> lg(m_mutex);
2917 auto ret = m_RPC.setManualBrakeActiveRPC(j,active);
2918 if (!ret) {
2919 yCError(REMOTECONTROLBOARD, "Unable to setManualBrakeActive");
2920 return ret;
2921 }
2922 return ret;
2923}
2924
2926{
2927 // std::lock_guard<std::mutex> lg(m_mutex);
2928 auto ret = m_RPC.setAutoBrakeEnabledRPC(j,enabled);
2929 if (!ret) {
2930 yCError(REMOTECONTROLBOARD, "Unable to isJointBraked");
2931 return ret;
2932 }
2933 return ret;
2934}
2935
2937{
2938 // std::lock_guard<std::mutex> lg(m_mutex);
2940 if (!ret.ret) {
2941 yCError(REMOTECONTROLBOARD, "Unable to getAutoBrakeEnabled");
2942 return ret.ret;
2943 }
2944 enabled = ret.enabled;
2945 return ret.ret;
2946}
2947// END IJointBrake
2948
2949// IVelocityDirect
2951{
2952 // std::lock_guard<std::mutex> lg(m_mutex);
2953 auto ret = m_RPC.getAxesRPC();
2954 if (!ret.ret) {
2955 yCError(REMOTECONTROLBOARD, "Unable to getAxes");
2956 return ret.ret;
2957 }
2958 axes = ret.axes;
2959 return ret.ret;
2960}
2961
2963{
2964 if (!isLive()) {
2965 return ReturnValue::return_code::return_value_error_not_ready;
2966 }
2968 c.head.clear();
2969 c.head.addVocab32(VOCAB_VELOCITY_DIRECT_SET_ONE);
2970 c.head.addInt32(jnt);
2971 c.body.resize(1);
2972 c.body[0] = vel;
2974 return ReturnValue_ok;
2975}
2976
2978{
2979 if (!isLive()) {
2980 return ReturnValue::return_code::return_value_error_not_ready;
2981 }
2983 c.head.clear();
2984 c.head.addVocab32(VOCAB_VELOCITY_DIRECT_SET_ALL);
2985 c.body.resize(nj);
2986 for (size_t i = 0; i < vels.size(); i++) {
2987 c.body[i]=vels[i];
2988 }
2990 return ReturnValue_ok;
2991}
2992
2993ReturnValue RemoteControlBoard::setDesiredVelocity(const std::vector<int>& jnts, const std::vector<double>& vels)
2994{
2995 if (!isLive()) {
2996 return ReturnValue::return_code::return_value_error_not_ready;
2997 }
2999 c.head.clear();
3000 c.head.addVocab32(VOCAB_VELOCITY_DIRECT_SET_GROUP);
3001 c.head.addInt32(jnts.size());
3002 Bottle &jointList = c.head.addList();
3003 for (size_t i = 0; i < jnts.size(); i++) {
3004 jointList.addInt32(jnts[i]);
3005 }
3006 c.body.resize(jnts.size());
3007 for (size_t i = 0; i < jnts.size(); i++) {
3008 c.body[i]=vels[i];
3009 }
3011 return ReturnValue_ok;
3012}
3013
3015{
3016 // std::lock_guard<std::mutex> lg(m_mutex);
3018 if (!ret.ret) {
3019 yCError(REMOTECONTROLBOARD, "Unable to getDesiredVelocityOneRPC");
3020 return ret.ret;
3021 }
3022 vel = ret.vel;
3023 return ret.ret;
3024}
3025
3027{
3028 // std::lock_guard<std::mutex> lg(m_mutex);
3030 if (!ret.ret) {
3031 yCError(REMOTECONTROLBOARD, "Unable to getDesiredVelocityAllRPC");
3032 return ret.ret;
3033 }
3034 vels = ret.vel;
3035 return ret.ret;
3036}
3037
3038ReturnValue RemoteControlBoard::getDesiredVelocity(const std::vector<int>& jnts, std::vector<double>& vels)
3039{
3040 // std::lock_guard<std::mutex> lg(m_mutex);
3042 if (!ret.ret) {
3043 yCError(REMOTECONTROLBOARD, "Unable to getDesiredVelocityGroupRPC");
3044 return ret.ret;
3045 }
3046 vels = ret.vel;
3047 return ret.ret;
3048}
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_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_POSITION_MOVE
constexpr yarp::conf::vocab32_t VOCAB_REF_ACCELERATION
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
FeatureMode mode
constexpr yarp::conf::vocab32_t VOCAB_LIM
constexpr yarp::conf::vocab32_t VOCAB_OUTPUTS
constexpr yarp::conf::vocab32_t VOCAB_ENABLE
constexpr yarp::conf::vocab32_t VOCAB_DISABLE
constexpr yarp::conf::vocab32_t VOCAB_REF
constexpr yarp::conf::vocab32_t VOCAB_ERRS
constexpr yarp::conf::vocab32_t VOCAB_GET
constexpr yarp::conf::vocab32_t VOCAB_OUTPUT
constexpr yarp::conf::vocab32_t VOCAB_ERR
constexpr yarp::conf::vocab32_t VOCAB_REFS
constexpr yarp::conf::vocab32_t VOCAB_RESET
constexpr yarp::conf::vocab32_t VOCAB_AXES
constexpr yarp::conf::vocab32_t VOCAB_SET
constexpr yarp::conf::vocab32_t VOCAB_OFFSET
constexpr yarp::conf::vocab32_t VOCAB_LIMS
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:104
constexpr yarp::conf::vocab32_t VOCAB_INFO_NAME
Definition IAxisInfo.h:103
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
constexpr yarp::conf::vocab32_t VOCAB_CM_CONTROL_MODES
constexpr yarp::conf::vocab32_t VOCAB_CM_CONTROL_MODE
constexpr yarp::conf::vocab32_t VOCAB_ICONTROLMODE
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:204
constexpr yarp::conf::vocab32_t VOCAB_ENCODER_ACCELERATIONS
Definition IEncoders.h:213
constexpr yarp::conf::vocab32_t VOCAB_ENCODER
Definition IEncoders.h:206
constexpr yarp::conf::vocab32_t VOCAB_ENCODER_SPEEDS
Definition IEncoders.h:211
constexpr yarp::conf::vocab32_t VOCAB_E_RESETS
Definition IEncoders.h:205
constexpr yarp::conf::vocab32_t VOCAB_ENCODER_SPEED
Definition IEncoders.h:210
constexpr yarp::conf::vocab32_t VOCAB_ENCODER_ACCELERATION
Definition IEncoders.h:212
constexpr yarp::conf::vocab32_t VOCAB_ENCODERS
Definition IEncoders.h:207
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_JF_GET_JOINTFAULT
Definition IJointFault.h:42
constexpr yarp::conf::vocab32_t VOCAB_IJOINTFAULT
Definition IJointFault.h:41
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_TEMPERATURE_LIMIT
Definition IMotor.h:163
constexpr yarp::conf::vocab32_t VOCAB_TEMPERATURE
Definition IMotor.h:160
constexpr yarp::conf::vocab32_t VOCAB_GEARBOX_RATIO
Definition IMotor.h:161
constexpr yarp::conf::vocab32_t VOCAB_MOTORS_NUMBER
Definition IMotor.h:159
constexpr yarp::conf::vocab32_t VOCAB_PWMCONTROL_INTERFACE
constexpr yarp::conf::vocab32_t VOCAB_PWMCONTROL_PWM_OUTPUTS
constexpr yarp::conf::vocab32_t VOCAB_PWMCONTROL_REF_PWMS
constexpr yarp::conf::vocab32_t VOCAB_PWMCONTROL_REF_PWM
constexpr yarp::conf::vocab32_t VOCAB_PWMCONTROL_PWM_OUTPUT
constexpr yarp::conf::vocab32_t VOCAB_PIDS
constexpr yarp::conf::vocab32_t VOCAB_PID
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
constexpr yarp::conf::vocab32_t VOCAB_VELOCITY_MOVE_GROUP
constexpr yarp::conf::vocab32_t VOCAB_VELOCITY_MOVES
constexpr yarp::conf::vocab32_t VOCAB_VELOCITY_DIRECT_SET_ONE
constexpr yarp::conf::vocab32_t VOCAB_VELOCITY_DIRECT_SET_GROUP
constexpr yarp::conf::vocab32_t VOCAB_VELOCITY_DIRECT_SET_ALL
bool ret
constexpr int PROTOCOL_VERSION_TWEAK
constexpr int PROTOCOL_VERSION_MINOR
constexpr int PROTOCOL_VERSION_MAJOR
const yarp::os::LogComponent & REMOTECONTROLBOARD()
#define ReturnValue_ok
Definition ReturnValue.h:80
virtual return_getDesiredVelocityGroup getDesiredVelocityGroupRPC(const std::vector< std::int32_t > &j) const
virtual yarp::dev::ReturnValue setManualBrakeActiveRPC(const std::int32_t j, const bool active)
virtual bool checkProtocolVersion()
virtual return_getDesiredVelocityAll getDesiredVelocityAllRPC() const
virtual yarp::dev::ReturnValue setAutoBrakeEnabledRPC(const std::int32_t j, const bool enabled)
virtual return_getAxes getAxesRPC() const
virtual return_getAutoBrakeEnabled getAutoBrakeEnabledRPC(const std::int32_t j) const
virtual return_isJointBraked isJointBrakedRPC(const std::int32_t j) const
virtual return_getDesiredVelocityOne getDesiredVelocityOneRPC(const std::int32_t j) const
void run() override
Loop function.
void setOwner(StateExtendedInputPort *o)
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
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.
yarp::os::PortReaderBuffer< yarp::sig::Vector > state_buffer
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.
yarp::dev::impl::jointData last_wholePart
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
yarp::os::PortWriterBuffer< CommandMessage > command_buffer
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.
yarp::dev::ReturnValue getDesiredVelocity(const int jnt, double &vel) override
Get the last reference velocity set by setDesiredVelocity() for a single joint.
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.
yarp::dev::ReturnValue isJointBraked(int j, bool &braked) const override
Check is the joint brake is currently active.
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.
DiagnosticThread * diagnosticThread
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.
yarp::dev::impl::jointData last_singleJoint
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.
yarp::dev::ReturnValue setManualBrakeActive(int j, bool active) override
Enables/Disables manually the joint brake.
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.
yarp::dev::ReturnValue getAutoBrakeEnabled(int j, bool &enabled) const override
checks if the automatic joint brake mode is enabled or disabled.
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
Get the number of available motors.
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)
yarp::dev::ReturnValue setAutoBrakeEnabled(int j, bool enabled) override
Enables/Disables the automatic joint brake.
bool get1V1I2D(int code, int axis, double *v1, double *v2)
bool resetEncoders() override
Reset encoders.
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 getLastJointFault(int j, int &fault, std::string &message) override
bool get1V1D(int code, double &v) const
Send a GET command expecting a double value in return.
yarp::os::Port command_p
bool setRefSpeeds(const int n_joint, const int *joints, const double *spds) override
Set reference speed on all joints.
ControlBoardMsgs m_RPC
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.
StateExtendedInputPort extendedIntputStatePort
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.
yarp::os::Port m_rpcPort
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.
yarp::dev::ReturnValue setDesiredVelocity(int jnt, double vel) override
Set the velocity of single joint.
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.
void setTimeout(const double &timeout)
setTimeout, set the timeout for retrieving data
bool getLastVector(int field, double *data, Stamp &stamp, double &localArrivalTime)
bool getLastSingle(int j, int field, double *data, Stamp &stamp, double &localArrivalTime)
void getEstFrequency(int &ite, double &av, double &min, double &max)
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
yarp::sig::VectorOf< float > pwmDutycycle
Definition jointData.h:41
yarp::sig::VectorOf< double > motorVelocity
Definition jointData.h:35
yarp::sig::VectorOf< double > jointAcceleration
Definition jointData.h:31
yarp::sig::VectorOf< int > controlMode
Definition jointData.h:45
yarp::sig::VectorOf< int > interactionMode
Definition jointData.h:47
yarp::sig::VectorOf< double > current
Definition jointData.h:43
yarp::sig::VectorOf< double > motorAcceleration
Definition jointData.h:37
yarp::sig::VectorOf< double > motorPosition
Definition jointData.h:33
yarp::sig::VectorOf< double > torque
Definition jointData.h:39
yarp::sig::VectorOf< double > jointPosition
Definition jointData.h:27
yarp::sig::VectorOf< double > jointVelocity
Definition jointData.h:29
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:65
void addVocab32(yarp::conf::vocab32_t x)
Places a 32 bit 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:359
Bottle & addList()
Places an empty nested list in the bottle, at the end of the list.
Definition Bottle.cpp:188
size_type size() const
Gets the number of elements in the bottle.
Definition Bottle.cpp:257
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:252
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:176
std::string toString() const override
Gives a human-readable textual representation of the bottle.
Definition Bottle.cpp:217
A mini-server for performing network communication in the background.
std::string getName() const override
Get name of port.
void close() override
Stop port activity.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
void interrupt() override
Interrupt any current reads or writes attached to the port.
void useCallback(TypedReaderCallback< T > &callback) override
Set an object whose onRead method will be called when data is available.
void setStrict(bool strict=true) override
Call this to strictly keep all messages, or allow old ones to be quietly dropped.
void write(bool forceStrict=false)
Write the current object being returned by BufferedPort::prepare.
virtual std::string getName() const
Get name of port.
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:1072
An abstraction for a periodic thread.
PeriodicThread(double period, ShouldUseSystemClock useSystemClock=ShouldUseSystemClock::No, PeriodicThreadClock clockAccuracy=PeriodicThreadClock::Relative)
Constructor.
bool start()
Call this to start the thread.
void stop()
Call this to stop the thread, this call blocks until the thread is terminated (and releaseThread() ca...
bool write(const PortWriter &writer, const PortWriter *callback=nullptr) const override
Write an object to the port.
Definition Port.cpp:395
bool addOutput(const std::string &name) override
Add an output connection to the specified port.
Definition Port.cpp:320
void interrupt() override
Interrupt any current reads or writes attached to the port.
Definition Port.cpp:347
void close() override
Stop port activity.
Definition Port.cpp:330
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
Definition Port.cpp:79
Group a pair of objects to be sent and received together.
Preferences for the port's Quality of Service.
Definition QosStyle.h:23
A base class for nested structures that can be searched.
Definition Searchable.h:31
An abstraction for a time stamp and/or sequence number.
Definition Stamp.h:21
double getTime() const
Get the time stamp.
Definition Stamp.cpp:34
virtual yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
Definition Value.cpp:228
virtual yarp::conf::vocab32_t asVocab32() const
Get 32 bit vocabulary identifier as an integer.
Definition Value.cpp:234
virtual bool asBool() const
Get boolean value.
Definition Value.cpp:192
virtual std::int32_t asInt32() const
Get 32-bit integer value.
Definition Value.cpp:210
virtual Bottle * asList() const
Get list value.
Definition Value.cpp:252
virtual std::string asString() const
Get string value.
Definition Value.cpp:246
yarp::os::WireLink & yarp()
Get YARP state associated with this object.
Definition Wire.h:28
void resize(size_t size) override
Resize the vector.
Definition Vector.h:211
T * data()
Return a pointer to the first element of the vector.
Definition Vector.h:196
#define yCInfo(component,...)
#define yCError(component,...)
#define yCAssert(component, x)
#define yCDebug(component,...)
For streams capable of holding different kinds of content, check what they actually have.
PidControlTypeEnum
Definition PidEnums.h:15
An interface to the operating system, including Port based communication.