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
117
119{
120 bool error=false;
121 // verify protocol
122 Bottle cmd, reply;
125 rpc_p.write(cmd, reply);
126
127 // check size and format of messages, expected [prot] int int int [ok]
128 if (reply.size() != 5) {
129 error = true;
130 }
131
132 if (reply.get(0).asVocab32() != VOCAB_PROTOCOL_VERSION) {
133 error = true;
134 }
135
136 if (!error)
137 {
138 protocolVersion.major=reply.get(1).asInt32();
139 protocolVersion.minor=reply.get(2).asInt32();
140 protocolVersion.tweak=reply.get(3).asInt32();
141
142 //verify protocol
144 error = true;
145 }
146
148 error = true;
149 }
150 }
151
152 if (!error) {
153 return true;
154 }
155
156 // protocol did not match
158 "Expecting protocol %d %d %d, but the device we are connecting to has protocol version %d %d %d",
165
166 bool ret;
167 if (ignore)
168 {
169 yCWarning(REMOTECONTROLBOARD, "Ignoring error but please update YARP or the remotecontrolboard implementation");
170 ret = true;
171 }
172 else
173 {
174 yCError(REMOTECONTROLBOARD, "Please update YARP or the remotecontrolboard implementation");
175 ret = false;
176 }
177
178 return ret;
179}
180
182{
183 if (!parseParams(config)) { return false; }
184
186
187 //handle local Qos
190 {
191 localQos.setThreadPriority(m_local_qos_thread_priority);
192 localQos.setThreadPolicy(m_local_qos_thread_policy);
193 localQos.setPacketPriority(m_local_qos_packet_priority);
194 }
195
196 //handle remote Qos
199 {
200 remoteQos.setThreadPriority(m_remote_qos_thread_priority);
201 remoteQos.setThreadPolicy(m_remote_qos_thread_policy);
202 remoteQos.setPacketPriority(m_remote_qos_packet_priority);
203 }
204
205 //handle param writeStrict
206 if (m_writeStrict == "on")
207 {
210 yCInfo(REMOTECONTROLBOARD, "RemoteControlBoard is ENABLING the writeStrict option for all commands");
211 }
212 else if(m_writeStrict == "off")
213 {
216 yCInfo(REMOTECONTROLBOARD, "RemoteControlBoard is DISABLING the writeStrict option for all commands");
217 }
218 else if (m_writeStrict.empty())
219 {
220 //leave the default values
221 }
222 else
223 {
224 yCError(REMOTECONTROLBOARD, "Found writeStrict option with wrong value. Accepted options are 'on' or 'off'");
225 return false;
226 }
227
228 //open ports
229 bool portProblem = false;
230 if (m_local != "") {
231 std::string s1 = m_local;
232 s1 += "/rpc:o";
233 if (!rpc_p.open(s1)) { portProblem = true; }
234 s1 = m_local;
235 s1 += "/command:o";
236 if (!command_p.open(s1)) { portProblem = true; }
237 s1 = m_local;
238 s1 += "/stateExt:i";
239 if (!extendedIntputStatePort.open(s1)) { portProblem = true; }
240 if (!portProblem)
241 {
243 }
244 }
245
246 bool connectionProblem = false;
247 if (m_remote != "" && !portProblem)
248 {
249 std::string s1 = m_remote;
250 s1 += "/rpc:i";
251 std::string s2 = m_local;
252 s2 += "/rpc:o";
253 bool ok = false;
254 // RPC port needs to be tcp, therefore no carrier option is added here
255 // ok=Network::connect(s2.c_str(), s1.c_str()); //This doesn't take into consideration possible YARP_PORT_PREFIX on local ports
256 // 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
257 ok=rpc_p.addOutput(s1); //This works because we are manipulating only remote side and let yarp handle the local side
258 if (!ok) {
259 yCError(REMOTECONTROLBOARD, "Problem connecting to %s, is the remote device available?", s1.c_str());
260 connectionProblem = true;
261 }
262
263 s1 = m_remote;
264 s1 += "/command:i";
265 s2 = m_local;
266 s2 += "/command:o";
267 //ok = Network::connect(s2.c_str(), s1.c_str(), carrier);
268 // ok=Network::connect(command_p.getName(), s1.c_str(), carrier); //doesn't take into consideration possible YARP_PORT_PREFIX on local ports
270 if (!ok) {
271 yCError(REMOTECONTROLBOARD, "Problem connecting to %s, is the remote device available?", s1.c_str());
272 connectionProblem = true;
273 }
274 // set the QoS preferences for the 'command' port
277 }
278
279 s1 = m_remote;
280 s1 += "/stateExt:o";
281 s2 = m_local;
282 s2 += "/stateExt:i";
283 // not checking return value for now since it is wip (different machines can have different compilation flags
284 ok = Network::connect(s1, extendedIntputStatePort.getName(), m_carrier);
285 if (ok)
286 {
287 // set the QoS preferences for the 'state' port
290 }
291 }
292 else
293 {
294 yCError(REMOTECONTROLBOARD, "Problem connecting to %s, is the remote device available?", s1.c_str());
295 connectionProblem = true;
296 }
297 }
298
300
301 rpc_p.close();
304 return false;
305 }
306
307 state_buffer.setStrict(false);
309
311 {
312 yCError(REMOTECONTROLBOARD) << "checkProtocolVersion failed";
313 command_buffer.detach();
314 rpc_p.close();
317 return false;
318 }
319
320 if (!isLive()) {
321 if (m_remote!="") {
322 yCError(REMOTECONTROLBOARD, "Problems with obtaining the number of controlled axes");
323 command_buffer.detach();
324 rpc_p.close();
327 return false;
328 }
329 }
330
331 if (m_diagnostic)
332 {
336 }
337
338 // allocate memory for helper struct
339 // single joint
351
352 // whole part (safe here because we already got the nj
364 return true;
365}
366
368{
369 if (diagnosticThread!=nullptr)
370 {
372 delete diagnosticThread;
373 }
374
378
379 rpc_p.close();
382 return true;
383}
384
385// BEGIN Helpers functions
386
388{
389 Bottle cmd, response;
390 cmd.addVocab32(v);
391 bool ok=rpc_p.write(cmd, response);
392 if (CHECK_FAIL(ok, response)) {
393 return true;
394 }
395 return false;
396}
397
399{
400 Bottle cmd, response;
401 cmd.addVocab32(v1);
402 cmd.addVocab32(v2);
403 bool ok=rpc_p.write(cmd, response);
404 if (CHECK_FAIL(ok, response)) {
405 return true;
406 }
407 return false;
408}
409
411{
412 Bottle cmd, response;
413 cmd.addVocab32(v1);
414 cmd.addVocab32(v2);
415 cmd.addInt32(axis);
416 bool ok=rpc_p.write(cmd, response);
417 if (CHECK_FAIL(ok, response)) {
418 return true;
419 }
420 return false;
421}
422
424{
425 Bottle cmd, response;
426 cmd.addVocab32(v);
427 cmd.addInt32(axis);
428 bool ok=rpc_p.write(cmd, response);
429 if (CHECK_FAIL(ok, response)) {
430 return true;
431 }
432 return false;
433}
434
435bool RemoteControlBoard::send3V1I(int v1, int v2, int v3, int j)
436{
437 Bottle cmd, response;
438 cmd.addVocab32(v1);
439 cmd.addVocab32(v2);
440 cmd.addVocab32(v3);
441 cmd.addInt32(j);
442 bool ok=rpc_p.write(cmd, response);
443 if (CHECK_FAIL(ok, response)) {
444 return true;
445 }
446 return false;
447}
448
450{
451 Bottle cmd, response;
453 cmd.addVocab32(code);
454
455 bool ok = rpc_p.write(cmd, response);
456 return CHECK_FAIL(ok, response);
457}
458
459bool RemoteControlBoard::set1V2D(int code, double v)
460{
461 Bottle cmd, response;
463 cmd.addVocab32(code);
464 cmd.addFloat64(v);
465
466 bool ok = rpc_p.write(cmd, response);
467
468 return CHECK_FAIL(ok, response);
469}
470
471bool RemoteControlBoard::set1V1I(int code, int v)
472{
473 Bottle cmd, response;
475 cmd.addVocab32(code);
476 cmd.addInt32(v);
477
478 bool ok = rpc_p.write(cmd, response);
479
480 return CHECK_FAIL(ok, response);
481}
482
483bool RemoteControlBoard::get1V1D(int code, double& v) const
484{
485 Bottle cmd;
486 Bottle response;
488 cmd.addVocab32(code);
489
490 bool ok = rpc_p.write(cmd, response);
491
492 if (CHECK_FAIL(ok, response)) {
493 // response should be [cmd] [name] value
494 v = response.get(2).asFloat64();
495
496 getTimeStamp(response, lastStamp);
497 return true;
498 }
499
500 return false;
501}
502
503bool RemoteControlBoard::get1V1I(int code, int& v) const
504{
505 Bottle cmd;
506 Bottle response;
508 cmd.addVocab32(code);
509
510 bool ok = rpc_p.write(cmd, response);
511
512 if (CHECK_FAIL(ok, response)) {
513 // response should be [cmd] [name] value
514 v = response.get(2).asInt32();
515
516 getTimeStamp(response, lastStamp);
517 return true;
518 }
519
520 return false;
521}
522
523bool RemoteControlBoard::set1V1I1D(int code, int j, double val)
524{
525 Bottle cmd, response;
527 cmd.addVocab32(code);
528 cmd.addInt32(j);
529 cmd.addFloat64(val);
530 bool ok = rpc_p.write(cmd, response);
531 return CHECK_FAIL(ok, response);
532}
533
534bool RemoteControlBoard::set1V1I2D(int code, int j, double val1, double val2)
535{
536 Bottle cmd, response;
538 cmd.addVocab32(code);
539 cmd.addInt32(j);
540 cmd.addFloat64(val1);
541 cmd.addFloat64(val2);
542
543 bool ok = rpc_p.write(cmd, response);
544 return CHECK_FAIL(ok, response);
545}
546
547bool RemoteControlBoard::set1VDA(int v, const double *val)
548{
549 if (!isLive()) {
550 return false;
551 }
552 Bottle cmd, response;
554 cmd.addVocab32(v);
555 Bottle& l = cmd.addList();
556 for (size_t i = 0; i < nj; i++) {
557 l.addFloat64(val[i]);
558 }
559 bool ok = rpc_p.write(cmd, response);
560 return CHECK_FAIL(ok, response);
561}
562
563bool RemoteControlBoard::set2V1DA(int v1, int v2, const double *val)
564{
565 if (!isLive()) {
566 return false;
567 }
568 Bottle cmd, response;
570 cmd.addVocab32(v1);
571 cmd.addVocab32(v2);
572 Bottle& l = cmd.addList();
573 for (size_t i = 0; i < nj; i++) {
574 l.addFloat64(val[i]);
575 }
576 bool ok = rpc_p.write(cmd, response);
577 return CHECK_FAIL(ok, response);
578}
579
580bool RemoteControlBoard::set2V2DA(int v1, int v2, const double *val1, const double *val2)
581{
582 if (!isLive()) {
583 return false;
584 }
585 Bottle cmd, response;
587 cmd.addVocab32(v1);
588 cmd.addVocab32(v2);
589 Bottle& l1 = cmd.addList();
590 for (size_t i = 0; i < nj; i++) {
591 l1.addFloat64(val1[i]);
592 }
593 Bottle& l2 = cmd.addList();
594 for (size_t i = 0; i < nj; i++) {
595 l2.addFloat64(val2[i]);
596 }
597 bool ok = rpc_p.write(cmd, response);
598 return CHECK_FAIL(ok, response);
599}
600
601bool RemoteControlBoard::set1V1I1IA1DA(int v, const int len, const int *val1, const double *val2)
602{
603 if (!isLive()) {
604 return false;
605 }
606 Bottle cmd, response;
608 cmd.addVocab32(v);
609 cmd.addInt32(len);
610 int i;
611 Bottle& l1 = cmd.addList();
612 for (i = 0; i < len; i++) {
613 l1.addInt32(val1[i]);
614 }
615 Bottle& l2 = cmd.addList();
616 for (i = 0; i < len; i++) {
617 l2.addFloat64(val2[i]);
618 }
619 bool ok = rpc_p.write(cmd, response);
620 return CHECK_FAIL(ok, response);
621}
622
623bool RemoteControlBoard::set2V1I1D(int v1, int v2, int axis, double val)
624{
625 Bottle cmd, response;
627 cmd.addVocab32(v1);
628 cmd.addVocab32(v2);
629 cmd.addInt32(axis);
630 cmd.addFloat64(val);
631 bool ok = rpc_p.write(cmd, response);
632 return CHECK_FAIL(ok, response);
633}
634
636{
637 if (!isLive()) {
638 return false;
639 }
640 Bottle cmd, response;
643 cmd.addVocab32(voc);
644 cmd.addVocab32(type);
645 cmd.addInt32(axis);
646 cmd.addFloat64(val);
647 bool ok = rpc_p.write(cmd, response);
648 return CHECK_FAIL(ok, response);
649}
650
652{
653 if (!isLive()) {
654 return false;
655 }
656 Bottle cmd, response;
659 cmd.addVocab32(voc);
660 cmd.addVocab32(type);
661 Bottle& l = cmd.addList();
662 for (size_t i = 0; i < nj; i++) {
663 l.addFloat64(val_arr[i]);
664 }
665 bool ok = rpc_p.write(cmd, response);
666 return CHECK_FAIL(ok, response);
667}
668
670{
671 Bottle cmd, response;
674 cmd.addVocab32(voc);
675 cmd.addVocab32(type);
676 cmd.addInt32(j);
677 bool ok = rpc_p.write(cmd, response);
678
679 if (CHECK_FAIL(ok, response))
680 {
681 *val = response.get(2).asFloat64();
682 getTimeStamp(response, lastStamp);
683 return true;
684 }
685 return false;
686}
687
689{
690 if (!isLive()) {
691 return false;
692 }
693 Bottle cmd, response;
696 cmd.addVocab32(voc);
697 cmd.addVocab32(type);
698 bool ok = rpc_p.write(cmd, response);
699 if (CHECK_FAIL(ok, response))
700 {
701 Bottle* lp = response.get(2).asList();
702 if (lp == nullptr) {
703 return false;
704 }
705 Bottle& l = *lp;
706 yCAssert(REMOTECONTROLBOARD, nj == l.size());
707 for (size_t i = 0; i < nj; i++) {
708 val[i] = l.get(i).asFloat64();
709 }
710 getTimeStamp(response, lastStamp);
711 return true;
712 }
713 return false;
714}
715
717{
718 Bottle cmd, response;
720 cmd.addVocab32(v1);
721 cmd.addVocab32(v2);
722 cmd.addInt32(axis);
723 bool ok = rpc_p.write(cmd, response);
724 return CHECK_FAIL(ok, response);
725}
726
727bool RemoteControlBoard::get1V1I1D(int v, int j, double *val)
728{
729 Bottle cmd, response;
731 cmd.addVocab32(v);
732 cmd.addInt32(j);
733 bool ok = rpc_p.write(cmd, response);
734
735 if (CHECK_FAIL(ok, response)) {
736 // ok
737 *val = response.get(2).asFloat64();
738
739 getTimeStamp(response, lastStamp);
740 return true;
741 }
742 return false;
743}
744
745bool RemoteControlBoard::get1V1I1I(int v, int j, int *val)
746{
747 Bottle cmd, response;
749 cmd.addVocab32(v);
750 cmd.addInt32(j);
751 bool ok = rpc_p.write(cmd, response);
752 if (CHECK_FAIL(ok, response)) {
753 // ok
754 *val = response.get(2).asInt32();
755
756 getTimeStamp(response, lastStamp);
757 return true;
758 }
759 return false;
760}
761
762bool RemoteControlBoard::get2V1I1D(int v1, int v2, int j, double *val)
763{
764 Bottle cmd, response;
766 cmd.addVocab32(v1);
767 cmd.addVocab32(v2);
768 cmd.addInt32(j);
769 bool ok = rpc_p.write(cmd, response);
770
771 if (CHECK_FAIL(ok, response)) {
772 // ok
773 *val = response.get(2).asFloat64();
774
775 getTimeStamp(response, lastStamp);
776 return true;
777 }
778 return false;
779}
780
781bool RemoteControlBoard::get2V1I2D(int v1, int v2, int j, double *val1, double *val2)
782{
783 Bottle cmd, response;
785 cmd.addVocab32(v1);
786 cmd.addVocab32(v2);
787 cmd.addInt32(j);
788 bool ok = rpc_p.write(cmd, response);
789 if (CHECK_FAIL(ok, response)) {
790 // ok
791 *val1 = response.get(2).asFloat64();
792 *val2 = response.get(3).asFloat64();
793
794 getTimeStamp(response, lastStamp);
795 return true;
796 }
797 return false;
798}
799
800bool RemoteControlBoard::get1V1I2D(int code, int axis, double *v1, double *v2)
801{
802 Bottle cmd, response;
804 cmd.addVocab32(code);
805 cmd.addInt32(axis);
806
807 bool ok = rpc_p.write(cmd, response);
808
809 if (CHECK_FAIL(ok, response)) {
810 *v1 = response.get(2).asFloat64();
811 *v2 = response.get(3).asFloat64();
812 return true;
813 }
814 return false;
815}
816
817bool RemoteControlBoard::get1V1I1B(int v, int j, bool &val)
818{
819 Bottle cmd, response;
821 cmd.addVocab32(v);
822 cmd.addInt32(j);
823 bool ok = rpc_p.write(cmd, response);
824 if (CHECK_FAIL(ok, response)) {
825 val = (response.get(2).asInt32()!=0);
826 getTimeStamp(response, lastStamp);
827 return true;
828 }
829 return false;
830}
831
832bool RemoteControlBoard::get1V1I1IA1B(int v, const int len, const int *val1, bool &retVal)
833{
834 Bottle cmd, response;
836 cmd.addVocab32(v);
837 cmd.addInt32(len);
838 Bottle& l1 = cmd.addList();
839 for (int i = 0; i < len; i++) {
840 l1.addInt32(val1[i]);
841 }
842
843 bool ok = rpc_p.write(cmd, response);
844
845 if (CHECK_FAIL(ok, response)) {
846 retVal = (response.get(2).asInt32()!=0);
847 getTimeStamp(response, lastStamp);
848 return true;
849 }
850 return false;
851}
852
853bool RemoteControlBoard::get2V1I1IA1DA(int v1, int v2, const int n_joints, const int *joints, double *retVals, std::string functionName)
854{
855 Bottle cmd, response;
856 if (!isLive()) {
857 return false;
858 }
859
861 cmd.addVocab32(v1);
862 cmd.addVocab32(v2);
863 cmd.addInt32(n_joints);
864
865 Bottle& l1 = cmd.addList();
866 for (int i = 0; i < n_joints; i++) {
867 l1.addInt32(joints[i]);
868 }
869
870 bool ok = rpc_p.write(cmd, response);
871
872 if (CHECK_FAIL(ok, response))
873 {
874 int i;
875 Bottle& list = *(response.get(0).asList());
876 yCAssert(REMOTECONTROLBOARD, list.size() >= (size_t) n_joints)
877
878 if (list.size() != (size_t )n_joints)
879 {
881 "%s length of response does not match: expected %d, received %zu\n ",
882 functionName.c_str(),
883 n_joints ,
884 list.size() );
885 return false;
886 }
887 else
888 {
889 for (i = 0; i < n_joints; i++)
890 {
891 retVals[i] = (double) list.get(i).asFloat64();
892 }
893 return true;
894 }
895 }
896 return false;
897}
898
899bool RemoteControlBoard::get1V1B(int v, bool &val)
900{
901 Bottle cmd, response;
903 cmd.addVocab32(v);
904 bool ok = rpc_p.write(cmd, response);
905 if (CHECK_FAIL(ok, response)) {
906 val = (response.get(2).asInt32()!=0);
907 getTimeStamp(response, lastStamp);
908 return true;
909 }
910 return false;
911}
912
913bool RemoteControlBoard::get1VIA(int v, int *val)
914{
915 if (!isLive()) {
916 return false;
917 }
918 Bottle cmd, response;
920 cmd.addVocab32(v);
921 bool ok = rpc_p.write(cmd, response);
922 if (CHECK_FAIL(ok, response)) {
923 Bottle* lp = response.get(2).asList();
924 if (lp == nullptr) {
925 return false;
926 }
927 Bottle& l = *lp;
928 yCAssert(REMOTECONTROLBOARD, nj == l.size());
929 for (size_t i = 0; i < nj; i++) {
930 val[i] = l.get(i).asInt32();
931 }
932
933 getTimeStamp(response, lastStamp);
934
935 return true;
936 }
937 return false;
938}
939
940bool RemoteControlBoard::get1VDA(int v, double *val)
941{
942 if (!isLive()) {
943 return false;
944 }
945 Bottle cmd, response;
947 cmd.addVocab32(v);
948 bool ok = rpc_p.write(cmd, response);
949 if (CHECK_FAIL(ok, response)) {
950 Bottle* lp = response.get(2).asList();
951 if (lp == nullptr) {
952 return false;
953 }
954 Bottle& l = *lp;
955 yCAssert(REMOTECONTROLBOARD, nj == l.size());
956 for (size_t i = 0; i < nj; i++) {
957 val[i] = l.get(i).asFloat64();
958 }
959
960 getTimeStamp(response, lastStamp);
961
962 return true;
963 }
964 return false;
965}
966
967bool RemoteControlBoard::get1V1DA(int v1, double *val)
968{
969 if (!isLive()) {
970 return false;
971 }
972 Bottle cmd, response;
974 cmd.addVocab32(v1);
975 bool ok = rpc_p.write(cmd, response);
976
977 if (CHECK_FAIL(ok, response)) {
978 Bottle* lp = response.get(2).asList();
979 if (lp == nullptr) {
980 return false;
981 }
982 Bottle& l = *lp;
983 yCAssert(REMOTECONTROLBOARD, nj == l.size());
984 for (size_t i = 0; i < nj; i++) {
985 val[i] = l.get(i).asFloat64();
986 }
987
988 getTimeStamp(response, lastStamp);
989 return true;
990 }
991 return false;
992}
993
994bool RemoteControlBoard::get2V1DA(int v1, int v2, double *val)
995{
996 if (!isLive()) {
997 return false;
998 }
999 Bottle cmd, response;
1000 cmd.addVocab32(VOCAB_GET);
1001 cmd.addVocab32(v1);
1002 cmd.addVocab32(v2);
1003 bool ok = rpc_p.write(cmd, response);
1004
1005 if (CHECK_FAIL(ok, response)) {
1006 Bottle* lp = response.get(2).asList();
1007 if (lp == nullptr) {
1008 return false;
1009 }
1010 Bottle& l = *lp;
1011 yCAssert(REMOTECONTROLBOARD, nj == l.size());
1012 for (size_t i = 0; i < nj; i++) {
1013 val[i] = l.get(i).asFloat64();
1014 }
1015
1016 getTimeStamp(response, lastStamp);
1017 return true;
1018 }
1019 return false;
1020}
1021
1022bool RemoteControlBoard::get2V2DA(int v1, int v2, double *val1, double *val2)
1023{
1024 if (!isLive()) {
1025 return false;
1026 }
1027 Bottle cmd, response;
1028 cmd.addVocab32(VOCAB_GET);
1029 cmd.addVocab32(v1);
1030 cmd.addVocab32(v2);
1031 bool ok = rpc_p.write(cmd, response);
1032 if (CHECK_FAIL(ok, response)) {
1033 Bottle* lp1 = response.get(2).asList();
1034 if (lp1 == nullptr) {
1035 return false;
1036 }
1037 Bottle& l1 = *lp1;
1038 Bottle* lp2 = response.get(3).asList();
1039 if (lp2 == nullptr) {
1040 return false;
1041 }
1042 Bottle& l2 = *lp2;
1043
1044 size_t nj1 = l1.size();
1045 size_t nj2 = l2.size();
1046 // yCAssert(REMOTECONTROLBOARD, nj == nj1);
1047 // yCAssert(REMOTECONTROLBOARD, nj == nj2);
1048
1049 for (size_t i = 0; i < nj1; i++) {
1050 val1[i] = l1.get(i).asFloat64();
1051 }
1052 for (size_t i = 0; i < nj2; i++) {
1053 val2[i] = l2.get(i).asFloat64();
1054 }
1055
1056 getTimeStamp(response, lastStamp);
1057 return true;
1058 }
1059 return false;
1060}
1061
1062bool RemoteControlBoard::get1V1I1S(int code, int j, std::string &name)
1063{
1064 Bottle cmd, response;
1065 cmd.addVocab32(VOCAB_GET);
1066 cmd.addVocab32(code);
1067 cmd.addInt32(j);
1068 bool ok = rpc_p.write(cmd, response);
1069
1070 if (CHECK_FAIL(ok, response)) {
1071 name = response.get(2).asString();
1072 return true;
1073 }
1074 return false;
1075}
1076
1077
1078bool RemoteControlBoard::get1V1I1IA1DA(int v, const int len, const int *val1, double *val2)
1079{
1080 if (!isLive()) {
1081 return false;
1082 }
1083
1084 Bottle cmd, response;
1085 cmd.addVocab32(VOCAB_GET);
1086 cmd.addVocab32(v);
1087 cmd.addInt32(len);
1088 Bottle &l1 = cmd.addList();
1089 for (int i = 0; i < len; i++) {
1090 l1.addInt32(val1[i]);
1091 }
1092
1093 bool ok = rpc_p.write(cmd, response);
1094
1095 if (CHECK_FAIL(ok, response)) {
1096 Bottle* lp2 = response.get(2).asList();
1097 if (lp2 == nullptr) {
1098 return false;
1099 }
1100 Bottle& l2 = *lp2;
1101
1102 size_t nj2 = l2.size();
1103 if(nj2 != (unsigned)len)
1104 {
1105 yCError(REMOTECONTROLBOARD, "received an answer with an unexpected number of entries!");
1106 return false;
1107 }
1108 for (size_t i = 0; i < nj2; i++) {
1109 val2[i] = l2.get(i).asFloat64();
1110 }
1111
1112 getTimeStamp(response, lastStamp);
1113 return true;
1114 }
1115 return false;
1116}
1117
1118// END Helpers functions
1119
1121{
1122 return get1V1I(VOCAB_AXES, *ax);
1123}
1124
1125// BEGIN IPidControl
1126
1128{
1129 Bottle cmd, response;
1130 cmd.addVocab32(VOCAB_SET);
1131 cmd.addVocab32(VOCAB_PID);
1132 cmd.addVocab32(VOCAB_PID);
1133 cmd.addVocab32(pidtype);
1134 cmd.addInt32(j);
1135 Bottle& l = cmd.addList();
1136 l.addFloat64(pid.kp);
1137 l.addFloat64(pid.kd);
1138 l.addFloat64(pid.ki);
1139 l.addFloat64(pid.max_int);
1140 l.addFloat64(pid.max_output);
1141 l.addFloat64(pid.offset);
1142 l.addFloat64(pid.scale);
1143 l.addFloat64(pid.stiction_up_val);
1144 l.addFloat64(pid.stiction_down_val);
1145 l.addFloat64(pid.kff);
1146 bool ok = rpc_p.write(cmd, response);
1147 return CHECK_FAIL(ok, response);
1148}
1149
1151{
1152 if (!isLive()) {
1153 return false;
1154 }
1155 Bottle cmd, response;
1156 cmd.addVocab32(VOCAB_SET);
1157 cmd.addVocab32(VOCAB_PID);
1159 cmd.addVocab32(pidtype);
1160 Bottle& l = cmd.addList();
1161 for (size_t i = 0; i < nj; i++) {
1162 Bottle& m = l.addList();
1163 m.addFloat64(pids[i].kp);
1164 m.addFloat64(pids[i].kd);
1165 m.addFloat64(pids[i].ki);
1166 m.addFloat64(pids[i].max_int);
1167 m.addFloat64(pids[i].max_output);
1168 m.addFloat64(pids[i].offset);
1169 m.addFloat64(pids[i].scale);
1170 m.addFloat64(pids[i].stiction_up_val);
1171 m.addFloat64(pids[i].stiction_down_val);
1172 m.addFloat64(pids[i].kff);
1173 }
1174
1175 bool ok = rpc_p.write(cmd, response);
1176 return CHECK_FAIL(ok, response);
1177}
1178
1180{
1181 return setValWithPidType(VOCAB_REF, pidtype, j, ref);
1182}
1183
1188
1193
1195{
1196 return setValWithPidType(VOCAB_LIMS, pidtype, limits);
1197}
1198
1200{
1201 return getValWithPidType(VOCAB_ERR, pidtype, j, err);
1202}
1203
1205{
1206 return getValWithPidType(VOCAB_ERRS, pidtype, errs);
1207}
1208
1210{
1211 Bottle cmd, response;
1212 cmd.addVocab32(VOCAB_GET);
1213 cmd.addVocab32(VOCAB_PID);
1214 cmd.addVocab32(VOCAB_PID);
1215 cmd.addVocab32(pidtype);
1216 cmd.addInt32(j);
1217 bool ok = rpc_p.write(cmd, response);
1218 if (CHECK_FAIL(ok, response)) {
1219 Bottle* lp = response.get(2).asList();
1220 if (lp == nullptr) {
1221 return false;
1222 }
1223 Bottle& l = *lp;
1224 pid->kp = l.get(0).asFloat64();
1225 pid->kd = l.get(1).asFloat64();
1226 pid->ki = l.get(2).asFloat64();
1227 pid->max_int = l.get(3).asFloat64();
1228 pid->max_output = l.get(4).asFloat64();
1229 pid->offset = l.get(5).asFloat64();
1230 pid->scale = l.get(6).asFloat64();
1231 pid->stiction_up_val = l.get(7).asFloat64();
1232 pid->stiction_down_val = l.get(8).asFloat64();
1233 pid->kff = l.get(9).asFloat64();
1234 return true;
1235 }
1236 return false;
1237}
1238
1240{
1241 if (!isLive()) {
1242 return false;
1243 }
1244 Bottle cmd, response;
1245 cmd.addVocab32(VOCAB_GET);
1246 cmd.addVocab32(VOCAB_PID);
1248 cmd.addVocab32(pidtype);
1249 bool ok = rpc_p.write(cmd, response);
1250 if (CHECK_FAIL(ok, response))
1251 {
1252 Bottle* lp = response.get(2).asList();
1253 if (lp == nullptr) {
1254 return false;
1255 }
1256 Bottle& l = *lp;
1257 yCAssert(REMOTECONTROLBOARD, nj == l.size());
1258 for (size_t i = 0; i < nj; i++)
1259 {
1260 Bottle* mp = l.get(i).asList();
1261 if (mp == nullptr) {
1262 return false;
1263 }
1264 pids[i].kp = mp->get(0).asFloat64();
1265 pids[i].kd = mp->get(1).asFloat64();
1266 pids[i].ki = mp->get(2).asFloat64();
1267 pids[i].max_int = mp->get(3).asFloat64();
1268 pids[i].max_output = mp->get(4).asFloat64();
1269 pids[i].offset = mp->get(5).asFloat64();
1270 pids[i].scale = mp->get(6).asFloat64();
1271 pids[i].stiction_up_val = mp->get(7).asFloat64();
1272 pids[i].stiction_down_val = mp->get(8).asFloat64();
1273 pids[i].kff = mp->get(9).asFloat64();
1274 }
1275 return true;
1276 }
1277 return false;
1278}
1279
1281{
1282 return getValWithPidType(VOCAB_REF, pidtype, j, ref);
1283}
1284
1289
1294
1296{
1297 return getValWithPidType(VOCAB_LIMS, pidtype, limits);
1298}
1299
1301{
1302 if (!isLive()) {
1303 return false;
1304 }
1305 Bottle cmd, response;
1306 cmd.addVocab32(VOCAB_SET);
1307 cmd.addVocab32(VOCAB_PID);
1309 cmd.addVocab32(pidtype);
1310 cmd.addInt32(j);
1311 bool ok = rpc_p.write(cmd, response);
1312 return CHECK_FAIL(ok, response);
1313}
1314
1316{
1317 if (!isLive()) {
1318 return false;
1319 }
1320 Bottle cmd, response;
1321 cmd.addVocab32(VOCAB_SET);
1322 cmd.addVocab32(VOCAB_PID);
1324 cmd.addVocab32(pidtype);
1325 cmd.addInt32(j);
1326 bool ok = rpc_p.write(cmd, response);
1327 return CHECK_FAIL(ok, response);
1328}
1329
1331{
1332 if (!isLive()) {
1333 return false;
1334 }
1335 Bottle cmd, response;
1336 cmd.addVocab32(VOCAB_SET);
1337 cmd.addVocab32(VOCAB_PID);
1339 cmd.addVocab32(pidtype);
1340 cmd.addInt32(j);
1341 bool ok = rpc_p.write(cmd, response);
1342 return CHECK_FAIL(ok, response);
1343}
1344
1346{
1347 Bottle cmd, response;
1348 cmd.addVocab32(VOCAB_GET);
1349 cmd.addVocab32(VOCAB_PID);
1351 cmd.addVocab32(pidtype);
1352 cmd.addInt32(j);
1353 bool ok = rpc_p.write(cmd, response);
1354 if (CHECK_FAIL(ok, response))
1355 {
1356 *enabled = response.get(2).asBool();
1357 return true;
1358 }
1359 return false;
1360}
1361
1363{
1364 return getValWithPidType(VOCAB_OUTPUT, pidtype, j, out);
1365}
1366
1371
1373{
1375}
1376
1377// END IPidControl
1378
1379// BEGIN IEncoder
1380
1382{
1383 return set1V1I(VOCAB_E_RESET, j);
1384}
1385
1390
1392{
1393 return set1V1I1D(VOCAB_ENCODER, j, val);
1394}
1395
1397{
1398 return set1VDA(VOCAB_ENCODERS, vals);
1399}
1400
1402{
1403 double localArrivalTime = 0.0;
1404
1405 extendedPortMutex.lock();
1407 extendedPortMutex.unlock();
1408 return ret;
1409}
1410
1411bool RemoteControlBoard::getEncoderTimed(int j, double *v, double *t)
1412{
1413 double localArrivalTime = 0.0;
1414
1415 extendedPortMutex.lock();
1417 *t=lastStamp.getTime();
1418 extendedPortMutex.unlock();
1419 return ret;
1420}
1421
1423{
1424 double localArrivalTime = 0.0;
1425
1426 extendedPortMutex.lock();
1428 extendedPortMutex.unlock();
1429
1430 return ret;
1431}
1432
1433bool RemoteControlBoard::getEncodersTimed(double *encs, double *ts)
1434{
1435 double localArrivalTime=0.0;
1436
1437 extendedPortMutex.lock();
1439 std::fill_n(ts, nj, lastStamp.getTime());
1440 extendedPortMutex.unlock();
1441 return ret;
1442}
1443
1445{
1446 double localArrivalTime=0.0;
1447
1448 extendedPortMutex.lock();
1450 extendedPortMutex.unlock();
1451 return ret;
1452}
1453
1463
1465{
1466 double localArrivalTime=0.0;
1467 extendedPortMutex.lock();
1469 extendedPortMutex.unlock();
1470 return ret;
1471}
1472
1481
1482// END IEncoder
1483
1484// BEGIN IRemoteVariable
1485
1487{
1488 Bottle cmd, response;
1489 cmd.addVocab32(VOCAB_GET);
1492 cmd.addString(key);
1493 bool ok = rpc_p.write(cmd, response);
1494 if (CHECK_FAIL(ok, response))
1495 {
1496 val = *(response.get(2).asList());
1497 return true;
1498 }
1499 return false;
1500}
1501
1503{
1504 Bottle cmd, response;
1505 cmd.addVocab32(VOCAB_SET);
1508 cmd.addString(key);
1509 cmd.append(val);
1510 //std::string s = cmd.toString();
1511 bool ok = rpc_p.write(cmd, response);
1512
1513 return CHECK_FAIL(ok, response);
1514}
1515
1516
1518{
1519 Bottle cmd, response;
1520 cmd.addVocab32(VOCAB_GET);
1523 bool ok = rpc_p.write(cmd, response);
1524 //std::string s = response.toString();
1525 if (CHECK_FAIL(ok, response))
1526 {
1527 *listOfKeys = *(response.get(2).asList());
1528 //std::string s = listOfKeys->toString();
1529 return true;
1530 }
1531 return false;
1532}
1533
1534// END IRemoteVariable
1535
1536// BEGIN IMotor
1537
1542
1544{
1545 return get1V1I1D(VOCAB_TEMPERATURE, m, val);
1546}
1547
1552
1554{
1555 return get1V1I1D(VOCAB_TEMPERATURE_LIMIT, m, val);
1556}
1557
1558bool RemoteControlBoard::setTemperatureLimit (int m, const double val)
1559{
1560 return set1V1I1D(VOCAB_TEMPERATURE_LIMIT, m, val);
1561}
1562
1564{
1565 return get1V1I1D(VOCAB_GEARBOX_RATIO, m, val);
1566}
1567
1568bool RemoteControlBoard::setGearboxRatio(int m, const double val)
1569{
1570 return set1V1I1D(VOCAB_GEARBOX_RATIO, m, val);
1571}
1572
1573// END IMotor
1574
1575// BEGIN IMotorEncoder
1576
1581
1586
1587bool RemoteControlBoard::setMotorEncoder(int j, const double val)
1588{
1589 return set1V1I1D(VOCAB_MOTOR_ENCODER, j, val);
1590}
1591
1596
1601
1603{
1605}
1606
1608{
1609 double localArrivalTime = 0.0;
1610
1611 extendedPortMutex.lock();
1613 extendedPortMutex.unlock();
1614 return ret;
1615}
1616
1617bool RemoteControlBoard::getMotorEncoderTimed(int j, double *v, double *t)
1618{
1619 double localArrivalTime = 0.0;
1620
1621 extendedPortMutex.lock();
1623 *t=lastStamp.getTime();
1624 extendedPortMutex.unlock();
1625 return ret;
1626}
1627
1629{
1630 double localArrivalTime=0.0;
1631
1632 extendedPortMutex.lock();
1634 extendedPortMutex.unlock();
1635
1636 return ret;
1637}
1638
1639bool RemoteControlBoard::getMotorEncodersTimed(double *encs, double *ts)
1640{
1641 double localArrivalTime=0.0;
1642
1643 extendedPortMutex.lock();
1645 std::fill_n(ts, nj, lastStamp.getTime());
1646 extendedPortMutex.unlock();
1647 return ret;
1648}
1649
1658
1667
1676
1685
1690
1691// END IMotorEncoder
1692
1693// BEGIN IPreciselyTimed
1694
1700{
1701 Stamp ret;
1702// mutex.lock();
1703 ret = lastStamp;
1704// mutex.unlock();
1705 return ret;
1706}
1707
1708// END IPreciselyTimed
1709
1710// BEGIN IPositionControl
1711
1713{
1714 return set1V1I1D(VOCAB_POSITION_MOVE, j, ref);
1715}
1716
1717bool RemoteControlBoard::positionMove(const int n_joint, const int *joints, const double *refs)
1718{
1720}
1721
1723{
1725}
1726
1728{
1729 return get1V1I1D(VOCAB_POSITION_MOVE, joint, ref);
1730}
1731
1736
1741
1743{
1745}
1746
1747bool RemoteControlBoard::relativeMove(const int n_joint, const int *joints, const double *refs)
1748{
1750}
1751
1753{
1755}
1756
1758{
1759 return get1V1I1B(VOCAB_MOTION_DONE, j, *flag);
1760}
1761
1762bool RemoteControlBoard::checkMotionDone(const int n_joint, const int *joints, bool *flag)
1763{
1765}
1766
1771
1773{
1774 return set1V1I1D(VOCAB_REF_SPEED, j, sp);
1775}
1776
1777bool RemoteControlBoard::setRefSpeeds(const int n_joint, const int *joints, const double *spds)
1778{
1780}
1781
1783{
1784 return set1VDA(VOCAB_REF_SPEEDS, spds);
1785}
1786
1788{
1789 return set1V1I1D(VOCAB_REF_ACCELERATION, j, acc);
1790}
1791
1792bool RemoteControlBoard::setRefAccelerations(const int n_joint, const int *joints, const double *accs)
1793{
1795}
1796
1801
1803{
1804 return get1V1I1D(VOCAB_REF_SPEED, j, ref);
1805}
1806
1807bool RemoteControlBoard::getRefSpeeds(const int n_joint, const int *joints, double *spds)
1808{
1810}
1811
1813{
1814 return get1VDA(VOCAB_REF_SPEEDS, spds);
1815}
1816
1818{
1819 return get1V1I1D(VOCAB_REF_ACCELERATION, j, acc);
1820}
1821
1826
1831
1833{
1834 return set1V1I(VOCAB_STOP, j);
1835}
1836
1837bool RemoteControlBoard::stop(const int len, const int *val1)
1838{
1839 if (!isLive()) {
1840 return false;
1841 }
1842 Bottle cmd, response;
1843 cmd.addVocab32(VOCAB_SET);
1845 cmd.addInt32(len);
1846 int i;
1847 Bottle& l1 = cmd.addList();
1848 for (i = 0; i < len; i++) {
1849 l1.addInt32(val1[i]);
1850 }
1851
1852 bool ok = rpc_p.write(cmd, response);
1853 return CHECK_FAIL(ok, response);
1854}
1855
1857{
1858 return set1V(VOCAB_STOPS);
1859}
1860
1861// END IPositionControl
1862
1863// BEGIN IJoint Fault
1864bool RemoteControlBoard::getLastJointFault(int j, int& fault, std::string& message)
1865{
1866 Bottle cmd, response;
1867
1868 cmd.addVocab32(VOCAB_GET);
1871 cmd.addInt32(j);
1872
1873 bool ok = rpc_p.write(cmd, response);
1874
1875 std::string ss = response.toString();
1876
1877 if (CHECK_FAIL(ok, response))
1878 {
1879 fault = response.get(1).asInt32();
1880 message = response.get(2).asString();
1881 return true;
1882 }
1883 return false;
1884}
1885// END IJointFault
1886
1887// BEGIN IVelocityControl
1888
1890{
1891 // return set1V1I1D(VOCAB_VELOCITY_MOVE, j, v);
1892 if (!isLive()) {
1893 return false;
1894 }
1896 c.head.clear();
1897 c.head.addVocab32(VOCAB_VELOCITY_MOVE);
1898 c.head.addInt32(j);
1899 c.body.resize(1);
1900 memcpy(&(c.body[0]), &v, sizeof(double));
1902 return true;
1903}
1904
1906{
1907 if (!isLive()) {
1908 return false;
1909 }
1911 c.head.clear();
1912 c.head.addVocab32(VOCAB_VELOCITY_MOVES);
1913 c.body.resize(nj);
1914 memcpy(&(c.body[0]), v, sizeof(double)*nj);
1916 return true;
1917}
1918
1919// END IVelocityControl
1920
1921// BEGIN IAmplifierControl
1922
1924{
1925 return set1V1I(VOCAB_AMP_ENABLE, j);
1926}
1927
1929{
1930 return set1V1I(VOCAB_AMP_DISABLE, j);
1931}
1932
1934{
1935 return get1VIA(VOCAB_AMP_STATUS, st);
1936}
1937
1939{
1941}
1942
1944{
1945 return set1V1I1D(VOCAB_AMP_MAXCURRENT, j, v);
1946}
1947
1949{
1950 return get1V1I1D(VOCAB_AMP_MAXCURRENT, j, v);
1951}
1952
1954{
1956}
1957
1958bool RemoteControlBoard::setNominalCurrent(int m, const double val)
1959{
1961}
1962
1964{
1965 return get1V1I1D(VOCAB_AMP_PEAK_CURRENT, m, val);
1966}
1967
1968bool RemoteControlBoard::setPeakCurrent(int m, const double val)
1969{
1970 return set1V1I1D(VOCAB_AMP_PEAK_CURRENT, m, val);
1971}
1972
1973bool RemoteControlBoard::getPWM(int m, double* val)
1974{
1975 double localArrivalTime = 0.0;
1976 extendedPortMutex.lock();
1978 extendedPortMutex.unlock();
1979 return ret;
1980}
1981
1983{
1984 return get1V1I1D(VOCAB_AMP_PWM_LIMIT, m, val);
1985}
1986
1987bool RemoteControlBoard::setPWMLimit(int m, const double val)
1988{
1989 return set1V1I1D(VOCAB_AMP_PWM_LIMIT, m, val);
1990}
1991
1993{
1994 return get1V1I1D(VOCAB_AMP_VOLTAGE_SUPPLY, m, val);
1995}
1996
1997// END IAmplifierControl
1998
1999// BEGIN IControlLimits
2000
2001bool RemoteControlBoard::setLimits(int axis, double min, double max)
2002{
2003 return set1V1I2D(VOCAB_LIMITS, axis, min, max);
2004}
2005
2006bool RemoteControlBoard::getLimits(int axis, double *min, double *max)
2007{
2008 return get1V1I2D(VOCAB_LIMITS, axis, min, max);
2009}
2010
2011bool RemoteControlBoard::setVelLimits(int axis, double min, double max)
2012{
2013 return set1V1I2D(VOCAB_VEL_LIMITS, axis, min, max);
2014}
2015
2016bool RemoteControlBoard::getVelLimits(int axis, double *min, double *max)
2017{
2018 return get1V1I2D(VOCAB_VEL_LIMITS, axis, min, max);
2019}
2020
2021// END IControlLimits
2022
2023// BEGIN IAxisInfo
2024
2025bool RemoteControlBoard::getAxisName(int j, std::string& name)
2026{
2027 return get1V1I1S(VOCAB_INFO_NAME, j, name);
2028}
2029
2031{
2032 return get1V1I1I(VOCAB_INFO_TYPE, j, (int*)&type);
2033}
2034
2035// END IAxisInfo
2036
2037// BEGIN IControlCalibration
2042
2047
2052
2054{
2055 return send1V(VOCAB_PARK);
2056}
2057
2058bool RemoteControlBoard::calibrateAxisWithParams(int j, unsigned int ui, double v1, double v2, double v3)
2059{
2060 Bottle cmd, response;
2061
2063 cmd.addInt32(j);
2064 cmd.addInt32(ui);
2065 cmd.addFloat64(v1);
2066 cmd.addFloat64(v2);
2067 cmd.addFloat64(v3);
2068
2069 bool ok = rpc_p.write(cmd, response);
2070
2071 if (CHECK_FAIL(ok, response)) {
2072 return true;
2073 }
2074 return false;
2075}
2076
2078{
2079 Bottle cmd, response;
2080
2082 cmd.addInt32(j);
2083 cmd.addInt32(params.type);
2084 cmd.addFloat64(params.param1);
2085 cmd.addFloat64(params.param2);
2086 cmd.addFloat64(params.param3);
2087 cmd.addFloat64(params.param4);
2088
2089 bool ok = rpc_p.write(cmd, response);
2090
2091 if (CHECK_FAIL(ok, response)) {
2092 return true;
2093 }
2094 return false;
2095}
2096
2101
2102// END IControlCalibration
2103
2104// BEGIN ITorqueControl
2105
2107{
2108 return get2V1I1D(VOCAB_TORQUE, VOCAB_REF, j, t);
2109}
2110
2112{
2113 return get2V1DA(VOCAB_TORQUE, VOCAB_REFS, t);
2114}
2115
2117{
2118 //Now we use streaming instead of rpc
2119 //return set2V1DA(VOCAB_TORQUE, VOCAB_REFS, t);
2120 if (!isLive()) {
2121 return false;
2122 }
2124 c.head.clear();
2125 c.head.addVocab32(VOCAB_TORQUES_DIRECTS);
2126
2127 c.body.resize(nj);
2128
2129 memcpy(c.body.data(), t, sizeof(double) * nj);
2130
2132 return true;
2133}
2134
2136{
2137 //return set2V1I1D(VOCAB_TORQUE, VOCAB_REF, j, v);
2138 // use the streaming port!
2139 if (!isLive()) {
2140 return false;
2141 }
2143 c.head.clear();
2144 // in streaming port only SET command can be sent, so it is implicit
2145 c.head.addVocab32(VOCAB_TORQUES_DIRECT);
2146 c.head.addInt32(j);
2147
2148 c.body.clear();
2149 c.body.resize(1);
2150 c.body[0] = v;
2152 return true;
2153}
2154
2155bool RemoteControlBoard::setRefTorques(const int n_joint, const int *joints, const double *t)
2156{
2157 //return set2V1I1D(VOCAB_TORQUE, VOCAB_REF, j, v);
2158 // use the streaming port!
2159 if (!isLive()) {
2160 return false;
2161 }
2163 c.head.clear();
2164 // in streaming port only SET command can be sent, so it is implicit
2165 c.head.addVocab32(VOCAB_TORQUES_DIRECT_GROUP);
2166 c.head.addInt32(n_joint);
2167 Bottle &jointList = c.head.addList();
2168 for (int i = 0; i < n_joint; i++) {
2169 jointList.addInt32(joints[i]);
2170 }
2171 c.body.resize(n_joint);
2172 memcpy(&(c.body[0]), t, sizeof(double)*n_joint);
2174 return true;
2175}
2176
2178{
2179 Bottle cmd, response;
2180 cmd.addVocab32(VOCAB_SET);
2183 cmd.addInt32(j);
2184 Bottle& b = cmd.addList();
2185 b.addFloat64(params.bemf);
2186 b.addFloat64(params.bemf_scale);
2187 b.addFloat64(params.ktau);
2188 b.addFloat64(params.ktau_scale);
2189 b.addFloat64(params.viscousPos);
2190 b.addFloat64(params.viscousNeg);
2191 b.addFloat64(params.coulombPos);
2192 b.addFloat64(params.coulombNeg);
2193 b.addFloat64(params.velocityThres);
2194 bool ok = rpc_p.write(cmd, response);
2195 return CHECK_FAIL(ok, response);
2196}
2197
2199{
2200 Bottle cmd, response;
2201 cmd.addVocab32(VOCAB_GET);
2204 cmd.addInt32(j);
2205 bool ok = rpc_p.write(cmd, response);
2206 if (CHECK_FAIL(ok, response)) {
2207 Bottle* lp = response.get(2).asList();
2208 if (lp == nullptr) {
2209 return false;
2210 }
2211 Bottle& l = *lp;
2212 if (l.size() != 9)
2213 {
2214 yCError(REMOTECONTROLBOARD, "getMotorTorqueParams return value not understood, size != 9");
2215 return false;
2216 }
2217 params->bemf = l.get(0).asFloat64();
2218 params->bemf_scale = l.get(1).asFloat64();
2219 params->ktau = l.get(2).asFloat64();
2220 params->ktau_scale = l.get(3).asFloat64();
2221 params->viscousPos = l.get(4).asFloat64();
2222 params->viscousNeg = l.get(5).asFloat64();
2223 params->coulombPos = l.get(6).asFloat64();
2224 params->coulombNeg = l.get(7).asFloat64();
2225 params->velocityThres = l.get(8).asFloat64();
2226 return true;
2227 }
2228 return false;
2229}
2230
2232{
2233 double localArrivalTime=0.0;
2234 extendedPortMutex.lock();
2236 extendedPortMutex.unlock();
2237 return ret;
2238}
2239
2241{
2242 double localArrivalTime=0.0;
2243 extendedPortMutex.lock();
2245 extendedPortMutex.unlock();
2246 return ret;
2247}
2248
2249bool RemoteControlBoard::getTorqueRange(int j, double *min, double* max)
2250{
2251 return get2V1I2D(VOCAB_TORQUE, VOCAB_RANGE, j, min, max);
2252}
2253
2254bool RemoteControlBoard::getTorqueRanges(double *min, double *max)
2255{
2256 return get2V2DA(VOCAB_TORQUE, VOCAB_RANGES, min, max);
2257}
2258
2259// END ITorqueControl
2260
2261// BEGIN IImpedanceControl
2262
2263bool RemoteControlBoard::getImpedance(int j, double *stiffness, double *damping)
2264{
2265 Bottle cmd, response;
2266 cmd.addVocab32(VOCAB_GET);
2269 cmd.addInt32(j);
2270 bool ok = rpc_p.write(cmd, response);
2271 if (CHECK_FAIL(ok, response)) {
2272 Bottle* lp = response.get(2).asList();
2273 if (lp == nullptr) {
2274 return false;
2275 }
2276 Bottle& l = *lp;
2277 *stiffness = l.get(0).asFloat64();
2278 *damping = l.get(1).asFloat64();
2279 return true;
2280 }
2281 return false;
2282}
2283
2285{
2286 Bottle cmd, response;
2287 cmd.addVocab32(VOCAB_GET);
2290 cmd.addInt32(j);
2291 bool ok = rpc_p.write(cmd, response);
2292 if (CHECK_FAIL(ok, response)) {
2293 Bottle* lp = response.get(2).asList();
2294 if (lp == nullptr) {
2295 return false;
2296 }
2297 Bottle& l = *lp;
2298 *offset = l.get(0).asFloat64();
2299 return true;
2300 }
2301 return false;
2302}
2303
2304bool RemoteControlBoard::setImpedance(int j, double stiffness, double damping)
2305{
2306 Bottle cmd, response;
2307 cmd.addVocab32(VOCAB_SET);
2310 cmd.addInt32(j);
2311
2312 Bottle& b = cmd.addList();
2313 b.addFloat64(stiffness);
2314 b.addFloat64(damping);
2315
2316 bool ok = rpc_p.write(cmd, response);
2317 return CHECK_FAIL(ok, response);
2318}
2319
2321{
2322 Bottle cmd, response;
2323 cmd.addVocab32(VOCAB_SET);
2326 cmd.addInt32(j);
2327
2328 Bottle& b = cmd.addList();
2329 b.addFloat64(offset);
2330
2331 bool ok = rpc_p.write(cmd, response);
2332 return CHECK_FAIL(ok, response);
2333}
2334
2335bool RemoteControlBoard::getCurrentImpedanceLimit(int j, double *min_stiff, double *max_stiff, double *min_damp, double *max_damp)
2336{
2337 Bottle cmd, response;
2338 cmd.addVocab32(VOCAB_GET);
2341 cmd.addInt32(j);
2342 bool ok = rpc_p.write(cmd, response);
2343 if (CHECK_FAIL(ok, response)) {
2344 Bottle* lp = response.get(2).asList();
2345 if (lp == nullptr) {
2346 return false;
2347 }
2348 Bottle& l = *lp;
2349 *min_stiff = l.get(0).asFloat64();
2350 *max_stiff = l.get(1).asFloat64();
2351 *min_damp = l.get(2).asFloat64();
2352 *max_damp = l.get(3).asFloat64();
2353 return true;
2354 }
2355 return false;
2356}
2357
2358// END IImpedanceControl
2359
2360// BEGIN IControlMode
2361
2363{
2364 double localArrivalTime=0.0;
2365 extendedPortMutex.lock();
2367 extendedPortMutex.unlock();
2368 return ret;
2369}
2370
2379
2381{
2382 double localArrivalTime=0.0;
2383
2384 extendedPortMutex.lock();
2386 if(ret)
2387 {
2388 for (int i = 0; i < n_joint; i++) {
2390 }
2391 } else {
2392 ret = false;
2393 }
2394
2395 extendedPortMutex.unlock();
2396 return ret;
2397}
2398
2399bool RemoteControlBoard::setControlMode(const int j, const int mode)
2400{
2401 if (!isLive()) {
2402 return false;
2403 }
2404 Bottle cmd, response;
2405 cmd.addVocab32(VOCAB_SET);
2408 cmd.addInt32(j);
2409 cmd.addVocab32(mode);
2410
2411 bool ok = rpc_p.write(cmd, response);
2412 return CHECK_FAIL(ok, response);
2413}
2414
2416{
2417 if (!isLive()) {
2418 return false;
2419 }
2420 Bottle cmd, response;
2421 cmd.addVocab32(VOCAB_SET);
2424 cmd.addInt32(n_joint);
2425 int i;
2426 Bottle& l1 = cmd.addList();
2427 for (i = 0; i < n_joint; i++) {
2428 l1.addInt32(joints[i]);
2429 }
2430
2431 Bottle& l2 = cmd.addList();
2432 for (i = 0; i < n_joint; i++) {
2433 l2.addVocab32(modes[i]);
2434 }
2435
2436 bool ok = rpc_p.write(cmd, response);
2437 return CHECK_FAIL(ok, response);
2438}
2439
2441{
2442 if (!isLive()) {
2443 return false;
2444 }
2445 Bottle cmd, response;
2446 cmd.addVocab32(VOCAB_SET);
2449
2450 Bottle& l2 = cmd.addList();
2451 for (size_t i = 0; i < nj; i++) {
2452 l2.addVocab32(modes[i]);
2453 }
2454
2455 bool ok = rpc_p.write(cmd, response);
2456 return CHECK_FAIL(ok, response);
2457}
2458
2459// END IControlMode
2460
2461// BEGIN IPositionDirect
2462
2464{
2465 if (!isLive()) {
2466 return false;
2467 }
2469 c.head.clear();
2470 c.head.addVocab32(VOCAB_POSITION_DIRECT);
2471 c.head.addInt32(j);
2472 c.body.resize(1);
2473 memcpy(&(c.body[0]), &ref, sizeof(double));
2475 return true;
2476}
2477
2478bool RemoteControlBoard::setPositions(const int n_joint, const int *joints, const double *refs)
2479{
2480 if (!isLive()) {
2481 return false;
2482 }
2484 c.head.clear();
2485 c.head.addVocab32(VOCAB_POSITION_DIRECT_GROUP);
2486 c.head.addInt32(n_joint);
2487 Bottle &jointList = c.head.addList();
2488 for (int i = 0; i < n_joint; i++) {
2489 jointList.addInt32(joints[i]);
2490 }
2491 c.body.resize(n_joint);
2492 memcpy(&(c.body[0]), refs, sizeof(double)*n_joint);
2494 return true;
2495}
2496
2498{
2499 if (!isLive()) {
2500 return false;
2501 }
2503 c.head.clear();
2504 c.head.addVocab32(VOCAB_POSITION_DIRECTS);
2505 c.body.resize(nj);
2506 memcpy(&(c.body[0]), refs, sizeof(double)*nj);
2508 return true;
2509}
2510
2511bool RemoteControlBoard::getRefPosition(const int joint, double* ref)
2512{
2514}
2515
2520
2525
2526// END IPositionDirect
2527
2528// BEGIN IVelocityControl
2529
2530bool RemoteControlBoard::velocityMove(const int n_joint, const int *joints, const double *spds)
2531{
2532 // streaming port
2533 if (!isLive()) {
2534 return false;
2535 }
2537 c.head.clear();
2538 c.head.addVocab32(VOCAB_VELOCITY_MOVE_GROUP);
2539 c.head.addInt32(n_joint);
2540 Bottle &jointList = c.head.addList();
2541 for (int i = 0; i < n_joint; i++) {
2542 jointList.addInt32(joints[i]);
2543 }
2544 c.body.resize(n_joint);
2545 memcpy(&(c.body[0]), spds, sizeof(double)*n_joint);
2547 return true;
2548}
2549
2550bool RemoteControlBoard::getRefVelocity(const int joint, double* vel)
2551{
2552 return get1V1I1D(VOCAB_VELOCITY_MOVE, joint, vel);
2553}
2554
2559
2564
2565// END IVelocityControl
2566
2567// BEGIN IInteractionMode
2568
2577
2579{
2580 double localArrivalTime=0.0;
2581
2582 extendedPortMutex.lock();
2584 if(ret)
2585 {
2586 for (int i = 0; i < n_joints; i++) {
2588 }
2589 } else {
2590 ret = false;
2591 }
2592
2593 extendedPortMutex.unlock();
2594 return ret;
2595}
2596
2605
2607{
2608 Bottle cmd, response;
2609 if (!isLive()) {
2610 return false;
2611 }
2612
2613 cmd.addVocab32(VOCAB_SET);
2616 cmd.addInt32(axis);
2617 cmd.addVocab32(mode);
2618
2619 bool ok = rpc_p.write(cmd, response);
2620 return CHECK_FAIL(ok, response);
2621}
2622
2624{
2625 Bottle cmd, response;
2626 if (!isLive()) {
2627 return false;
2628 }
2629
2630 cmd.addVocab32(VOCAB_SET);
2633 cmd.addInt32(n_joints);
2634
2635 Bottle& l1 = cmd.addList();
2636 for (int i = 0; i < n_joints; i++) {
2637 l1.addInt32(joints[i]);
2638 }
2639
2640 Bottle& l2 = cmd.addList();
2641 for (int i = 0; i < n_joints; i++)
2642 {
2643 l2.addVocab32(modes[i]);
2644 }
2645 bool ok = rpc_p.write(cmd, response);
2646 return CHECK_FAIL(ok, response);
2647}
2648
2650{
2651 Bottle cmd, response;
2652 if (!isLive()) {
2653 return false;
2654 }
2655
2656 cmd.addVocab32(VOCAB_SET);
2659
2660 Bottle& l1 = cmd.addList();
2661 for (size_t i = 0; i < nj; i++) {
2662 l1.addVocab32(modes[i]);
2663 }
2664
2665 bool ok = rpc_p.write(cmd, response);
2666 return CHECK_FAIL(ok, response);
2667}
2668
2669// END IInteractionMode
2670
2671// BEGIN IRemoteCalibrator
2672
2674{
2675 Bottle cmd, response;
2676 cmd.addVocab32(VOCAB_GET);
2679 bool ok = rpc_p.write(cmd, response);
2680 if(ok) {
2681 *isCalib = response.get(2).asInt32()!=0;
2682 } else {
2683 *isCalib = false;
2684 }
2685 return CHECK_FAIL(ok, response);
2686}
2687
2692
2694{
2695 Bottle cmd, response;
2696 cmd.addVocab32(VOCAB_SET);
2699 bool ok = rpc_p.write(cmd, response);
2700 return CHECK_FAIL(ok, response);
2701}
2702
2707
2709{
2710 Bottle cmd, response;
2711 cmd.addVocab32(VOCAB_SET);
2714 bool ok = rpc_p.write(cmd, response);
2715 yCDebug(REMOTECONTROLBOARD) << "Sent homing whole part message";
2716 return CHECK_FAIL(ok, response);
2717}
2718
2723
2725{
2726 Bottle cmd, response;
2727 cmd.addVocab32(VOCAB_SET);
2730 bool ok = rpc_p.write(cmd, response);
2731 return CHECK_FAIL(ok, response);
2732}
2733
2735{
2736 Bottle cmd, response;
2737 cmd.addVocab32(VOCAB_SET);
2740 bool ok = rpc_p.write(cmd, response);
2741 return CHECK_FAIL(ok, response);
2742}
2743
2745{
2746 Bottle cmd, response;
2747 cmd.addVocab32(VOCAB_SET);
2750 bool ok = rpc_p.write(cmd, response);
2751 return CHECK_FAIL(ok, response);
2752}
2753
2754// END IRemoteCalibrator
2755
2756// BEGIN ICurrentControl
2757
2762
2767
2769{
2770 if (!isLive()) {
2771 return false;
2772 }
2774 c.head.clear();
2775 c.head.addVocab32(VOCAB_CURRENTCONTROL_INTERFACE);
2776 c.head.addVocab32(VOCAB_CURRENT_REFS);
2777 c.body.resize(nj);
2778 memcpy(&(c.body[0]), refs, sizeof(double)*nj);
2780 return true;
2781}
2782
2784{
2785 if (!isLive()) {
2786 return false;
2787 }
2789 c.head.clear();
2790 c.head.addVocab32(VOCAB_CURRENTCONTROL_INTERFACE);
2791 c.head.addVocab32(VOCAB_CURRENT_REF);
2792 c.head.addInt32(j);
2793 c.body.resize(1);
2794 memcpy(&(c.body[0]), &ref, sizeof(double));
2796 return true;
2797}
2798
2799bool RemoteControlBoard::setRefCurrents(const int n_joint, const int *joints, const double *refs)
2800{
2801 if (!isLive()) {
2802 return false;
2803 }
2805 c.head.clear();
2806 c.head.addVocab32(VOCAB_CURRENTCONTROL_INTERFACE);
2807 c.head.addVocab32(VOCAB_CURRENT_REF_GROUP);
2808 c.head.addInt32(n_joint);
2809 Bottle &jointList = c.head.addList();
2810 for (int i = 0; i < n_joint; i++) {
2811 jointList.addInt32(joints[i]);
2812 }
2813 c.body.resize(n_joint);
2814 memcpy(&(c.body[0]), refs, sizeof(double)*n_joint);
2816 return true;
2817}
2818
2827
2828bool RemoteControlBoard::getCurrent(int j, double *val)
2829{
2830 double localArrivalTime=0.0;
2831 extendedPortMutex.lock();
2833 extendedPortMutex.unlock();
2834 return ret;
2835}
2836
2837bool RemoteControlBoard::getCurrentRange(int j, double *min, double *max)
2838{
2840}
2841
2842bool RemoteControlBoard::getCurrentRanges(double *min, double *max)
2843{
2845}
2846
2847// END ICurrentControl
2848
2849// BEGIN IPWMControl
2851{
2852 // using the streaming port
2853 if (!isLive()) {
2854 return false;
2855 }
2857 c.head.clear();
2858 // in streaming port only SET command can be sent, so it is implicit
2859 c.head.addVocab32(VOCAB_PWMCONTROL_INTERFACE);
2860 c.head.addVocab32(VOCAB_PWMCONTROL_REF_PWM);
2861 c.head.addInt32(j);
2862
2863 c.body.clear();
2864 c.body.resize(1);
2865 c.body[0] = v;
2867 return true;
2868}
2869
2871{
2872 // using the streaming port
2873 if (!isLive()) {
2874 return false;
2875 }
2877 c.head.clear();
2878 c.head.addVocab32(VOCAB_PWMCONTROL_INTERFACE);
2879 c.head.addVocab32(VOCAB_PWMCONTROL_REF_PWMS);
2880
2881 c.body.resize(nj);
2882
2883 memcpy(&(c.body[0]), v, sizeof(double)*nj);
2884
2886
2887 return true;
2888}
2889
2891{
2892 Bottle cmd, response;
2893 cmd.addVocab32(VOCAB_GET);
2896 cmd.addInt32(j);
2897 response.clear();
2898
2899 bool ok = rpc_p.write(cmd, response);
2900
2901 if (CHECK_FAIL(ok, response))
2902 {
2903 // ok
2904 *ref = response.get(2).asFloat64();
2905
2906 getTimeStamp(response, lastStamp);
2907 return true;
2908 } else {
2909 return false;
2910 }
2911}
2912
2917
2919{
2920 double localArrivalTime = 0.0;
2921 extendedPortMutex.lock();
2923 extendedPortMutex.unlock();
2924 return ret;
2925}
2926
2928{
2929 double localArrivalTime = 0.0;
2930 extendedPortMutex.lock();
2932 extendedPortMutex.unlock();
2933 return ret;
2934}
2935// 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 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_TEMPERATURES
Definition IMotor.h:162
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_GROUP
bool ret
constexpr int PROTOCOL_VERSION_TWEAK
constexpr int PROTOCOL_VERSION_MINOR
constexpr int PROTOCOL_VERSION_MAJOR
const yarp::os::LogComponent & REMOTECONTROLBOARD()
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.
bool setMotorEncoderCountsPerRevolution(int m, const double cpr) override
Sets number of counts per revolution for motor encoder m.
ProtocolVersion protocolVersion
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.
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.
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
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)
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 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.
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.
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.
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< 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 > pwmDutycycle
Definition jointData.h:41
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:64
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:353
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
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
std::string toString() const override
Gives a human-readable textual representation of the bottle.
Definition Bottle.cpp:211
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 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...
void setStrict(bool strict=true) override
Call this to strictly keep all messages, or allow old ones to be quietly dropped.
bool write(const PortWriter &writer, const PortWriter *callback=nullptr) const override
Write an object to the port.
Definition Port.cpp:436
bool addOutput(const std::string &name) override
Add an output connection to the specified port.
Definition Port.cpp:353
void interrupt() override
Interrupt any current reads or writes attached to the port.
Definition Port.cpp:383
void close() override
Stop port activity.
Definition Port.cpp:363
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: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
void resize(size_t size) override
Resize the vector.
Definition Vector.h:221
T * data()
Return a pointer to the first element of the vector.
Definition Vector.h:206
#define yCInfo(component,...)
#define yCError(component,...)
#define yCAssert(component, x)
#define yCWarning(component,...)
#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.