YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
ControlBoard_nwc_yarp.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#include <algorithm>
13
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#include <yarp/os/Vocab32.h>
23
24
26#include <yarp/dev/PolyDriver.h>
30
31#include <mutex>
32
33
34using namespace yarp::os;
35using namespace yarp::dev;
36using namespace yarp::sig;
37
38namespace {
39
40constexpr int PROTOCOL_VERSION_MAJOR = 1;
41constexpr int PROTOCOL_VERSION_MINOR = 9;
42constexpr int PROTOCOL_VERSION_TWEAK = 0;
43
44constexpr double DIAGNOSTIC_THREAD_PERIOD = 1.000;
45
46inline bool getTimeStamp(Bottle &bot, Stamp &st)
47{
48 if (bot.get(3).asVocab32()==VOCAB_TIMESTAMP)
49 {
50 //yup! we have a timestamp
51 int fr=bot.get(4).asInt32();
52 double ts=bot.get(5).asFloat64();
53 st=Stamp(fr,ts);
54 return true;
55 }
56 return false;
57}
58
59} // namespace
60
61
63 public PeriodicThread
64{
65 StateExtendedInputPort *owner{nullptr};
66 std::string ownerName;
67
68public:
70
72 {
73 owner = o;
74 ownerName = owner->getName();
75 }
76
77 void run() override
78 {
79 if (owner != nullptr)
80 {
81 if (owner->getIterations() > 100)
82 {
83 int it;
84 double av;
85 double max;
86 double min;
87 owner->getEstFrequency(it, av, min, max);
88 owner->resetStat();
90 "%s: %d msgs av:%.2lf min:%.2lf max:%.2lf [ms]",
91 ownerName.c_str(),
92 it,
93 av,
94 min,
95 max);
96 }
97
98 }
99 }
100};
101
102
104{
105 if (!m_njIsKnown)
106 {
107 auto ret = m_RPC.getAxesRPC();
108 if (ret.ret)
109 {
110 if (ret.axes >= 0)
111 {
112 m_nj = ret.axes;
113 m_njIsKnown = true;
114 }
115 }
116 }
117 return m_njIsKnown;
118}
119
121{
122 if (!parseParams(config)) { return false; }
123
125
126 //handle local Qos
129 {
130 localQos.setThreadPriority(m_local_qos_thread_priority);
131 localQos.setThreadPolicy(m_local_qos_thread_policy);
132 localQos.setPacketPriority(m_local_qos_packet_priority);
133 }
134
135 //handle remote Qos
138 {
139 remoteQos.setThreadPriority(m_remote_qos_thread_priority);
140 remoteQos.setThreadPolicy(m_remote_qos_thread_policy);
141 remoteQos.setPacketPriority(m_remote_qos_packet_priority);
142 }
143
144 //handle param writeStrict
145 if (m_writeStrict == "on")
146 {
149 yCInfo(CONTROLBOARD_NWC_YARP, "RemoteControlBoard is ENABLING the writeStrict option for all commands");
150 }
151 else if(m_writeStrict == "off")
152 {
155 yCInfo(CONTROLBOARD_NWC_YARP, "RemoteControlBoard is DISABLING the writeStrict option for all commands");
156 }
157 else if (m_writeStrict.empty())
158 {
159 //leave the default values
160 }
161 else
162 {
163 yCError(CONTROLBOARD_NWC_YARP, "Found writeStrict option with wrong value. Accepted options are 'on' or 'off'");
164 return false;
165 }
166
167 //open ports
168 bool portProblem = false;
169 if (m_local != "") {
170 std::string s1;
171 s1 = m_local;
172 s1 += "/command:o";
173 if (!command_p.open(s1)) { portProblem = true; }
174 s1 = m_local;
175 s1 += "/stateExt:i";
176 if (!extendedIntputStatePort.open(s1)) { portProblem = true; }
177 if (!portProblem)
178 {
180 }
181 }
182
183 bool connectionProblem = false;
184 if (m_remote != "" && !portProblem)
185 {
186 std::string s1 = m_remote;
187 s1 += "/nws/rpc:i";
188 std::string s2 = m_local;
189 s2 += "/rpc:o";
190 bool ok = false;
191 // RPC port needs to be tcp, therefore no carrier option is added here
192 // ok=Network::connect(s2.c_str(), s1.c_str()); //This doesn't take into consideration possible YARP_PORT_PREFIX on local ports
193 // 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
194
195 s1 = m_remote;
196 s1 += "/command:i";
197 s2 = m_local;
198 s2 += "/command:o";
199 //ok = Network::connect(s2.c_str(), s1.c_str(), carrier);
200 // ok=Network::connect(command_p.getName(), s1.c_str(), carrier); //doesn't take into consideration possible YARP_PORT_PREFIX on local ports
202 if (!ok) {
203 yCError(CONTROLBOARD_NWC_YARP, "Problem connecting to %s, is the remote device available?", s1.c_str());
204 connectionProblem = true;
205 }
206 // set the QoS preferences for the 'command' port
209 }
210
211 s1 = m_remote;
212 s1 += "/stateExt:o";
213 s2 = m_local;
214 s2 += "/stateExt:i";
215 // not checking return value for now since it is wip (different machines can have different compilation flags
216 ok = Network::connect(s1, extendedIntputStatePort.getName(), m_carrier);
217 if (ok)
218 {
219 // set the QoS preferences for the 'state' port
222 }
223 }
224 else
225 {
226 yCError(CONTROLBOARD_NWC_YARP, "Problem connecting to %s, is the remote device available?", s1.c_str());
227 connectionProblem = true;
228 }
229 }
230
232 {
235 return false;
236 }
237
238
239 // open rpc port
240 std::string local_rpc_portname = m_local + "/nwc/rpc:o";
242 {
243 yCError(CONTROLBOARD_NWC_YARP, "open() error could not open rpc port %s, check network\n", local_rpc_portname.c_str());
246 return false;
247 }
248
249 //Attach the ControlBoardMsgs to the port
251 {
252 yCError(CONTROLBOARD_NWC_YARP, "Error! Cannot attach the port as a client");
256 return false;
257 }
258
259 // connection for the rpc port
260 std::string nws_rpc_portname = m_remote + "/nws/rpc:i";
261 if (!Network::connect(local_rpc_portname, nws_rpc_portname))
262 {
263 yCError(CONTROLBOARD_NWC_YARP, "open() error could not connect to %s\n", nws_rpc_portname.c_str());
267 return false;
268 }
269
270 // Check the protocol version
272 {
276 return false;
277 }
278
279 if (!isLive())
280 {
281 if (m_remote!="")
282 {
283 yCError(CONTROLBOARD_NWC_YARP, "Problems with obtaining the number of controlled axes");
287 return false;
288 }
289 }
290
291 if (m_diagnostic)
292 {
296 }
297
298 // allocate memory for helper struct
299 // single joint
306 last_singleJoint.torque.resize(1);
308 last_singleJoint.current.resize(1);
311
312 // whole part (safe here because we already got the m_nj
319 last_wholePart.torque.resize(m_nj);
324
325 //check device capabilities
326 auto ret = m_RPC.getDeviceInterfacesRPC();
327 if (!ret.ret)
328 {
329 yCError(CONTROLBOARD_NWC_YARP, "Unable to getDeviceInterfacesRPC");
333 return false;
334 }
335 m_device_has_interfaces = ret.interfaces;
336
337 return true;
338}
339
341{
342 if (diagnosticThread!=nullptr)
343 {
345 delete diagnosticThread;
346 }
347
348
349 m_rpcPort.interrupt(); // TBC
350 command_p.interrupt(); // TBC
352
356 return true;
357}
358
359#if 0
360#define LOCKMUTEX std::lock_guard<std::mutex> lg(m_mutex);
361#else
362#define LOCKMUTEX
363#endif
364
365#define CHECK_INTERFACE(VALUE) \
366 { \
367 if (auto it = m_device_has_interfaces.find(VALUE); \
368 it == m_device_has_interfaces.end() || !it->second) \
369 { \
370 yCError(CONTROLBOARD_NWC_YARP, \
371 "Device does not implement required interface: %s", \
372 VALUE); \
373 return yarp::dev::ReturnValue::return_code:: \
374 return_value_error_not_implemented_by_device; \
375 } \
376 }
377
378// BEGIN IPidControl
379
380ReturnValue ControlBoard_nwc_yarp::getAvailablePids(int j, std::vector<yarp::dev::PidControlTypeEnum>& avail)
381{
383 auto ret = m_RPC.getAvailablePidsRPC(j);
384 if (!ret.ret) {
385 yCError(CONTROLBOARD_NWC_YARP, "Unable to getAvailablePids");
386 return ret.ret;
387 }
388 avail = ret.avail;
389 return ret.ret;
390}
391
393{
395 auto ret = m_RPC.setPidRPC(pidtype, j, pid);
396 if (!ret) {
397 yCError(CONTROLBOARD_NWC_YARP, "Unable to setPidRPC");
398 return ret;
399 }
400 return ret;
401}
402
404{
406 std::vector<Pid> pids_vec(pids, pids + m_nj);
407 auto ret = m_RPC.setPidsRPC(pidtype, pids_vec);
408 if (!ret) {
409 yCError(CONTROLBOARD_NWC_YARP, "Unable to setPidsRPC");
410 return ret;
411 }
412 return ret;
413}
414
416{
418 auto ret = m_RPC.setPidReferenceRPC(pidtype, j, ref);
419 if (!ret) {
420 yCError(CONTROLBOARD_NWC_YARP, "Unable to setPidReferenceRPC");
421 return ret;
422 }
423 return ret;
424}
425
427{
429 std::vector<double> pids_refs(refs, refs + m_nj);
430 auto ret = m_RPC.setPidReferencesRPC(pidtype, pids_refs);
431 if (!ret) {
432 yCError(CONTROLBOARD_NWC_YARP, "Unable to setPidReferencesRPC");
433 return ret;
434 }
435 return ret;
436}
437
439{
441 auto ret = m_RPC.setPidErrorLimitRPC(pidtype, j, limit);
442 if (!ret) {
443 yCError(CONTROLBOARD_NWC_YARP, "Unable to setPidErrorLimitRPC");
444 return ret;
445 }
446 return ret;
447}
448
450{
452 std::vector<double> pids_lims(limits, limits + m_nj);
453 auto ret = m_RPC.setPidErrorLimitsRPC(pidtype, pids_lims);
454 if (!ret) {
455 yCError(CONTROLBOARD_NWC_YARP, "Unable to setPidErrorLimitsRPC");
456 return ret;
457 }
458 return ret;
459}
460
462{
464 auto ret = m_RPC.getPidErrorRPC(pidtype,j);
465 if (!ret.ret) {
466 yCError(CONTROLBOARD_NWC_YARP, "Unable to getPidErrorRPC");
467 return ret.ret;
468 }
469 *err = ret.err;
470 return ret.ret;
471}
472
474{
476 auto ret = m_RPC.getPidErrorsRPC(pidtype);
477 if (!ret.ret) {
478 yCError(CONTROLBOARD_NWC_YARP, "Unable to getPidErrorsRPC");
479 return ret.ret;
480 }
481 std::copy(ret.errs.begin(), ret.errs.end(), errs);
482 return ret.ret;
483}
484
486{
488 auto ret = m_RPC.getPidRPC(pidtype,j);
489 if (!ret.ret) {
490 yCError(CONTROLBOARD_NWC_YARP, "Unable to getPidRPC");
491 return ret.ret;
492 }
493 *pid = ret.pid;
494 return ret.ret;
495}
496
498{
500 auto ret = m_RPC.getPidsRPC(pidtype);
501 if (!ret.ret) {
502 yCError(CONTROLBOARD_NWC_YARP, "Unable to getPidsRPC");
503 return ret.ret;
504 }
505 std::copy(ret.pids.begin(), ret.pids.end(), pids);
506 return ret.ret;
507}
508
510{
512 auto ret = m_RPC.getPidReferenceRPC(pidtype,j);
513 if (!ret.ret) {
514 yCError(CONTROLBOARD_NWC_YARP, "Unable to getPidReferenceRPC");
515 return ret.ret;
516 }
517 *ref = ret.ref;
518 return ret.ret;
519}
520
522{
524 auto ret = m_RPC.getPidReferencesRPC(pidtype);
525 if (!ret.ret) {
526 yCError(CONTROLBOARD_NWC_YARP, "Unable to getPidReferencesRPC");
527 return ret.ret;
528 }
529 std::copy(ret.refs.begin(), ret.refs.end(), refs);
530 return ret.ret;
531}
532
534{
536 auto ret = m_RPC.getPidErrorLimitRPC(pidtype,j);
537 if (!ret.ret) {
538 yCError(CONTROLBOARD_NWC_YARP, "Unable to getPidErrorLimitRPC");
539 return ret.ret;
540 }
541 *limit = ret.lim;
542 return ret.ret;
543}
544
546{
548 auto ret = m_RPC.getPidErrorLimitsRPC(pidtype);
549 if (!ret.ret) {
550 yCError(CONTROLBOARD_NWC_YARP, "Unable to getPidErrorLimits");
551 return ret.ret;
552 }
553 std::copy(ret.lims.begin(), ret.lims.end(), limits);
554 return ret.ret;
555}
556
558{
560 auto ret = m_RPC.resetPidRPC(pidtype, j);
561 if (!ret) {
562 yCError(CONTROLBOARD_NWC_YARP, "Unable to resetPidRPC");
563 return ret;
564 }
565 return ret;
566}
567
569{
571 auto ret = m_RPC.disablePidRPC(pidtype, j);
572 if (!ret) {
573 yCError(CONTROLBOARD_NWC_YARP, "Unable to disablePidRPC");
574 return ret;
575 }
576 return ret;
577}
578
580{
582 auto ret = m_RPC.enablePidRPC(pidtype, j);
583 if (!ret) {
584 yCError(CONTROLBOARD_NWC_YARP, "Unable to enablePidRPC");
585 return ret;
586 }
587 return ret;
588}
589
591{
593 auto ret = m_RPC.isPidEnabledRPC(pidtype,j);
594 if (!ret.ret) {
595 yCError(CONTROLBOARD_NWC_YARP, "Unable to isPidEnabledRPC");
596 return ret.ret;
597 }
598 enabled = ret.isEnabled;
599 return ret.ret;
600}
601
603{
605 auto ret = m_RPC.getPidOutputRPC(pidtype,j);
606 if (!ret.ret) {
607 yCError(CONTROLBOARD_NWC_YARP, "Unable to getPidOutputRPC");
608 return ret.ret;
609 }
610 *out = ret.out;
611 return ret.ret;
612}
613
615{
617 auto ret = m_RPC.getPidOutputsRPC(pidtype);
618 if (!ret.ret) {
619 yCError(CONTROLBOARD_NWC_YARP, "Unable to getPidOutputsRPC");
620 return ret.ret;
621 }
622 std::copy(ret.outs.begin(), ret.outs.end(), outs);
623 return ret.ret;
624}
625
627{
628 if (m_use_streaming)
629 {
630 CHECK_INTERFACE("iPidControl")
631 if (!isLive()) {
632 return ReturnValue::return_code::return_value_error_not_ready;
633 }
635 c.head.clear();
636 c.head.addVocab32(VOCAB_PIDCONTROL_INTERFACE);
637 c.head.addVocab32(VOCAB_PIDCONTROL_SET_OFFSET);
638 c.head.addVocab32(yarp::conf::vocab32_t(pidtype));
639 c.head.addInt32(j);
640 c.body.resize(1);
641 c.body[0] = v;
643 return ReturnValue_ok;
644 }
645 else
646 {
648 auto ret = m_RPC.setPidOffsetOneRPC(pidtype,j,v);
649 if (!ret) {
650 yCError(CONTROLBOARD_NWC_YARP, "Unable to velocityMoveOneRPC");
651 return ret;
652 }
653 return ret;
654 }
655}
656
658{
659 if (m_use_streaming)
660 {
661 CHECK_INTERFACE("iPidControl")
662 if (!isLive()) {
663 return ReturnValue::return_code::return_value_error_not_ready;
664 }
666 c.head.clear();
667 c.head.addVocab32(VOCAB_PIDCONTROL_INTERFACE);
668 c.head.addVocab32(VOCAB_PIDCONTROL_SET_FEEDFORWARD);
669 c.head.addVocab32(yarp::conf::vocab32_t(pidtype));
670 c.head.addInt32(j);
671 c.body.resize(1);
672 c.body[0] = v;
674 return ReturnValue_ok;
675 }
676 else
677 {
679 auto ret = m_RPC.setPidFeedforwardOneRPC(pidtype,j,v);
680 if (!ret) {
681 yCError(CONTROLBOARD_NWC_YARP, "Unable to velocityMoveOneRPC");
682 return ret;
683 }
684 return ret;
685 }
686}
687
689{
691 auto ret = m_RPC.getPidExtraInfoRPC(pidtype,j);
692 if (!ret.ret) {
693 yCError(CONTROLBOARD_NWC_YARP, "Unable to getPidExtraInfoRPC");
694 return ret.ret;
695 }
696 info = ret.info;
697 return ret.ret;
698}
699
701{
703 auto ret = m_RPC.getPidExtraInfosRPC(pidtype);
704 if (!ret.ret) {
705 yCError(CONTROLBOARD_NWC_YARP, "Unable to getPidExtraInfosRPC");
706 return ret.ret;
707 }
708 info = ret.info;
709 return ret.ret;
710}
711
713{
715 auto ret = m_RPC.getPidOffsetRPC(pidtype,j);
716 if (!ret.ret) {
717 yCError(CONTROLBOARD_NWC_YARP, "Unable to getPidOffsetRPC");
718 return ret.ret;
719 }
720 value = ret.offset;
721 return ret.ret;
722}
723
725{
727 auto ret = m_RPC.getPidFeedforwardRPC(pidtype,j);
728 if (!ret.ret) {
729 yCError(CONTROLBOARD_NWC_YARP, "Unable to getPidFeedforwardRPC");
730 return ret.ret;
731 }
732 value = ret.feedforward;
733 return ret.ret;
734}
735
736// END IPidControl
737
738// BEGIN IEncoder
739
741{
743 auto ret = m_RPC.resetEncoderOneRPC(j);
744 if (!ret) {
745 yCError(CONTROLBOARD_NWC_YARP, "Unable to resetEncoderOneRPC");
746 return ret;
747 }
748 return ret;
749}
750
752{
754 auto ret = m_RPC.resetEncoderAllRPC();
755 if (!ret) {
756 yCError(CONTROLBOARD_NWC_YARP, "Unable to resetEncoderAllRPC");
757 return ret;
758 }
759 return ret;
760}
761
763{
765 auto ret = m_RPC.setEncoderOneRPC(j, val);
766 if (!ret) {
767 yCError(CONTROLBOARD_NWC_YARP, "Unable to setEncoderOneRPC");
768 return ret;
769 }
770 return ret;
771}
772
774{
776 std::vector<double> temp(vals, vals + this->m_nj);
777 auto ret = m_RPC.setEncoderAllRPC(temp);
778 if (!ret) {
779 yCError(CONTROLBOARD_NWC_YARP, "Unable to setEncoderAllRPC");
780 return ret;
781 }
782 return ret;
783}
784
786{
787 double localArrivalTime = 0.0;
788
789 extendedPortMutex.lock();
791 extendedPortMutex.unlock();
792 return ret?ReturnValue_ok:ReturnValue::return_code::return_value_error_not_ready;
793}
794
796{
797 double localArrivalTime = 0.0;
798
799 extendedPortMutex.lock();
801 *t=m_lastStamp.getTime();
802 extendedPortMutex.unlock();
803 return ret?ReturnValue_ok:ReturnValue::return_code::return_value_error_not_ready;
804}
805
807{
808 double localArrivalTime = 0.0;
809
810 extendedPortMutex.lock();
812 extendedPortMutex.unlock();
813 return ret?ReturnValue_ok:ReturnValue::return_code::return_value_error_not_ready;
814}
815
817{
818 double localArrivalTime=0.0;
819
820 extendedPortMutex.lock();
822 std::fill_n(ts, m_nj, m_lastStamp.getTime());
823 extendedPortMutex.unlock();
824 return ret?ReturnValue_ok:ReturnValue::return_code::return_value_error_not_ready;
825}
826
828{
829 double localArrivalTime=0.0;
830
831 extendedPortMutex.lock();
833 extendedPortMutex.unlock();
834 return ret?ReturnValue_ok:ReturnValue::return_code::return_value_error_not_ready;
835}
836
838{
839 double localArrivalTime=0.0;
840
841 extendedPortMutex.lock();
843 extendedPortMutex.unlock();
844 return ret?ReturnValue_ok:ReturnValue::return_code::return_value_error_not_ready;
845}
846
848{
849 double localArrivalTime=0.0;
850 extendedPortMutex.lock();
852 extendedPortMutex.unlock();
853 return ret?ReturnValue_ok:ReturnValue::return_code::return_value_error_not_ready;
854}
855
857{
858 double localArrivalTime=0.0;
859 extendedPortMutex.lock();
861 extendedPortMutex.unlock();
862 return ret?ReturnValue_ok:ReturnValue::return_code::return_value_error_not_ready;
863}
864
865// END IEncoder
866
867// BEGIN IRemoteVariable
868
870{
872 auto ret = m_RPC.getRemoteVariableRPC(key);
873 if (!ret.ret) {
874 yCError(CONTROLBOARD_NWC_YARP, "Unable to getRemoteVariable");
875 return ret.ret;
876 }
877 val = ret.val;
878 return ret.ret;
879}
880
882{
884 auto ret = m_RPC.setRemoteVariableRPC(key, val);
885 if (!ret) {
886 yCError(CONTROLBOARD_NWC_YARP, "Unable to setRemoteVariable");
887 return ret;
888 }
889 return ret;
890}
891
892
894{
896 auto ret = m_RPC.getRemoteVariablesListRPC();
897 if (!ret.ret) {
898 yCError(CONTROLBOARD_NWC_YARP, "Unable to getRemoteVariable");
899 return ret.ret;
900 }
901 std::copy(ret.listOfKeys.begin(), ret.listOfKeys.end(), listOfKeys);
902 return ret.ret;
903}
904
905// END IRemoteVariable
906
907// BEGIN IMotor
908
910{
912 auto ret = m_RPC.getNumberOfMotorsRPC();
913 if (!ret.ret) {
914 yCError(CONTROLBOARD_NWC_YARP, "Unable to getNumberOfMotors");
915 return ret.ret;
916 }
917 *num = ret.val;
918 return ret.ret;
919}
920
922{
923 double localArrivalTime = 0.0;
924
925 extendedPortMutex.lock();
927 extendedPortMutex.unlock();
928 return ret?ReturnValue_ok:ReturnValue::return_code::return_value_error_not_ready;
929}
930
932{
933 double localArrivalTime = 0.0;
934
935 extendedPortMutex.lock();
937 extendedPortMutex.unlock();
938 return ret?ReturnValue_ok:ReturnValue::return_code::return_value_error_not_ready;
939}
940
942{
944 auto ret = m_RPC.getTemperatureLimitRPC(m);
945 if (!ret.ret) {
946 yCError(CONTROLBOARD_NWC_YARP, "Unable to getTemperatureLimit");
947 return ret.ret;
948 }
949 *val = ret.val;
950 return ret.ret;
951}
952
954{
956 auto ret = m_RPC.setTemperatureLimitRPC(m, val);
957 if (!ret) {
958 yCError(CONTROLBOARD_NWC_YARP, "Unable to setTemperatureLimit");
959 return ret;
960 }
961 return ret;
962}
963
965{
967 auto ret = m_RPC.getGearboxRatioRPC(m);
968 if (!ret.ret) {
969 yCError(CONTROLBOARD_NWC_YARP, "Unable to getGearboxRatio");
970 return ret.ret;
971 }
972 *val = ret.val;
973 return ret.ret;
974}
975
977{
979 auto ret = m_RPC.setGearboxRatioRPC(m, val);
980 if (!ret) {
981 yCError(CONTROLBOARD_NWC_YARP, "Unable to setGearboxRatio");
982 return ret;
983 }
984 return ret;
985}
986
987// END IMotor
988
989// BEGIN IMotorEncoder
990
992{
994 auto ret = m_RPC.resetMotorEncoderRPC(j);
995 if (!ret) {
996 yCError(CONTROLBOARD_NWC_YARP, "Unable to resetMotorEncoder");
997 return ret;
998 }
999 return ret;
1000}
1001
1003{
1004 LOCKMUTEX
1005 auto ret = m_RPC.resetMotorEncodersRPC();
1006 if (!ret) {
1007 yCError(CONTROLBOARD_NWC_YARP, "Unable to resetMotorEncoders");
1008 return ret;
1009 }
1010 return ret;
1011}
1012
1014{
1015 LOCKMUTEX
1016 auto ret = m_RPC.setMotorEncoderRPC(j, val);
1017 if (!ret) {
1018 yCError(CONTROLBOARD_NWC_YARP, "Unable to setMotorEncoder");
1019 return ret;
1020 }
1021 return ret;
1022}
1023
1025{
1026 LOCKMUTEX
1028 if (!ret) {
1029 yCError(CONTROLBOARD_NWC_YARP, "Unable to setMotorEncoderCountsPerRevolution");
1030 return ret;
1031 }
1032 return ret;
1033}
1034
1036{
1037 LOCKMUTEX
1039 if (!ret.ret) {
1040 yCError(CONTROLBOARD_NWC_YARP, "Unable to getMotorEncoderCountsPerRevolution");
1041 return ret.ret;
1042 }
1043 *cpr = ret.cpr;
1044 return ret.ret;
1045}
1046
1048{
1049 LOCKMUTEX
1050 std::vector<double> temp(vals, vals + this->m_nj);
1051 auto ret = m_RPC.setMotorEncodersAllRPC(temp);
1052 if (!ret) {
1053 yCError(CONTROLBOARD_NWC_YARP, "Unable to setMotorEncoders");
1054 return ret;
1055 }
1056 return ret;
1057}
1058
1060{
1061 double localArrivalTime = 0.0;
1062
1063 extendedPortMutex.lock();
1065 extendedPortMutex.unlock();
1066 return ret?ReturnValue_ok:ReturnValue::return_code::return_value_error_not_ready;
1067}
1068
1070{
1071 double localArrivalTime = 0.0;
1072
1073 extendedPortMutex.lock();
1075 *t=m_lastStamp.getTime();
1076 extendedPortMutex.unlock();
1077 return ret?ReturnValue_ok:ReturnValue::return_code::return_value_error_not_ready;
1078}
1079
1081{
1082 double localArrivalTime=0.0;
1083
1084 extendedPortMutex.lock();
1086 extendedPortMutex.unlock();
1087 return ret?ReturnValue_ok:ReturnValue::return_code::return_value_error_not_ready;
1088}
1089
1091{
1092 double localArrivalTime=0.0;
1093
1094 extendedPortMutex.lock();
1096 std::fill_n(ts, m_nj, m_lastStamp.getTime());
1097 extendedPortMutex.unlock();
1098 return ret?ReturnValue_ok:ReturnValue::return_code::return_value_error_not_ready;
1099}
1100
1102{
1103 double localArrivalTime=0.0;
1104 extendedPortMutex.lock();
1106 extendedPortMutex.unlock();
1107 return ret?ReturnValue_ok:ReturnValue::return_code::return_value_error_not_ready;
1108}
1109
1111{
1112 double localArrivalTime=0.0;
1113 extendedPortMutex.lock();
1115 extendedPortMutex.unlock();
1116 return ret?ReturnValue_ok:ReturnValue::return_code::return_value_error_not_ready;
1117}
1118
1120{
1121 double localArrivalTime=0.0;
1122 extendedPortMutex.lock();
1124 extendedPortMutex.unlock();
1125 return ret?ReturnValue_ok:ReturnValue::return_code::return_value_error_not_ready;
1126}
1127
1129{
1130 double localArrivalTime=0.0;
1131 extendedPortMutex.lock();
1133 extendedPortMutex.unlock();
1134 return ret?ReturnValue_ok:ReturnValue::return_code::return_value_error_not_ready;
1135}
1136
1138{
1139 LOCKMUTEX
1141 if (!ret.ret) {
1142 yCError(CONTROLBOARD_NWC_YARP, "Unable to getNumberOfMotorEncodersRPC");
1143 return ret.ret;
1144 }
1145 *num = ret.num;
1146 return ret.ret;
1147}
1148
1149// END IMotorEncoder
1150
1151// BEGIN IPreciselyTimed
1152
1158{
1159 Stamp ret;
1160// mutex.lock();
1161 ret = m_lastStamp;
1162// mutex.unlock();
1163 return ret;
1164}
1165
1166// END IPreciselyTimed
1167
1168// BEGIN IPositionControl
1169
1171{
1172 LOCKMUTEX
1173 auto ret = m_RPC.positionMoveOneRPC(j, ref);
1174 if (!ret) {
1175 yCError(CONTROLBOARD_NWC_YARP, "Unable to positionMoveOneRPC");
1176 return ret;
1177 }
1178 return ret;
1179}
1180
1181yarp::dev::ReturnValue ControlBoard_nwc_yarp::positionMove(const int n_joint, const int *joints, const double *refs)
1182{
1183 LOCKMUTEX
1184 std::vector<int> tempjoints(joints, joints + n_joint);
1185 std::vector<double> tempvals(refs, refs + n_joint);
1187 if (!ret) {
1188 yCError(CONTROLBOARD_NWC_YARP, "Unable to positionMoveGroupRPC");
1189 return ret;
1190 }
1191 return ret;
1192}
1193
1195{
1196 LOCKMUTEX
1197 std::vector<double> temp(refs, refs + this->m_nj);
1198 auto ret = m_RPC.positionMoveAllRPC(temp);
1199 if (!ret) {
1200 yCError(CONTROLBOARD_NWC_YARP, "Unable to positionMoveAllRPC");
1201 return ret;
1202 }
1203 return ret;
1204}
1205
1207{
1208 LOCKMUTEX
1209 auto ret = m_RPC.getTargetPositionOneRPC(joint);
1210 if (!ret.ret) {
1211 yCError(CONTROLBOARD_NWC_YARP, "Unable to getTargetPositionsOneRPC");
1212 return ret.ret;
1213 }
1214 *ref = ret.val;
1215 return ret.ret;
1216}
1217
1219{
1220 LOCKMUTEX
1221 auto ret = m_RPC.getTargetPositionAllRPC();
1222 if (!ret.ret) {
1223 yCError(CONTROLBOARD_NWC_YARP, "Unable to getTargetPositionAllRPC");
1224 return ret.ret;
1225 }
1226 std::copy(ret.val.begin(), ret.val.end(), refs);
1227 return ret.ret;
1228}
1229
1231{
1232 LOCKMUTEX
1233 std::vector<int> tempjoints(joints, joints + n_joint);
1235 if (!ret.ret) {
1236 yCError(CONTROLBOARD_NWC_YARP, "Unable to getTargetPositionGroupRPC");
1237 return ret.ret;
1238 }
1239 std::copy(ret.val.begin(), ret.val.end(), refs);
1240 return ret.ret;
1241}
1242
1244{
1245 LOCKMUTEX
1246 auto ret = m_RPC.relativeMoveOneRPC(j, delta);
1247 if (!ret) {
1248 yCError(CONTROLBOARD_NWC_YARP, "Unable to relativeMoveOneRPC");
1249 return ret;
1250 }
1251 return ret;
1252}
1253
1254yarp::dev::ReturnValue ControlBoard_nwc_yarp::relativeMove(const int n_joint, const int *joints, const double *refs)
1255{
1256 LOCKMUTEX
1257 std::vector<int> tempjoints(joints, joints + n_joint);
1258 std::vector<double> tempvals(refs, refs + n_joint);
1260 if (!ret) {
1261 yCError(CONTROLBOARD_NWC_YARP, "Unable to relativeMoveGroupRPC");
1262 return ret;
1263 }
1264 return ret;
1265}
1266
1268{
1269 LOCKMUTEX
1270 std::vector<double> temp(deltas, deltas + this->m_nj);
1271 auto ret = m_RPC.relativeMoveAllRPC(temp);
1272 if (!ret) {
1273 yCError(CONTROLBOARD_NWC_YARP, "Unable to relativeMoveAllRPC");
1274 return ret;
1275 }
1276 return ret;
1277}
1278
1280{
1281 LOCKMUTEX
1282 auto ret = m_RPC.checkMotionDoneOneRPC(j);
1283 if (!ret.ret) {
1284 yCError(CONTROLBOARD_NWC_YARP, "Unable to checkMotionDoneOneRPC");
1285 return ret.ret;
1286 }
1287 flag = ret.flag;
1288 return ret.ret;
1289}
1290
1291yarp::dev::ReturnValue ControlBoard_nwc_yarp::checkMotionDone(const std::vector<int>& joints, bool& flag)
1292{
1293 LOCKMUTEX
1294 auto ret = m_RPC.checkMotionDoneGroupRPC(joints);
1295 if (!ret.ret) {
1296 yCError(CONTROLBOARD_NWC_YARP, "Unable to checkMotionDoneGroupRPC");
1297 return ret.ret;
1298 }
1299 flag = ret.flag;
1300 return ret.ret;
1301}
1302
1304{
1305 LOCKMUTEX
1306 auto ret = m_RPC.checkMotionDoneAllRPC();
1307 if (!ret.ret) {
1308 yCError(CONTROLBOARD_NWC_YARP, "Unable to checkMotionDoneAllRPC");
1309 return ret.ret;
1310 }
1311 flag = ret.flag;
1312 return ret.ret;
1313}
1314
1316{
1317 LOCKMUTEX
1318 auto ret = m_RPC.setTrajSpeedOneRPC(j, sp);
1319 if (!ret) {
1320 yCError(CONTROLBOARD_NWC_YARP, "Unable to setTrajSpeedOneRPC");
1321 return ret;
1322 }
1323 return ret;
1324}
1325
1326yarp::dev::ReturnValue ControlBoard_nwc_yarp::setTrajSpeeds(const int n_joint, const int *joints, const double *spds)
1327{
1328 LOCKMUTEX
1329 std::vector<int> tempjoints(joints, joints + n_joint);
1330 std::vector<double> tempvals(spds, spds + n_joint);
1332 if (!ret) {
1333 yCError(CONTROLBOARD_NWC_YARP, "Unable to setTrajSpeedGroupRPC");
1334 return ret;
1335 }
1336 return ret;
1337}
1338
1340{
1341 LOCKMUTEX
1342 std::vector<double> temp(spds, spds + this->m_nj);
1343 auto ret = m_RPC.setTrajSpeedAllRPC(temp);
1344 if (!ret) {
1345 yCError(CONTROLBOARD_NWC_YARP, "Unable to setTrajSpeedAllRPC");
1346 return ret;
1347 }
1348 return ret;
1349}
1350
1352{
1353 LOCKMUTEX
1354 auto ret = m_RPC.setTrajAccelerationOneRPC(j, acc);
1355 if (!ret) {
1356 yCError(CONTROLBOARD_NWC_YARP, "Unable to setTrajAccelerationOneRPC");
1357 return ret;
1358 }
1359 return ret;
1360}
1361
1362yarp::dev::ReturnValue ControlBoard_nwc_yarp::setTrajAccelerations(const int n_joint, const int *joints, const double *accs)
1363{
1364 LOCKMUTEX
1365 std::vector<int> tempjoints(joints, joints + n_joint);
1366 std::vector<double> tempvals(accs, accs + n_joint);
1368 if (!ret) {
1369 yCError(CONTROLBOARD_NWC_YARP, "Unable to setTrajAccelerationsGroupRPC");
1370 return ret;
1371 }
1372 return ret;
1373}
1374
1376{
1377 LOCKMUTEX
1378 std::vector<double> temp(accs, accs + this->m_nj);
1380 if (!ret) {
1381 yCError(CONTROLBOARD_NWC_YARP, "Unable to setTrajAccelerationsAllRPC");
1382 return ret;
1383 }
1384 return ret;
1385}
1386
1388{
1389 LOCKMUTEX
1390 auto ret = m_RPC.getTrajSpeedOneRPC(j);
1391 if (!ret.ret) {
1392 yCError(CONTROLBOARD_NWC_YARP, "Unable to getTrajSpeedOneRPC");
1393 return ret.ret;
1394 }
1395 *ref = ret.val;
1396 return ret.ret;
1397}
1398
1400{
1401 LOCKMUTEX
1402 std::vector<int> tempjoints(joints, joints + n_joint);
1404 if (!ret.ret) {
1405 yCError(CONTROLBOARD_NWC_YARP, "Unable to getTrajSpeedsGroupRPC");
1406 return ret.ret;
1407 }
1408 std::copy(ret.val.begin(), ret.val.end(), spds);
1409 return ret.ret;
1410}
1411
1413{
1414 LOCKMUTEX
1415 auto ret = m_RPC.getTrajSpeedsAllRPC();
1416 if (!ret.ret) {
1417 yCError(CONTROLBOARD_NWC_YARP, "Unable to getTrajSpeedsAllRPC");
1418 return ret.ret;
1419 }
1420 std::copy(ret.val.begin(), ret.val.end(), spds);
1421 return ret.ret;
1422}
1423
1425{
1426 LOCKMUTEX
1427 auto ret = m_RPC.getTrajAccelerationOneRPC(j);
1428 if (!ret.ret) {
1429 yCError(CONTROLBOARD_NWC_YARP, "Unable to getTrajAccelerationOneRPC");
1430 return ret.ret;
1431 }
1432 *acc = ret.val;
1433 return ret.ret;
1434}
1435
1437{
1438 LOCKMUTEX
1439 std::vector<int> tempjoints(joints, joints + n_joint);
1441 if (!ret.ret) {
1442 yCError(CONTROLBOARD_NWC_YARP, "Unable to getTrajAccelerationsGroupRPC");
1443 return ret.ret;
1444 }
1445 std::copy(ret.val.begin(), ret.val.end(), accs);
1446 return ret.ret;
1447}
1448
1450{
1451 LOCKMUTEX
1452 auto ret = m_RPC.getTrajAccelerationAllRPC();
1453 if (!ret.ret) {
1454 yCError(CONTROLBOARD_NWC_YARP, "Unable to getTrajAccelerationsAllRPC");
1455 return ret.ret;
1456 }
1457 std::copy(ret.val.begin(), ret.val.end(), accs);
1458 return ret.ret;
1459}
1460
1462{
1463 LOCKMUTEX
1464 auto ret = m_RPC.stopOneRPC(j);
1465 if (!ret) {
1466 yCError(CONTROLBOARD_NWC_YARP, "Unable to stopOneRPC");
1467 return ret;
1468 }
1469 return ret;
1470}
1471
1473{
1474 LOCKMUTEX
1475 std::vector<int> tempjoints(joints, joints + len);
1476 auto ret = m_RPC.stopGroupRPC(tempjoints);
1477 if (!ret) {
1478 yCError(CONTROLBOARD_NWC_YARP, "Unable to stopGroupRPC");
1479 return ret;
1480 }
1481 return ret;
1482}
1483
1485{
1486 LOCKMUTEX
1487 auto ret = m_RPC.stopAllRPC();
1488 if (!ret) {
1489 yCError(CONTROLBOARD_NWC_YARP, "Unable to stopAllRPC");
1490 return ret;
1491 }
1492 return ret;
1493}
1494
1495// END IPositionControl
1496
1497// BEGIN IJoint Fault
1499{
1500 LOCKMUTEX
1501 auto ret = m_RPC.getLastJointFaultRPC(j);
1502 if (!ret.ret) {
1503 yCError(CONTROLBOARD_NWC_YARP, "Unable to getLastJointFaultRPC");
1504 return ret.ret;
1505 }
1506 fault = ret.fault;
1507 message = ret.message;
1508 return ret.ret;
1509}
1510// END IJointFault
1511
1512// BEGIN IVelocityControl
1513
1515{
1516 if (m_use_streaming)
1517 {
1518 CHECK_INTERFACE("iVelocityControl")
1519 if (!isLive()) {
1520 return ReturnValue::return_code::return_value_error_not_ready;
1521 }
1523 c.head.clear();
1524 c.head.addVocab32(VOCAB_VELOCITYCONTROL_INTERFACE);
1525 c.head.addVocab32(VOCAB_VELOCITY_MOVE);
1526 c.head.addInt32(j);
1527 c.body.resize(1);
1528 memcpy(&(c.body[0]), &v, sizeof(double));
1530 return ReturnValue_ok;
1531 }
1532 else
1533 {
1534 LOCKMUTEX
1535 auto ret = m_RPC.velocityMoveOneRPC(j,v);
1536 if (!ret) {
1537 yCError(CONTROLBOARD_NWC_YARP, "Unable to velocityMoveOneRPC");
1538 return ret;
1539 }
1540 return ret;
1541 }
1542}
1543
1545{
1546 if (m_use_streaming)
1547 {
1548 CHECK_INTERFACE("iVelocityControl")
1549 if (!isLive()) {
1550 return ReturnValue::return_code::return_value_error_not_ready;
1551 }
1553 c.head.clear();
1554 c.head.addVocab32(VOCAB_VELOCITYCONTROL_INTERFACE);
1555 c.head.addVocab32(VOCAB_VELOCITY_MOVES);
1556 c.body.resize(m_nj);
1557 memcpy(&(c.body[0]), v, sizeof(double)*m_nj);
1559 return ReturnValue_ok;
1560 }
1561 else
1562 {
1563 LOCKMUTEX
1564 std::vector<double> temp(v, v + this->m_nj);
1565 auto ret = m_RPC.velocityMoveAllRPC(temp);
1566 if (!ret) {
1567 yCError(CONTROLBOARD_NWC_YARP, "Unable to velocityMoveAllRPC");
1568 return ret;
1569 }
1570 return ret;
1571 }
1572}
1573
1574// END IVelocityControl
1575
1576// BEGIN IAmplifierControl
1577
1579{
1580 LOCKMUTEX
1581 auto ret = m_RPC.enableAmpRPC(j);
1582 if (!ret) {
1583 yCError(CONTROLBOARD_NWC_YARP, "Unable to enableAmp");
1584 return ret;
1585 }
1586 return ret;
1587}
1588
1590{
1591 LOCKMUTEX
1592 auto ret = m_RPC.disableAmpRPC(j);
1593 if (!ret) {
1594 yCError(CONTROLBOARD_NWC_YARP, "Unable to disableAmpRPC");
1595 return ret;
1596 }
1597 return ret;
1598}
1599
1601{
1602 LOCKMUTEX
1603 auto ret = m_RPC.getAmpStatusAllRPC();
1604 if (!ret.ret) {
1605 yCError(CONTROLBOARD_NWC_YARP, "Unable to getAmpStatusAllRPC");
1606 return ret.ret;
1607 }
1608 std::copy(ret.val.begin(), ret.val.end(), st);
1609 return ret.ret;
1610}
1611
1613{
1614 LOCKMUTEX
1615 auto ret = m_RPC.getAmpStatusOneRPC(j);
1616 if (!ret.ret) {
1617 yCError(CONTROLBOARD_NWC_YARP, "Unable to getAmpStatusOneRPC");
1618 return ret.ret;
1619 }
1620 *st = ret.val;
1621 return ret.ret;
1622}
1623
1625{
1626 LOCKMUTEX
1627 auto ret = m_RPC.setMaxCurrentRPC(j,v);
1628 if (!ret) {
1629 yCError(CONTROLBOARD_NWC_YARP, "Unable to setMaxCurrentRPC");
1630 return ret;
1631 }
1632 return ret;
1633}
1634
1636{
1637 LOCKMUTEX
1638 auto ret = m_RPC.getMaxCurrentRPC(j);
1639 if (!ret.ret) {
1640 yCError(CONTROLBOARD_NWC_YARP, "Unable to getMaxCurrentRPC");
1641 return ret.ret;
1642 }
1643 *v = ret.val;
1644 return ret.ret;
1645}
1646
1648{
1649 LOCKMUTEX
1650 auto ret = m_RPC.getNominalCurrentRPC(m);
1651 if (!ret.ret) {
1652 yCError(CONTROLBOARD_NWC_YARP, "Unable to getNominalCurrentRPC");
1653 return ret.ret;
1654 }
1655 *val = ret.val;
1656 return ret.ret;
1657}
1658
1660{
1661 LOCKMUTEX
1662 auto ret = m_RPC.setNominalCurrentRPC(m,val);
1663 if (!ret) {
1664 yCError(CONTROLBOARD_NWC_YARP, "Unable to setNominalCurrentRPC");
1665 return ret;
1666 }
1667 return ret;
1668}
1669
1671{
1672 LOCKMUTEX
1673 auto ret = m_RPC.getPeakCurrentRPC(m);
1674 if (!ret.ret) {
1675 yCError(CONTROLBOARD_NWC_YARP, "Unable to getPeakCurrentRPC");
1676 return ret.ret;
1677 }
1678 *val = ret.val;
1679 return ret.ret;
1680}
1681
1683{
1684 LOCKMUTEX
1685 auto ret = m_RPC.setPeakCurrentRPC(m,val);
1686 if (!ret) {
1687 yCError(CONTROLBOARD_NWC_YARP, "Unable to setPeakCurrentRPC");
1688 return ret;
1689 }
1690 return ret;
1691}
1692
1694{
1695 double localArrivalTime = 0.0;
1696 extendedPortMutex.lock();
1698 extendedPortMutex.unlock();
1699 return ret?ReturnValue_ok:ReturnValue::return_code::return_value_error_not_ready;
1700}
1701
1703{
1704 LOCKMUTEX
1705 auto ret = m_RPC.getPWMLimitRPC(m);
1706 if (!ret.ret) {
1707 yCError(CONTROLBOARD_NWC_YARP, "Unable to getPWMLimitRPC");
1708 return ret.ret;
1709 }
1710 *val = ret.val;
1711 return ret.ret;
1712}
1713
1715{
1716 LOCKMUTEX
1717 auto ret = m_RPC.setPWMLimitRPC(m,val);
1718 if (!ret) {
1719 yCError(CONTROLBOARD_NWC_YARP, "Unable to setPWMLimitRPC");
1720 return ret;
1721 }
1722 return ret;
1723}
1724
1726{
1727 LOCKMUTEX
1728 auto ret = m_RPC.getPowerSupplyVoltageRPC(m);
1729 if (!ret.ret) {
1730 yCError(CONTROLBOARD_NWC_YARP, "Unable to getPowerSupplyVoltageRPC");
1731 return ret.ret;
1732 }
1733 *val = ret.val;
1734 return ret.ret;
1735}
1736
1737// END IAmplifierControl
1738
1739// BEGIN IControlLimits
1740
1741ReturnValue ControlBoard_nwc_yarp::setPosLimits(int axis, double min, double max)
1742{
1743 LOCKMUTEX
1744 auto ret = m_RPC.setPosLimitsRPC(axis, min, max);
1745 if (!ret) {
1746 yCError(CONTROLBOARD_NWC_YARP, "Unable to setPosLimitsRPC");
1747 return ret;
1748 }
1749 return ret;
1750}
1751
1752ReturnValue ControlBoard_nwc_yarp::getPosLimits(int axis, double *min, double *max)
1753{
1754 LOCKMUTEX
1755 auto ret = m_RPC.getPosLimitsRPC(axis);
1756 if (!ret.ret) {
1757 yCError(CONTROLBOARD_NWC_YARP, "Unable to getPosLimitsRPC");
1758 return ret.ret;
1759 }
1760 *min = ret.min;
1761 *max = ret.max;
1762 return ret.ret;
1763}
1764
1765ReturnValue ControlBoard_nwc_yarp::setVelLimits(int axis, double min, double max)
1766{
1767 LOCKMUTEX
1768 auto ret = m_RPC.setVelLimitsRPC(axis, min, max);
1769 if (!ret) {
1770 yCError(CONTROLBOARD_NWC_YARP, "Unable to setVelLimitsRPC");
1771 return ret;
1772 }
1773 return ret;
1774}
1775
1776ReturnValue ControlBoard_nwc_yarp::getVelLimits(int axis, double *min, double *max)
1777{
1778 LOCKMUTEX
1779 auto ret = m_RPC.getVelLimitsRPC(axis);
1780 if (!ret.ret) {
1781 yCError(CONTROLBOARD_NWC_YARP, "Unable to getVelLimitsRPC");
1782 return ret.ret;
1783 }
1784 *min = ret.min;
1785 *max = ret.max;
1786 return ret.ret;
1787}
1788
1789// END IControlLimits
1790
1791// BEGIN IAxisInfo
1792
1794{
1795 LOCKMUTEX
1796 auto ret = m_RPC.getAxisNameRPC(j);
1797 if (!ret.ret) {
1798 yCError(CONTROLBOARD_NWC_YARP, "Unable to getAxisNameRPC");
1799 return ret.ret;
1800 }
1801 name = ret.name;
1802 return ret.ret;
1803}
1804
1806{
1807 LOCKMUTEX
1808 auto ret = m_RPC.getJointTypeRPC(j);
1809 if (!ret.ret) {
1810 yCError(CONTROLBOARD_NWC_YARP, "Unable to getJointTypeRPC");
1811 return ret.ret;
1812 }
1813 type = ret.joint;
1814 return ret.ret;
1815}
1816
1817// END IAxisInfo
1818
1819// BEGIN IControlCalibration
1821{
1822 LOCKMUTEX
1823 auto ret = m_RPC.calibrateRobotRPC();
1824 if (!ret) {
1825 yCError(CONTROLBOARD_NWC_YARP, "Unable to calibrateRobot");
1826 return ret;
1827 }
1828 return ret;
1829}
1830
1832{
1833 LOCKMUTEX
1834 auto ret = m_RPC.abortCalibrationRPC();
1835 if (!ret) {
1836 yCError(CONTROLBOARD_NWC_YARP, "Unable to abortCalibration");
1837 return ret;
1838 }
1839 return ret;
1840}
1841
1843{
1844 LOCKMUTEX
1845 auto ret = m_RPC.abortParkRPC();
1846 if (!ret) {
1847 yCError(CONTROLBOARD_NWC_YARP, "Unable to abortPark");
1848 return ret;
1849 }
1850 return ret;
1851}
1852
1854{
1855 LOCKMUTEX
1856 auto ret = m_RPC.parkRPC(wait);
1857 if (!ret) {
1858 yCError(CONTROLBOARD_NWC_YARP, "Unable to park");
1859 return ret;
1860 }
1861 return ret;
1862}
1863
1864yarp::dev::ReturnValue ControlBoard_nwc_yarp::calibrateAxisWithParams(int j, unsigned int ui, double v1, double v2, double v3)
1865{
1866 LOCKMUTEX
1867 auto ret = m_RPC.calibrateAxisWithParamsRPC(j, ui, v1, v2, v3);
1868 if (!ret) {
1869 yCError(CONTROLBOARD_NWC_YARP, "Unable to calibrateAxisWithParams");
1870 return ret;
1871 }
1872 return ret;
1873}
1874
1876{
1877 LOCKMUTEX
1879 cal.param1 = params.param1;
1880 cal.param2 = params.param2;
1881 cal.param3 = params.param3;
1882 cal.param4 = params.param4;
1883 cal.param5 = params.param5;
1884 cal.paramZero = params.paramZero;
1886 if (!ret) {
1887 yCError(CONTROLBOARD_NWC_YARP, "Unable to setCalibrationParameters");
1888 return ret;
1889 }
1890 return ret;
1891}
1892
1894{
1895 LOCKMUTEX
1896 auto ret = m_RPC.calibrationDoneRPC(j);
1897 if (!ret) {
1898 yCError(CONTROLBOARD_NWC_YARP, "Unable to calibrationDone");
1899 return ret;
1900 }
1901 return ret;
1902}
1903
1904// END IControlCalibration
1905
1906// BEGIN ITorqueControl
1907
1909{
1910 LOCKMUTEX
1911 auto ret = m_RPC.getRefTorqueOneRPC(j);
1912 if (!ret.ret) {
1913 yCError(CONTROLBOARD_NWC_YARP, "Unable to getRefTorqueOneRPC");
1914 return ret.ret;
1915 }
1916 *t = ret.val;
1917 return ret.ret;
1918}
1919
1921{
1922 LOCKMUTEX
1923 auto ret = m_RPC.getRefTorqueAllRPC();
1924 if (!ret.ret) {
1925 yCError(CONTROLBOARD_NWC_YARP, "Unable to getRefTorqueAllRPC");
1926 return ret.ret;
1927 }
1928
1929 std::copy(ret.val.begin(), ret.val.end(), t);
1930 return ret.ret;
1931}
1932
1934{
1935 if (m_use_streaming)
1936 {
1937 CHECK_INTERFACE("iTorqueControl")
1938 if (!isLive()) {
1939 return ReturnValue::return_code::return_value_error_not_ready;
1940 }
1942 c.head.clear();
1943 c.head.addVocab32(VOCAB_TORQUECONTROL_INTERFACE);
1944 c.head.addVocab32(VOCAB_TORQUES_DIRECTS);
1945
1946 c.body.resize(m_nj);
1947
1948 memcpy(c.body.data(), t, sizeof(double) * m_nj);
1949
1951 return ReturnValue_ok;
1952 }
1953 else
1954 {
1955 LOCKMUTEX
1956 std::vector<double> temp(t, t + this->m_nj);
1957 auto ret = m_RPC.setRefTorqueAllRPC(temp);
1958 if (!ret) {
1959 yCError(CONTROLBOARD_NWC_YARP, "Unable to setRefTorqueAllRPC");
1960 return ret;
1961 }
1962 return ret;
1963 }
1964}
1965
1967{
1968 if (m_use_streaming)
1969 {
1970 CHECK_INTERFACE("iTorqueControl")
1971 if (!isLive()) {
1972 return ReturnValue::return_code::return_value_error_not_ready;
1973 }
1975 c.head.clear();
1976 c.head.addVocab32(VOCAB_TORQUECONTROL_INTERFACE);
1977 c.head.addVocab32(VOCAB_TORQUES_DIRECT);
1978 c.head.addInt32(j);
1979
1980 c.body.clear();
1981 c.body.resize(1);
1982 c.body[0] = v;
1984 return ReturnValue_ok;
1985 }
1986 else
1987 {
1988 LOCKMUTEX
1989 auto ret = m_RPC.setRefTorqueOneRPC(j,v);
1990 if (!ret) {
1991 yCError(CONTROLBOARD_NWC_YARP, "Unable to setRefTorqueOneRPC");
1992 return ret;
1993 }
1994 return ret;
1995 }
1996}
1997
1998yarp::dev::ReturnValue ControlBoard_nwc_yarp::setRefTorques(const int n_joint, const int *joints, const double *t)
1999{
2000 if (m_use_streaming)
2001 {
2002 CHECK_INTERFACE("iTorqueControl")
2003 if (!isLive()) {
2004 return ReturnValue::return_code::return_value_error_not_ready;
2005 }
2007 c.head.clear();
2008 c.head.addVocab32(VOCAB_TORQUECONTROL_INTERFACE);
2009 c.head.addVocab32(VOCAB_TORQUES_DIRECT_GROUP);
2010 c.head.addInt32(n_joint);
2011 Bottle &jointList = c.head.addList();
2012 for (int i = 0; i < n_joint; i++) {
2013 jointList.addInt32(joints[i]);
2014 }
2015 c.body.resize(n_joint);
2016 memcpy(&(c.body[0]), t, sizeof(double)*n_joint);
2018 return ReturnValue_ok;
2019 }
2020 else
2021 {
2022 LOCKMUTEX
2023 std::vector<int> tempjoints(joints, joints + n_joint);
2024 std::vector<double> tempdata(t, t + n_joint);
2026 if (!ret) {
2027 yCError(CONTROLBOARD_NWC_YARP, "Unable to setRefTorqueGroupRPC");
2028 return ret;
2029 }
2030 return ret;
2031 }
2032}
2033
2035{
2036 LOCKMUTEX
2038 mparams.bemf = params.bemf;
2039 mparams.bemf_scale = params.bemf_scale;
2040 mparams.coulombNeg = params.coulombNeg;
2041 mparams.coulombPos = params.coulombPos;
2042 mparams.ktau = params.ktau;
2043 mparams.ktau_scale = params.ktau_scale;
2044 mparams.velocityThres = params.velocityThres;
2045 mparams.viscousNeg = params.viscousNeg;
2046 mparams.viscousPos = params.viscousPos;
2047 auto ret = m_RPC.setMotorTorqueParamsRPC(j, mparams);
2048 if (!ret) {
2049 yCError(CONTROLBOARD_NWC_YARP, "Unable to setMotorTorqueParamsRPC");
2050 return ret;
2051 }
2052 return ret;
2053}
2054
2056{
2057 LOCKMUTEX
2058 auto ret = m_RPC.getMotorTorqueParamsRPC(j);
2059 if (!ret.ret) {
2060 yCError(CONTROLBOARD_NWC_YARP, "Unable to getMotorTorqueParamsRPC");
2061 return ret.ret;
2062 }
2063 (*params).bemf = ret.params.bemf;
2064 (*params).bemf_scale = ret.params.bemf_scale;
2065 (*params).coulombNeg = ret.params.coulombNeg;
2066 (*params).coulombPos = ret.params.coulombPos;
2067 (*params).ktau = ret.params.ktau;
2068 (*params).ktau_scale = ret.params.ktau_scale;
2069 (*params).velocityThres = ret.params.velocityThres;
2070 (*params).viscousNeg = ret.params.viscousNeg;
2071 (*params).viscousPos = ret.params.viscousPos;
2072 return ret.ret;
2073}
2074
2076{
2077 double localArrivalTime=0.0;
2078 extendedPortMutex.lock();
2080 extendedPortMutex.unlock();
2081 return ret?ReturnValue_ok:ReturnValue::return_code::return_value_error_not_ready;
2082}
2083
2085{
2086 double localArrivalTime=0.0;
2087 extendedPortMutex.lock();
2089 extendedPortMutex.unlock();
2090 return ret?ReturnValue_ok:ReturnValue::return_code::return_value_error_not_ready;
2091}
2092
2094{
2095 LOCKMUTEX
2096 auto ret = m_RPC.getTorqueRangeOneRPC(j);
2097 if (!ret.ret) {
2098 yCError(CONTROLBOARD_NWC_YARP, "Unable to getTorqueRangeOneRPC");
2099 return ret.ret;
2100 }
2101 *min = ret.min;
2102 *max = ret.max;
2103 return ret.ret;
2104}
2105
2107{
2108 LOCKMUTEX
2109 auto ret = m_RPC.getTorqueRangeAllRPC();
2110 if (!ret.ret) {
2111 yCError(CONTROLBOARD_NWC_YARP, "Unable to getTorqueRangeAllRPC");
2112 return ret.ret;
2113 }
2114 std::copy(ret.mins.begin(), ret.mins.end(), min);
2115 std::copy(ret.maxs.begin(), ret.maxs.end(), max);
2116 return ret.ret;
2117}
2118
2119// END ITorqueControl
2120
2121// BEGIN IImpedanceControl
2122
2123yarp::dev::ReturnValue ControlBoard_nwc_yarp::getImpedance(int j, double *stiffness, double *damping)
2124{
2125 LOCKMUTEX
2126 auto ret = m_RPC.getImpedanceRPC(j);
2127 if (!ret.ret) {
2128 yCError(CONTROLBOARD_NWC_YARP, "Unable to getImpedanceRPC");
2129 return ret.ret;
2130 }
2131 *stiffness = ret.stiffness;
2132 *damping = ret.damping;
2133 return ret.ret;
2134}
2135
2137{
2138 LOCKMUTEX
2139 auto ret = m_RPC.getImpedanceOffsetRPC(j);
2140 if (!ret.ret) {
2141 yCError(CONTROLBOARD_NWC_YARP, "Unable to getImpedanceOffsetRPC");
2142 return ret.ret;
2143 }
2144 *offset = ret.offset;
2145 return ret.ret;
2146}
2147
2148yarp::dev::ReturnValue ControlBoard_nwc_yarp::setImpedance(int j, double stiffness, double damping)
2149{
2150 LOCKMUTEX
2151 auto ret = m_RPC.setImpedanceRPC(j,stiffness, damping);
2152 if (!ret) {
2153 yCError(CONTROLBOARD_NWC_YARP, "Unable to setImpedance");
2154 return ret;
2155 }
2156 return ret;
2157}
2158
2160{
2161 LOCKMUTEX
2162 auto ret = m_RPC.setImpedanceOffsetRPC(j,offset);
2163 if (!ret) {
2164 yCError(CONTROLBOARD_NWC_YARP, "Unable to setImpedanceOffset");
2165 return ret;
2166 }
2167 return ret;
2168}
2169
2170yarp::dev::ReturnValue ControlBoard_nwc_yarp::getCurrentImpedanceLimit(int j, double *min_stiff, double *max_stiff, double *min_damp, double *max_damp)
2171{
2172 LOCKMUTEX
2173 auto ret = m_RPC.getCurrentImpedanceLimitRPC(j);
2174 if (!ret.ret) {
2175 yCError(CONTROLBOARD_NWC_YARP, "Unable to getCurrentImpedanceLimitRPC");
2176 return ret.ret;
2177 }
2178 *min_stiff = ret.min_stiffness;
2179 *max_stiff = ret.max_stiffness;
2180 *min_damp = ret.min_damping;
2181 *max_damp = ret.max_damping;
2182 return ret.ret;
2183}
2184
2185// END IImpedanceControl
2186
2187// BEGIN IControlMode
2188
2189ReturnValue ControlBoard_nwc_yarp::getAvailableControlModes(int j, std::vector<yarp::dev::SelectableControlModeEnum>& avail)
2190{
2191 LOCKMUTEX
2192 auto ret = m_RPC.getAvailableControlModesRPC(j);
2193 if (!ret.ret) {
2194 yCError(CONTROLBOARD_NWC_YARP, "Unable to getAvailableControlModes");
2195 return ret.ret;
2196 }
2197 avail =ret.avail;
2198 return ret.ret;
2199}
2200
2202{
2203 double localArrivalTime=0.0;
2204 extendedPortMutex.lock();
2205 int mode_tmp;
2208 extendedPortMutex.unlock();
2209 return ret?ReturnValue_ok:ReturnValue::return_code::return_value_error_not_ready;
2210}
2211
2212yarp::dev::ReturnValue ControlBoard_nwc_yarp::getControlModes(std::vector<yarp::dev::ControlModeEnum>& modes)
2213{
2214 double localArrivalTime=0.0;
2215 extendedPortMutex.lock();
2217 if(ret)
2218 {
2219 for (int i = 0; i < modes.size(); i++) {
2221 }
2222 } else {
2223 ret = false;
2224 }
2225
2226 extendedPortMutex.unlock();
2227 return ret?ReturnValue_ok:ReturnValue::return_code::return_value_error_not_ready;
2228}
2229
2230yarp::dev::ReturnValue ControlBoard_nwc_yarp::getControlModes(const std::vector<int>& joints, std::vector<yarp::dev::ControlModeEnum>& modes)
2231{
2232 double localArrivalTime=0.0;
2233
2234 extendedPortMutex.lock();
2236 if(ret)
2237 {
2238 for (int i = 0; i < joints.size(); i++) {
2240 }
2241 } else {
2242 ret = false;
2243 }
2244
2245 extendedPortMutex.unlock();
2246 return ret?ReturnValue_ok:ReturnValue::return_code::return_value_error_not_ready;
2247}
2248
2250{
2251 LOCKMUTEX
2252 auto ret = m_RPC.setControlModeOneRPC(j, mode);
2253 if (!ret) {
2254 yCError(CONTROLBOARD_NWC_YARP, "Unable to setControlMode");
2255 return ret;
2256 }
2257 return ret;
2258}
2259
2260yarp::dev::ReturnValue ControlBoard_nwc_yarp::setControlModes(const std::vector<int>& j, const std::vector<yarp::dev::SelectableControlModeEnum>& modes)
2261{
2262 LOCKMUTEX
2263 auto ret = m_RPC.setControlModeGroupRPC(j, modes);
2264 if (!ret) {
2265 yCError(CONTROLBOARD_NWC_YARP, "Unable to setControlModes");
2266 return ret;
2267 }
2268 return ret;
2269}
2270
2271yarp::dev::ReturnValue ControlBoard_nwc_yarp::setControlModes(const std::vector<yarp::dev::SelectableControlModeEnum>& modes)
2272{
2273 LOCKMUTEX
2274 auto ret = m_RPC.setControlModeAllRPC(modes);
2275 if (!ret) {
2276 yCError(CONTROLBOARD_NWC_YARP, "Unable to setControlModes");
2277 return ret;
2278 }
2279 return ret;
2280}
2281
2282// END IControlMode
2283
2284// BEGIN IPositionDirect
2285
2287{
2288 if (m_use_streaming)
2289 {
2290 CHECK_INTERFACE("iPositionDirect")
2291 if (!isLive()) {
2292 return ReturnValue::return_code::return_value_error_not_ready;
2293 }
2295 c.head.clear();
2297 c.head.addVocab32(VOCAB_POSITION_DIRECT);
2298 c.head.addInt32(j);
2299 c.body.resize(1);
2300 memcpy(&(c.body[0]), &ref, sizeof(double));
2302 return ReturnValue_ok;
2303 }
2304 else
2305 {
2306 LOCKMUTEX
2307 auto ret = m_RPC.setRefPositionOneRPC(j, ref);
2308 if (!ret) {
2309 yCError(CONTROLBOARD_NWC_YARP, "Unable to setPositionOneRPC");
2310 return ret;
2311 }
2312 return ret;
2313 }
2314}
2315
2316yarp::dev::ReturnValue ControlBoard_nwc_yarp::setPositions(const int n_joint, const int *joints, const double *refs)
2317{
2318 if (m_use_streaming)
2319 {
2320 CHECK_INTERFACE("iPositionDirect")
2321 if (!isLive()) {
2322 return ReturnValue::return_code::return_value_error_not_ready;
2323 }
2325 c.head.clear();
2327 c.head.addVocab32(VOCAB_POSITION_DIRECT_GROUP);
2328 c.head.addInt32(n_joint);
2329 Bottle &jointList = c.head.addList();
2330 for (int i = 0; i < n_joint; i++) {
2331 jointList.addInt32(joints[i]);
2332 }
2333 c.body.resize(n_joint);
2334 memcpy(&(c.body[0]), refs, sizeof(double)*n_joint);
2336 return ReturnValue_ok;
2337 }
2338 else
2339 {
2340 LOCKMUTEX
2341 std::vector<int> tempjoints(joints, joints + n_joint);
2342 std::vector<double> tempdata(refs, refs + n_joint);
2344 if (!ret) {
2345 yCError(CONTROLBOARD_NWC_YARP, "Unable to setPositionGroupRPC");
2346 return ret;
2347 }
2348 return ret;
2349 }
2350}
2351
2353{
2354 if (m_use_streaming)
2355 {
2356 CHECK_INTERFACE("iPositionDirect")
2357 if (!isLive()) {
2358 return ReturnValue::return_code::return_value_error_not_ready;
2359 }
2361 c.head.clear();
2363 c.head.addVocab32(VOCAB_POSITION_DIRECTS);
2364 c.body.resize(m_nj);
2365 memcpy(&(c.body[0]), refs, sizeof(double)*m_nj);
2367 return ReturnValue_ok;
2368 }
2369 else
2370 {
2371 LOCKMUTEX
2372 std::vector<double> temp(refs, refs + m_nj);
2373 auto ret = m_RPC.setRefPositionAllRPC(temp);
2374 if (!ret) {
2375 yCError(CONTROLBOARD_NWC_YARP, "Unable to setPositionAllRPC");
2376 return ret;
2377 }
2378 return ret;
2379 }
2380}
2381
2383{
2384 LOCKMUTEX
2385 auto ret = m_RPC.getRefPositionOneRPC(joint);
2386 if (!ret.ret) {
2387 yCError(CONTROLBOARD_NWC_YARP, "Unable to getRefPositionOneRPC");
2388 return ret.ret;
2389 }
2390 *ref = ret.val;
2391 return ret.ret;
2392}
2393
2395{
2396 LOCKMUTEX
2397 auto ret = m_RPC.getRefPositionAllRPC();
2398 if (!ret.ret) {
2399 yCError(CONTROLBOARD_NWC_YARP, "Unable to getRefPositionAllRPC");
2400 return ret.ret;
2401 }
2402 std::copy(ret.val.begin(), ret.val.end(), refs);
2403 return ret.ret;
2404}
2405
2407{
2408 LOCKMUTEX
2409 std::vector<int> tempjoints(joints, joints + n_joint);
2411 if (!ret.ret) {
2412 yCError(CONTROLBOARD_NWC_YARP, "Unable to getRefPositionGroupRPC");
2413 return ret.ret;
2414 }
2415 std::copy(ret.val.begin(), ret.val.end(), refs);
2416 return ret.ret;
2417}
2418
2419// END IPositionDirect
2420
2421// BEGIN IVelocityControl
2422
2423yarp::dev::ReturnValue ControlBoard_nwc_yarp::velocityMove(const int n_joint, const int *joints, const double *spds)
2424{
2425 if (m_use_streaming)
2426 {
2427 CHECK_INTERFACE("iVelocityControl")
2428 if (!isLive()) {
2429 return ReturnValue::return_code::return_value_error_not_ready;
2430 }
2432 c.head.clear();
2433 c.head.addVocab32(VOCAB_VELOCITYCONTROL_INTERFACE);
2434 c.head.addVocab32(VOCAB_VELOCITY_MOVE_GROUP);
2435 c.head.addInt32(n_joint);
2436 Bottle &jointList = c.head.addList();
2437 for (int i = 0; i < n_joint; i++) {
2438 jointList.addInt32(joints[i]);
2439 }
2440 c.body.resize(n_joint);
2441 memcpy(&(c.body[0]), spds, sizeof(double)*n_joint);
2443 return ReturnValue_ok;
2444 }
2445 else
2446 {
2447 LOCKMUTEX
2448 std::vector<int> tempjoints(joints, joints + n_joint);
2449 std::vector<double> tempdata(spds, spds + n_joint);
2451 if (!ret) {
2452 yCError(CONTROLBOARD_NWC_YARP, "Unable to velocityMoveGroupRPC");
2453 return ret;
2454 }
2455 return ret;
2456 }
2457}
2458
2460{
2461 LOCKMUTEX
2462 auto ret = m_RPC.getTargetVelocityOneRPC(joint);
2463 if (!ret.ret) {
2464 yCError(CONTROLBOARD_NWC_YARP, "Unable to getTargetVelocityOneRPC");
2465 return ret.ret;
2466 }
2467 *vel = ret.val;
2468 return ret.ret;
2469}
2470
2472{
2473 LOCKMUTEX
2474 auto ret = m_RPC.getTargetVelocityAllRPC();
2475 if (!ret.ret) {
2476 yCError(CONTROLBOARD_NWC_YARP, "Unable to getTargetVelocityAllRPC");
2477 return ret.ret;
2478 }
2479 std::copy(ret.val.begin(), ret.val.end(), vels);
2480 return ret.ret;
2481}
2482
2484{
2485 LOCKMUTEX
2486 std::vector<int> tempjoints(joints, joints + n_joint);
2488 if (!ret.ret) {
2489 yCError(CONTROLBOARD_NWC_YARP, "Unable to getTargetVelocityGroupRPC");
2490 return ret.ret;
2491 }
2492 std::copy(ret.val.begin(), ret.val.end(), vels);
2493 return ret.ret;
2494}
2495
2496// END IVelocityControl
2497
2498// BEGIN IInteractionMode
2499
2501{
2502 double localArrivalTime=0.0;
2503 extendedPortMutex.lock();
2504 int mode_tmp;
2507 extendedPortMutex.unlock();
2508 return ret?ReturnValue_ok:ReturnValue::return_code::return_value_error_not_ready;
2509}
2510
2511yarp::dev::ReturnValue ControlBoard_nwc_yarp::getInteractionModes(const std::vector<int>& joints, std::vector<yarp::dev::InteractionModeEnum>& modes)
2512{
2513 double localArrivalTime=0.0;
2514
2515 extendedPortMutex.lock();
2517 if(ret)
2518 {
2519 for (int i = 0; i < joints.size(); i++) {
2521 }
2522 } else {
2523 ret = false;
2524 }
2525
2526 extendedPortMutex.unlock();
2527 return ret?ReturnValue_ok:ReturnValue::return_code::return_value_error_not_ready;
2528}
2529
2530yarp::dev::ReturnValue ControlBoard_nwc_yarp::getInteractionModes(std::vector<yarp::dev::InteractionModeEnum>& modes)
2531{
2532 double localArrivalTime=0.0;
2533 extendedPortMutex.lock();
2535 if(ret)
2536 {
2537 for (int i = 0; i < modes.size(); i++) {
2539 }
2540 } else {
2541 ret = false;
2542 }
2543 extendedPortMutex.unlock();
2544 return ret?ReturnValue_ok:ReturnValue::return_code::return_value_error_not_ready;
2545}
2546
2548{
2549 LOCKMUTEX
2550 auto ret = m_RPC.setInteractionModeOneRPC(axis,mode);
2551 if (!ret) {
2552 yCError(CONTROLBOARD_NWC_YARP, "Unable to setInteractionModeRPC");
2553 return ret;
2554 }
2555 return ret;
2556}
2557
2558yarp::dev::ReturnValue ControlBoard_nwc_yarp::setInteractionModes(const std::vector<int>& joints, const std::vector<yarp::dev::InteractionModeEnum>& modes)
2559{
2560 LOCKMUTEX
2561 auto ret = m_RPC.setInteractionModesGroupRPC(joints, modes);
2562 if (!ret) {
2563 yCError(CONTROLBOARD_NWC_YARP, "Unable to setInteractionModesGroupRPC");
2564 return ret;
2565 }
2566 return ret;}
2567
2568yarp::dev::ReturnValue ControlBoard_nwc_yarp::setInteractionModes(const std::vector<yarp::dev::InteractionModeEnum>& modes)
2569{
2570 LOCKMUTEX
2571 auto ret = m_RPC.setInteractionModesAllRPC(modes);
2572 if (!ret) {
2573 yCError(CONTROLBOARD_NWC_YARP, "Unable to setInteractionModesAllRPC");
2574 return ret;
2575 }
2576 return ret;}
2577
2578// END IInteractionMode
2579
2580// BEGIN IRemoteCalibrator
2581
2583{
2584 LOCKMUTEX
2586 if (!ret.ret) {
2587 yCError(CONTROLBOARD_NWC_YARP, "Unable to isCalibratorDevicePresentRPC");
2588 return ret.ret;
2589 }
2590 *isCalib = ret.isPresent;
2591 return ret.ret;
2592}
2593
2595{
2596 LOCKMUTEX
2597 auto ret = m_RPC.calibrateSingleJointRPC(j);
2598 if (!ret) {
2599 yCError(CONTROLBOARD_NWC_YARP, "Unable to calibrateSingleJoint");
2600 return ret;
2601 }
2602 return ret;
2603}
2604
2606{
2607 LOCKMUTEX
2608 auto ret = m_RPC.calibrateWholePartRPC();
2609 if (!ret) {
2610 yCError(CONTROLBOARD_NWC_YARP, "Unable to calibrateWholePart");
2611 return ret;
2612 }
2613 return ret;
2614}
2615
2617{
2618 LOCKMUTEX
2619 auto ret = m_RPC.homingSingleJointRPC(j);
2620 if (!ret) {
2621 yCError(CONTROLBOARD_NWC_YARP, "Unable to homingSingleJoint");
2622 return ret;
2623 }
2624 return ret;
2625}
2626
2628{
2629 LOCKMUTEX
2630 auto ret = m_RPC.homingWholePartRPC();
2631 if (!ret) {
2632 yCError(CONTROLBOARD_NWC_YARP, "Unable to homingWholePart");
2633 return ret;
2634 }
2635 return ret;
2636}
2637
2639{
2640 LOCKMUTEX
2641 auto ret = m_RPC.parkSingleJointRPC(j,_wait);
2642 if (!ret) {
2643 yCError(CONTROLBOARD_NWC_YARP, "Unable to parkSingleJoint");
2644 return ret;
2645 }
2646 return ret;
2647}
2648
2650{
2651 LOCKMUTEX
2652 auto ret = m_RPC.parkWholePartRPC();
2653 if (!ret) {
2654 yCError(CONTROLBOARD_NWC_YARP, "Unable to parkWholePart");
2655 return ret;
2656 }
2657 return ret;
2658}
2659
2661{
2662 LOCKMUTEX
2663 auto ret = m_RPC.quitCalibrateRPC();
2664 if (!ret) {
2665 yCError(CONTROLBOARD_NWC_YARP, "Unable to quitCalibrate");
2666 return ret;
2667 }
2668 return ret;
2669}
2670
2672{
2673 LOCKMUTEX
2674 auto ret = m_RPC.quitParkRPC();
2675 if (!ret) {
2676 yCError(CONTROLBOARD_NWC_YARP, "Unable to quitPark");
2677 return ret;
2678 }
2679 return ret;
2680}
2681
2682// END IRemoteCalibrator
2683
2684// BEGIN ICurrentControl
2685
2687{
2688 LOCKMUTEX
2689 auto ret = m_RPC.getRefCurrentAllRPC();
2690 if (!ret.ret) {
2691 yCError(CONTROLBOARD_NWC_YARP, "Unable to getRefCurrentAllRPC");
2692 return ret.ret;
2693 }
2694 std::copy(ret.refs.begin(), ret.refs.end(), t);
2695 return ret.ret;
2696}
2697
2699{
2700 LOCKMUTEX
2701 auto ret = m_RPC.getRefCurrentOneRPC(j);
2702 if (!ret.ret) {
2703 yCError(CONTROLBOARD_NWC_YARP, "Unable to getRefCurrentOneRPC");
2704 return ret.ret;
2705 }
2706 *t = ret.ref;
2707 return ret.ret;
2708}
2709
2711{
2712 if (m_use_streaming)
2713 {
2714 CHECK_INTERFACE("iCurrentControl")
2715 if (!isLive()) {
2716 return ReturnValue::return_code::return_value_error_not_ready;
2717 }
2719 c.head.clear();
2720 c.head.addVocab32(VOCAB_CURRENTCONTROL_INTERFACE);
2721 c.head.addVocab32(VOCAB_CURRENT_REFS);
2722 c.body.resize(m_nj);
2723 memcpy(&(c.body[0]), refs, sizeof(double)*m_nj);
2725 return ReturnValue_ok;
2726 }
2727 else
2728 {
2729 LOCKMUTEX
2730 std::vector<double> temp(refs, refs + this->m_nj);
2731 auto ret = m_RPC.setRefCurrentAllRPC(temp);
2732 if (!ret) {
2733 yCError(CONTROLBOARD_NWC_YARP, "Unable to setRefCurrentAllRPC");
2734 return ret;
2735 }
2736 return ret;
2737 }
2738}
2739
2741{
2742 LOCKMUTEX
2743 auto ret = m_RPC.setRefCurrentOneRPC(j,ref);
2744 if (!ret) {
2745 yCError(CONTROLBOARD_NWC_YARP, "Unable to setRefCurrentOneRPC");
2746 return ret;
2747 }
2748 return ret;
2749}
2750
2751yarp::dev::ReturnValue ControlBoard_nwc_yarp::setRefCurrents(const int n_joint, const int *joints, const double *refs)
2752{
2753 if (m_use_streaming)
2754 {
2755 CHECK_INTERFACE("iCurrentControl")
2756 if (!isLive()) {
2757 return ReturnValue::return_code::return_value_error_not_ready;
2758 }
2760 c.head.clear();
2761 c.head.addVocab32(VOCAB_CURRENTCONTROL_INTERFACE);
2762 c.head.addVocab32(VOCAB_CURRENT_REF_GROUP);
2763 c.head.addInt32(n_joint);
2764 Bottle &jointList = c.head.addList();
2765 for (int i = 0; i < n_joint; i++) {
2766 jointList.addInt32(joints[i]);
2767 }
2768 c.body.resize(n_joint);
2769 memcpy(&(c.body[0]), refs, sizeof(double)*n_joint);
2771 return ReturnValue_ok;
2772 }
2773 else
2774 {
2775 LOCKMUTEX
2776 std::vector<int> tempjoints(joints, joints + n_joint);
2777 std::vector<double> tempdata(refs, refs + n_joint);
2779 if (!ret) {
2780 yCError(CONTROLBOARD_NWC_YARP, "Unable to setRefCurrentGroupRPC");
2781 return ret;
2782 }
2783 return ret;
2784 }
2785}
2786
2788{
2789 if (m_use_streaming)
2790 {
2791 CHECK_INTERFACE("iCurrentControl")
2792 if (!isLive()) {
2793 return ReturnValue::return_code::return_value_error_not_ready;
2794 }
2795 double localArrivalTime=0.0;
2796 extendedPortMutex.lock();
2798 extendedPortMutex.unlock();
2799 return ret?ReturnValue_ok:ReturnValue::return_code::return_value_error_not_ready;
2800 }
2801 else
2802 {
2803 LOCKMUTEX
2804 auto ret = m_RPC.getCurrentAllRPC();
2805 if (!ret.ret) {
2806 yCError(CONTROLBOARD_NWC_YARP, "Unable to getCurrentAllRPC");
2807 return ret.ret;
2808 }
2809 std::copy(ret.currs.begin(), ret.currs.end(), vals);
2810 return ret.ret;
2811 }
2812}
2813
2815{
2816 if (m_use_streaming)
2817 {
2818 CHECK_INTERFACE("iCurrentControl")
2819 if (!isLive()) {
2820 return ReturnValue::return_code::return_value_error_not_ready;
2821 }
2822 double localArrivalTime = 0.0;
2823 extendedPortMutex.lock();
2825 extendedPortMutex.unlock();
2826 return ret?ReturnValue_ok:ReturnValue::return_code::return_value_error_not_ready;
2827 }
2828 else
2829 {
2830 LOCKMUTEX
2831 auto ret = m_RPC.getCurrentOneRPC(j);
2832 if (!ret.ret) {
2833 yCError(CONTROLBOARD_NWC_YARP, "Unable to getCurrentOneRPC");
2834 return ret.ret;
2835 }
2836 *val = ret.curr;
2837 return ret.ret;
2838 }
2839}
2840
2842{
2843 LOCKMUTEX
2844 auto ret = m_RPC.getCurrentRangeOneRPC(j);
2845 if (!ret.ret) {
2846 yCError(CONTROLBOARD_NWC_YARP, "Unable to getCurrentRangeOneRPC");
2847 return ret.ret;
2848 }
2849 *max = ret.max;
2850 *min = ret.min;
2851 return ret.ret;
2852}
2853
2855{
2856 LOCKMUTEX
2857 auto ret = m_RPC.getCurrentRangeAllRPC();
2858 if (!ret.ret) {
2859 yCError(CONTROLBOARD_NWC_YARP, "Unable to getCurrentRangeOneRPC");
2860 return ret.ret;
2861 }
2862 std::copy(ret.mins.begin(), ret.mins.end(), min);
2863 std::copy(ret.maxs.begin(), ret.maxs.end(), max);
2864 return ret.ret;
2865}
2866
2867// END ICurrentControl
2868
2869// BEGIN IPWMControl
2871{
2872 LOCKMUTEX
2873 auto ret = m_RPC.setRefDutyCycleOneRPC(j,v);
2874 if (!ret) {
2875 yCError(CONTROLBOARD_NWC_YARP, "Unable to setRefDutyCycle");
2876 return ret;
2877 }
2878 return ret;
2879}
2880
2882{
2883 if (m_use_streaming)
2884 {
2885 CHECK_INTERFACE("iPwmControl")
2886 if (!isLive()) {
2887 return ReturnValue::return_code::return_value_error_not_ready;
2888 }
2890 c.head.clear();
2891 c.head.addVocab32(VOCAB_PWMCONTROL_INTERFACE);
2892 c.head.addVocab32(VOCAB_PWMCONTROL_REF_PWMS);
2893
2894 c.body.resize(m_nj);
2895
2896 memcpy(&(c.body[0]), v, sizeof(double)*m_nj);
2897
2899 return ReturnValue_ok;
2900 }
2901 else
2902 {
2903 LOCKMUTEX
2904 std::vector<double> temp(v, v + this->m_nj);
2905 auto ret = m_RPC.setRefDutyCycleAllRPC(temp);
2906 if (!ret) {
2907 yCError(CONTROLBOARD_NWC_YARP, "Unable to setRefDutyCycleAllRPC");
2908 return ret;
2909 }
2910 return ret;
2911 }
2912}
2913
2915{
2916 LOCKMUTEX
2917 auto ret = m_RPC.getRefDutyCycleOneRPC(j);
2918 if (!ret.ret) {
2919 yCError(CONTROLBOARD_NWC_YARP, "Unable to getRefDutyCycle");
2920 return ret.ret;
2921 }
2922 *ref = ret.val;
2923 return ret.ret;
2924}
2925
2927{
2928 LOCKMUTEX
2929 auto ret = m_RPC.getRefDutyCycleAllRPC();
2930 if (!ret.ret) {
2931 yCError(CONTROLBOARD_NWC_YARP, "Unable to getRefDutyCycle");
2932 return ret.ret;
2933 }
2934 std::copy(ret.val.begin(), ret.val.end(), refs);
2935 return ret.ret;
2936}
2937
2939{
2940 double localArrivalTime = 0.0;
2941 extendedPortMutex.lock();
2943 extendedPortMutex.unlock();
2944 return ret?ReturnValue_ok:ReturnValue::return_code::return_value_error_not_ready;
2945}
2946
2948{
2949 double localArrivalTime = 0.0;
2950 extendedPortMutex.lock();
2952 extendedPortMutex.unlock();
2953 return ret?ReturnValue_ok:ReturnValue::return_code::return_value_error_not_ready;
2954}
2955// END IPWMControl
2956
2957// BEGIN IJointBrake
2959{
2960 LOCKMUTEX
2961 auto ret = m_RPC.isJointBrakedRPC(j);
2962 if (!ret.ret) {
2963 yCError(CONTROLBOARD_NWC_YARP, "Unable to isJointBraked");
2964 return ret.ret;
2965 }
2966 braked = ret.isBraked;
2967 return ret.ret;
2968}
2969
2971{
2972 LOCKMUTEX
2973 auto ret = m_RPC.setManualBrakeActiveRPC(j,active);
2974 if (!ret) {
2975 yCError(CONTROLBOARD_NWC_YARP, "Unable to setManualBrakeActive");
2976 return ret;
2977 }
2978 return ret;
2979}
2980
2982{
2983 LOCKMUTEX
2984 auto ret = m_RPC.setAutoBrakeEnabledRPC(j,enabled);
2985 if (!ret) {
2986 yCError(CONTROLBOARD_NWC_YARP, "Unable to setAutoBrakeEnabled");
2987 return ret;
2988 }
2989 return ret;
2990}
2991
2993{
2994 LOCKMUTEX
2995 auto ret = m_RPC.getAutoBrakeEnabledRPC(j);
2996 if (!ret.ret) {
2997 yCError(CONTROLBOARD_NWC_YARP, "Unable to getAutoBrakeEnabled");
2998 return ret.ret;
2999 }
3000 enabled = ret.enabled;
3001 return ret.ret;
3002}
3003// END IJointBrake
3004
3005// IVelocityDirect
3007{
3008 LOCKMUTEX
3009 auto ret = m_RPC.getAxesRPC();
3010 if (!ret.ret) {
3011 yCError(CONTROLBOARD_NWC_YARP, "Unable to getAxes");
3012 return ret.ret;
3013 }
3014 axes = ret.axes;
3015 return ret.ret;
3016}
3017
3019{
3020 if (m_use_streaming)
3021 {
3022 CHECK_INTERFACE("iVelocityDirect")
3023 if (!isLive()) {
3024 return ReturnValue::return_code::return_value_error_not_ready;
3025 }
3027 c.head.clear();
3029 c.head.addVocab32(VOCAB_VELOCITY_DIRECT_SET_ONE);
3030 c.head.addInt32(jnt);
3031 c.body.resize(1);
3032 c.body[0] = vel;
3034 return ReturnValue_ok;
3035 }
3036 else
3037 {
3038 LOCKMUTEX
3039 auto ret = m_RPC.setRefVelocityOneRPC(jnt,vel);
3040 if (!ret) {
3041 yCError(CONTROLBOARD_NWC_YARP, "Unable to setRefVelocityOneRPC");
3042 return ret;
3043 }
3044 return ret;
3045 }
3046}
3047
3049{
3050 if (m_use_streaming)
3051 {
3052 CHECK_INTERFACE("iVelocityDirect")
3053 if (!isLive()) {
3054 return ReturnValue::return_code::return_value_error_not_ready;
3055 }
3057 c.head.clear();
3059 c.head.addVocab32(VOCAB_VELOCITY_DIRECT_SET_ALL);
3060 c.body.resize(m_nj);
3061 for (size_t i = 0; i < vels.size(); i++) {
3062 c.body[i]=vels[i];
3063 }
3065 return ReturnValue_ok;
3066 }
3067 else
3068 {
3069 LOCKMUTEX
3070 auto ret = m_RPC.setRefVelocityAllRPC(vels);
3071 if (!ret) {
3072 yCError(CONTROLBOARD_NWC_YARP, "Unable to setRefVelocityAllRPC");
3073 return ret;
3074 }
3075 return ret;
3076 }
3077}
3078
3079ReturnValue ControlBoard_nwc_yarp::setRefVelocity(const std::vector<int>& jnts, const std::vector<double>& vels)
3080{
3081 if (m_use_streaming)
3082 {
3083 CHECK_INTERFACE("iVelocityDirect")
3084 if (!isLive()) {
3085 return ReturnValue::return_code::return_value_error_not_ready;
3086 }
3088 c.head.clear();
3090 c.head.addVocab32(VOCAB_VELOCITY_DIRECT_SET_GROUP);
3091 c.head.addInt32(jnts.size());
3092 Bottle &jointList = c.head.addList();
3093 for (size_t i = 0; i < jnts.size(); i++) {
3094 jointList.addInt32(jnts[i]);
3095 }
3096 c.body.resize(jnts.size());
3097 for (size_t i = 0; i < jnts.size(); i++) {
3098 c.body[i]=vels[i];
3099 }
3101 return ReturnValue_ok;
3102 }
3103 else
3104 {
3105 LOCKMUTEX
3107 if (!ret) {
3108 yCError(CONTROLBOARD_NWC_YARP, "Unable to setRefVelocityGroupRPC");
3109 return ret;
3110 }
3111 return ret;
3112 }
3113}
3114
3116{
3117 LOCKMUTEX
3118 auto ret = m_RPC.getRefVelocityOneRPC(jnt);
3119 if (!ret.ret) {
3120 yCError(CONTROLBOARD_NWC_YARP, "Unable to getRefVelocityOneRPC");
3121 return ret.ret;
3122 }
3123 vel = ret.vel;
3124 return ret.ret;
3125}
3126
3128{
3129 LOCKMUTEX
3130 auto ret = m_RPC.getRefVelocityAllRPC();
3131 if (!ret.ret) {
3132 yCError(CONTROLBOARD_NWC_YARP, "Unable to getRefVelocityAllRPC");
3133 return ret.ret;
3134 }
3135 vels = ret.vel;
3136 return ret.ret;
3137}
3138
3139ReturnValue ControlBoard_nwc_yarp::getRefVelocity(const std::vector<int>& jnts, std::vector<double>& vels)
3140{
3141 LOCKMUTEX
3142 auto ret = m_RPC.getRefVelocityGroupRPC(jnts);
3143 if (!ret.ret) {
3144 yCError(CONTROLBOARD_NWC_YARP, "Unable to getRefVelocityGroupRPC");
3145 return ret.ret;
3146 }
3147 vels = ret.vel;
3148 return ret.ret;
3149}
define control board standard interfaces
constexpr yarp::conf::vocab32_t VOCAB_TIMESTAMP
#define CHECK_INTERFACE(VALUE)
#define LOCKMUTEX
const yarp::os::LogComponent & CONTROLBOARD_NWC_YARP()
FeatureMode mode
constexpr yarp::conf::vocab32_t VOCAB_AMP_CURRENT
constexpr yarp::conf::vocab32_t VOCAB_AMP_CURRENTS
constexpr yarp::conf::vocab32_t VOCAB_CM_CONTROL_MODES
constexpr yarp::conf::vocab32_t VOCAB_CM_CONTROL_MODE
constexpr yarp::conf::vocab32_t VOCAB_CURRENT_REF_GROUP
constexpr yarp::conf::vocab32_t VOCAB_CURRENT_REFS
constexpr yarp::conf::vocab32_t VOCAB_CURRENTCONTROL_INTERFACE
constexpr yarp::conf::vocab32_t VOCAB_ENCODER_ACCELERATIONS
Definition IEncoders.h:214
constexpr yarp::conf::vocab32_t VOCAB_ENCODER
Definition IEncoders.h:207
constexpr yarp::conf::vocab32_t VOCAB_ENCODER_SPEEDS
Definition IEncoders.h:212
constexpr yarp::conf::vocab32_t VOCAB_ENCODER_SPEED
Definition IEncoders.h:211
constexpr yarp::conf::vocab32_t VOCAB_ENCODER_ACCELERATION
Definition IEncoders.h:213
constexpr yarp::conf::vocab32_t VOCAB_ENCODERS
Definition IEncoders.h:208
constexpr yarp::conf::vocab32_t VOCAB_INTERACTION_MODES
constexpr yarp::conf::vocab32_t VOCAB_INTERACTION_MODE
constexpr yarp::conf::vocab32_t VOCAB_MOTOR_ENCODER_SPEED
constexpr yarp::conf::vocab32_t VOCAB_MOTOR_ENCODER_ACCELERATION
constexpr yarp::conf::vocab32_t VOCAB_MOTOR_ENCODER
constexpr yarp::conf::vocab32_t VOCAB_MOTOR_ENCODER_SPEEDS
constexpr yarp::conf::vocab32_t VOCAB_MOTOR_ENCODERS
constexpr yarp::conf::vocab32_t VOCAB_TEMPERATURE
Definition IMotor.h:161
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_PWM_OUTPUT
constexpr yarp::conf::vocab32_t VOCAB_PIDCONTROL_SET_FEEDFORWARD
constexpr yarp::conf::vocab32_t VOCAB_PIDCONTROL_INTERFACE
constexpr yarp::conf::vocab32_t VOCAB_PIDCONTROL_SET_OFFSET
constexpr yarp::conf::vocab32_t VOCAB_POSITIONDIRECTCONTROL_INTERFACE
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_TRQ
constexpr yarp::conf::vocab32_t VOCAB_TORQUES_DIRECTS
constexpr yarp::conf::vocab32_t VOCAB_TRQS
constexpr yarp::conf::vocab32_t VOCAB_TORQUES_DIRECT_GROUP
constexpr yarp::conf::vocab32_t VOCAB_TORQUES_DIRECT
constexpr yarp::conf::vocab32_t VOCAB_TORQUECONTROL_INTERFACE
constexpr yarp::conf::vocab32_t VOCAB_VELOCITY_MOVE
constexpr yarp::conf::vocab32_t VOCAB_VELOCITYCONTROL_INTERFACE
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_VELOCITYDIRECTCONTROL_INTERFACE
constexpr yarp::conf::vocab32_t VOCAB_VELOCITY_DIRECT_SET_GROUP
constexpr yarp::conf::vocab32_t VOCAB_VELOCITY_DIRECT_SET_ALL
#define ReturnValue_ok
Definition ReturnValue.h:82
virtual return_getTargetVelocityOne getTargetVelocityOneRPC(const std::int32_t j) const
virtual return_getCurrentImpedanceLimit getCurrentImpedanceLimitRPC(const std::int32_t j) const
virtual return_getTargetPositionGroup getTargetPositionGroupRPC(const std::vector< std::int32_t > &joints) const
virtual yarp::dev::ReturnValue setPeakCurrentRPC(const std::int32_t m, const double val)
virtual return_getRefTorqueAll getRefTorqueAllRPC() const
virtual yarp::dev::ReturnValue resetMotorEncoderRPC(const std::int32_t j)
virtual yarp::dev::ReturnValue setRefCurrentOneRPC(const std::int32_t j, const double ref)
virtual return_checkMotionDoneOne checkMotionDoneOneRPC(const std::int32_t j) const
virtual yarp::dev::ReturnValue setMotorEncoderCountsPerRevolutionRPC(const std::int32_t j, const double val)
virtual return_getPidExtraInfo getPidExtraInfoRPC(const yarp::dev::PidControlTypeEnum pidtype, const std::int16_t j) const
virtual yarp::dev::ReturnValue setRefCurrentGroupRPC(const std::vector< std::int32_t > &j, const std::vector< double > &refs)
virtual yarp::dev::ReturnValue calibrateSingleJointRPC(const std::int32_t j)
virtual return_getDeviceInterfaces getDeviceInterfacesRPC() const
virtual return_getPidOutputs getPidOutputsRPC(const yarp::dev::PidControlTypeEnum pidtype) const
virtual yarp::dev::ReturnValue calibrationDoneRPC(const std::int32_t j)
virtual yarp::dev::ReturnValue setControlModeGroupRPC(const std::vector< std::int32_t > &j, const std::vector< yarp::dev::SelectableControlModeEnum > &modes)
virtual return_isCalibratorDevicePresent isCalibratorDevicePresentRPC() const
virtual yarp::dev::ReturnValue setManualBrakeActiveRPC(const std::int32_t j, const bool active)
virtual yarp::dev::ReturnValue setTrajSpeedAllRPC(const std::vector< double > &spds)
virtual yarp::dev::ReturnValue setPWMLimitRPC(const std::int32_t m, const double val)
virtual yarp::dev::ReturnValue setInteractionModeOneRPC(const std::int32_t axis, const yarp::dev::InteractionModeEnum mode)
virtual yarp::dev::ReturnValue relativeMoveAllRPC(const std::vector< double > &deltas)
virtual return_getPid getPidRPC(const yarp::dev::PidControlTypeEnum pidtype, const std::int16_t j) const
virtual yarp::dev::ReturnValue velocityMoveAllRPC(const std::vector< double > &refs)
virtual return_getPowerSupplyVoltage getPowerSupplyVoltageRPC(const std::int32_t m) const
virtual yarp::dev::ReturnValue setPosLimitsRPC(const std::int16_t j, const double min, const double max)
virtual return_getRefDutyCycleAll getRefDutyCycleAllRPC() const
virtual return_getNumberOfMotors getNumberOfMotorsRPC() const
virtual yarp::dev::ReturnValue stopAllRPC()
virtual bool checkProtocolVersion()
virtual yarp::dev::ReturnValue parkWholePartRPC()
virtual yarp::dev::ReturnValue setRefPositionGroupRPC(const std::vector< std::int32_t > &j, const std::vector< double > &value)
virtual yarp::dev::ReturnValue homingSingleJointRPC(const std::int32_t j)
virtual yarp::dev::ReturnValue disablePidRPC(const yarp::dev::PidControlTypeEnum pidtype, const std::int16_t j)
virtual yarp::dev::ReturnValue setTrajAccelerationOneRPC(const std::int32_t j, const double acc)
virtual return_getMotorTorqueParams getMotorTorqueParamsRPC(const std::int32_t j)
virtual return_getTargetVelocityAll getTargetVelocityAllRPC() const
virtual return_getPidReferences getPidReferencesRPC(const yarp::dev::PidControlTypeEnum pidtype) const
virtual return_getVelLimits getVelLimitsRPC(const std::int16_t j) const
virtual return_getTrajAccelerationOne getTrajAccelerationOneRPC(const std::int32_t j) const
virtual return_getAmpStatusAll getAmpStatusAllRPC() const
virtual yarp::dev::ReturnValue setMotorTorqueParamsRPC(const std::int32_t j, const yMotorTorqueParameters &params)
virtual return_getTorqueRangeAll getTorqueRangeAllRPC() const
virtual return_getCurrentAll getCurrentAllRPC() const
virtual return_getTrajSpeedsAll getTrajSpeedsAllRPC() const
virtual return_getMaxCurrent getMaxCurrentRPC(const std::int32_t j) const
virtual yarp::dev::ReturnValue setControlModeOneRPC(const std::int32_t j, const yarp::dev::SelectableControlModeEnum mod)
virtual yarp::dev::ReturnValue setPidErrorLimitsRPC(const yarp::dev::PidControlTypeEnum pidtype, const std::vector< double > &limits)
virtual yarp::dev::ReturnValue setPidRPC(const yarp::dev::PidControlTypeEnum pidtype, const std::int16_t j, const yarp::dev::Pid &pid)
virtual return_getAvailableControlModes getAvailableControlModesRPC(const std::int16_t j) const
virtual yarp::dev::ReturnValue stopOneRPC(const std::int32_t j)
virtual return_getPWMLimit getPWMLimitRPC(const std::int32_t m) const
virtual return_isPidEnabled isPidEnabledRPC(const yarp::dev::PidControlTypeEnum pidtype, const std::int16_t j) const
virtual yarp::dev::ReturnValue parkSingleJointRPC(const std::int32_t j, const bool wait)
virtual return_getMotorEncoderCountsPerRevolution getMotorEncoderCountsPerRevolutionRPC(const std::int32_t m) const
virtual yarp::dev::ReturnValue disableAmpRPC(const std::int32_t j)
virtual yarp::dev::ReturnValue setEncoderOneRPC(const std::int32_t j, const double val)
virtual yarp::dev::ReturnValue calibrateRobotRPC()
virtual return_getTargetVelocityGroup getTargetVelocityGroupRPC(const std::vector< std::int32_t > &joints) const
virtual yarp::dev::ReturnValue setPidFeedforwardOneRPC(const yarp::dev::PidControlTypeEnum pidtype, const std::int16_t j, const double off)
virtual yarp::dev::ReturnValue setRefDutyCycleOneRPC(const std::int32_t j, const double v)
virtual return_getTargetPositionAll getTargetPositionAllRPC() const
virtual return_getRemoteVariable getRemoteVariableRPC(const std::string &key) const
virtual yarp::dev::ReturnValue resetPidRPC(const yarp::dev::PidControlTypeEnum pidtype, const std::int16_t j)
virtual return_getTrajSpeedOne getTrajSpeedOneRPC(const std::int32_t j) const
virtual yarp::dev::ReturnValue setRefVelocityAllRPC(const std::vector< double > &ref)
virtual yarp::dev::ReturnValue resetEncoderOneRPC(const std::int32_t j)
virtual return_getRefTorqueOne getRefTorqueOneRPC(const std::int32_t j) const
virtual yarp::dev::ReturnValue setEncoderAllRPC(const std::vector< double > &vals)
virtual yarp::dev::ReturnValue setMotorEncodersAllRPC(const std::vector< double > &vals)
virtual return_checkMotionDoneGroup checkMotionDoneGroupRPC(const std::vector< std::int32_t > &joints) const
virtual yarp::dev::ReturnValue setTrajAccelerationsGroupRPC(const std::vector< std::int32_t > &joints, const std::vector< double > &accs)
virtual yarp::dev::ReturnValue setRefPositionOneRPC(const std::int32_t j, const double value)
virtual yarp::dev::ReturnValue setTemperatureLimitRPC(const std::int32_t m, const double val)
virtual yarp::dev::ReturnValue setRefTorqueGroupRPC(const std::vector< std::int32_t > &j, const std::vector< double > &val)
virtual yarp::dev::ReturnValue setPidReferenceRPC(const yarp::dev::PidControlTypeEnum pidtype, const std::int16_t j, const double ref)
virtual yarp::dev::ReturnValue setNominalCurrentRPC(const std::int32_t m, const double val)
virtual yarp::dev::ReturnValue resetEncoderAllRPC()
virtual yarp::dev::ReturnValue setRefTorqueOneRPC(const std::int32_t j, const double val)
virtual yarp::dev::ReturnValue resetMotorEncodersRPC()
virtual return_getCurrentRangeOne getCurrentRangeOneRPC(const std::int32_t j) const
virtual return_getImpedanceOffset getImpedanceOffsetRPC(const std::int32_t j) const
virtual return_getPidOffset getPidOffsetRPC(const yarp::dev::PidControlTypeEnum pidtype, const std::int16_t j) const
virtual return_getGearboxRatio getGearboxRatioRPC(const std::int32_t m) const
virtual yarp::dev::ReturnValue setMaxCurrentRPC(const std::int32_t j, const double v)
virtual return_getRefPositionAll getRefPositionAllRPC() const
virtual yarp::dev::ReturnValue setAutoBrakeEnabledRPC(const std::int32_t j, const bool enabled)
virtual yarp::dev::ReturnValue quitCalibrateRPC()
virtual return_getAxes getAxesRPC() const
virtual yarp::dev::ReturnValue parkRPC(const bool wait)
virtual return_getAutoBrakeEnabled getAutoBrakeEnabledRPC(const std::int32_t j) const
virtual return_getNominalCurrent getNominalCurrentRPC(const std::int32_t m) const
virtual yarp::dev::ReturnValue positionMoveOneRPC(const std::int32_t j, const double ref)
virtual yarp::dev::ReturnValue quitParkRPC()
virtual yarp::dev::ReturnValue setPidReferencesRPC(const yarp::dev::PidControlTypeEnum pidtype, const std::vector< double > &refs)
virtual yarp::dev::ReturnValue enablePidRPC(const yarp::dev::PidControlTypeEnum pidtype, const std::int16_t j)
virtual yarp::dev::ReturnValue setGearboxRatioRPC(const std::int32_t m, const double val)
virtual return_getTrajSpeedsGroup getTrajSpeedsGroupRPC(const std::vector< std::int32_t > &joints) const
virtual yarp::dev::ReturnValue relativeMoveOneRPC(const std::int32_t j, const double delta)
virtual return_getRefPositionOne getRefPositionOneRPC(const std::int32_t j) const
virtual yarp::dev::ReturnValue calibrateWholePartRPC()
virtual return_getPidExtraInfos getPidExtraInfosRPC(const yarp::dev::PidControlTypeEnum pidtype) const
virtual return_getPeakCurrent getPeakCurrentRPC(const std::int32_t m) const
virtual yarp::dev::ReturnValue setImpedanceRPC(const std::int32_t j, const double stiffness, const double damping)
virtual return_getRefVelocityOne getRefVelocityOneRPC(const std::int32_t j) const
virtual yarp::dev::ReturnValue calibrateAxisWithParamsRPC(const std::int32_t j, const std::int32_t ui, const double v1, const double v2, const double v3)
virtual yarp::dev::ReturnValue setRefTorqueAllRPC(const std::vector< double > &val)
virtual yarp::dev::ReturnValue setTrajAccelerationsAllRPC(const std::vector< double > &accs)
virtual yarp::dev::ReturnValue setImpedanceOffsetRPC(const std::int32_t j, const double offset)
virtual yarp::dev::ReturnValue setVelLimitsRPC(const std::int16_t j, const double min, const double max)
virtual yarp::dev::ReturnValue setInteractionModesGroupRPC(const std::vector< std::int32_t > &joints, const std::vector< yarp::dev::InteractionModeEnum > &modes)
virtual yarp::dev::ReturnValue stopGroupRPC(const std::vector< std::int32_t > &joints)
virtual yarp::dev::ReturnValue setRefCurrentAllRPC(const std::vector< double > &refs)
virtual return_getAmpStatusOne getAmpStatusOneRPC(const std::int32_t j) const
virtual yarp::dev::ReturnValue homingWholePartRPC()
virtual yarp::dev::ReturnValue positionMoveGroupRPC(const std::vector< std::int32_t > &joints, const std::vector< double > &refs)
virtual yarp::dev::ReturnValue setTrajSpeedOneRPC(const std::int32_t j, const double sp)
virtual return_getImpedance getImpedanceRPC(const std::int32_t j) const
virtual return_getTargetPositionOne getTargetPositionOneRPC(const std::int32_t j) const
virtual return_getPidReference getPidReferenceRPC(const yarp::dev::PidControlTypeEnum pidtype, const std::int16_t j) const
virtual return_getTorqueRangeOne getTorqueRangeOneRPC(const std::int32_t j) const
virtual return_getPidErrorLimits getPidErrorLimitsRPC(const yarp::dev::PidControlTypeEnum pidtype) const
virtual return_getPidError getPidErrorRPC(const yarp::dev::PidControlTypeEnum pidtype, const std::int16_t j) const
virtual return_getRefVelocityAll getRefVelocityAllRPC() const
virtual return_getJointType getJointTypeRPC(const std::int32_t j)
virtual return_getCurrentOne getCurrentOneRPC(const std::int32_t j) const
virtual return_getRefDutyCycleOne getRefDutyCycleOneRPC(const std::int32_t j) const
virtual yarp::dev::ReturnValue setRefVelocityOneRPC(const std::int32_t j, const double ref)
virtual yarp::dev::ReturnValue setTrajSpeedGroupRPC(const std::vector< std::int32_t > &joints, const std::vector< double > &spds)
virtual return_checkMotionDoneAll checkMotionDoneAllRPC() const
virtual yarp::dev::ReturnValue velocityMoveOneRPC(const std::int32_t j, const double ref)
virtual yarp::dev::ReturnValue setRemoteVariableRPC(const std::string &key, const yarp::os::Bottle &val)
virtual return_getCurrentRangeAll getCurrentRangeAllRPC() const
virtual yarp::dev::ReturnValue setRefVelocityGroupRPC(const std::vector< std::int32_t > &j, const std::vector< double > &ref)
virtual yarp::dev::ReturnValue setCalibrationParametersRPC(const std::int32_t j, const yCalibrationParameters &params)
virtual return_getRemoteVariablesList getRemoteVariablesListRPC() const
virtual return_getPosLimits getPosLimitsRPC(const std::int16_t j) const
virtual return_getPidErrors getPidErrorsRPC(const yarp::dev::PidControlTypeEnum pidtype) const
virtual return_getPidOutput getPidOutputRPC(const yarp::dev::PidControlTypeEnum pidtype, const std::int16_t j) const
virtual return_getRefCurrentOne getRefCurrentOneRPC(const std::int32_t j) const
virtual yarp::dev::ReturnValue enableAmpRPC(const std::int32_t j)
virtual yarp::dev::ReturnValue setControlModeAllRPC(const std::vector< yarp::dev::SelectableControlModeEnum > &modes)
virtual yarp::dev::ReturnValue relativeMoveGroupRPC(const std::vector< std::int32_t > &joints, const std::vector< double > &refs)
virtual return_getPidFeedforward getPidFeedforwardRPC(const yarp::dev::PidControlTypeEnum pidtype, const std::int16_t j) const
virtual return_getAxisName getAxisNameRPC(const std::int32_t j)
virtual yarp::dev::ReturnValue abortCalibrationRPC()
virtual yarp::dev::ReturnValue setRefDutyCycleAllRPC(const std::vector< double > &v)
virtual yarp::dev::ReturnValue setPidsRPC(const yarp::dev::PidControlTypeEnum pidtype, const std::vector< yarp::dev::Pid > &pids)
virtual yarp::dev::ReturnValue abortParkRPC()
virtual return_getPids getPidsRPC(const yarp::dev::PidControlTypeEnum pidtype) const
virtual yarp::dev::ReturnValue velocityMoveGroupRPC(const std::vector< std::int32_t > &joints, const std::vector< double > &refs)
virtual return_isJointBraked isJointBrakedRPC(const std::int32_t j) const
virtual return_getAvailablePids getAvailablePidsRPC(const std::int16_t j) const
virtual return_getTemperatureLimit getTemperatureLimitRPC(const std::int32_t m) const
virtual return_getRefCurrentAll getRefCurrentAllRPC() const
virtual yarp::dev::ReturnValue positionMoveAllRPC(const std::vector< double > &refs)
virtual return_getRefVelocityGroup getRefVelocityGroupRPC(const std::vector< std::int32_t > &j) const
virtual yarp::dev::ReturnValue setPidOffsetOneRPC(const yarp::dev::PidControlTypeEnum pidtype, const std::int16_t j, const double off)
virtual return_getPidErrorLimit getPidErrorLimitRPC(const yarp::dev::PidControlTypeEnum pidtype, const std::int16_t j) const
virtual return_getTrajAccelerationAll getTrajAccelerationAllRPC() const
virtual return_getRefPositionGroup getRefPositionGroupRPC(const std::vector< std::int32_t > &j) const
virtual yarp::dev::ReturnValue setRefPositionAllRPC(const std::vector< double > &value)
virtual return_getNumberOfMotorEncoders getNumberOfMotorEncodersRPC() const
virtual return_getLastJointFault getLastJointFaultRPC(const std::int32_t j) const
virtual return_getTrajAccelerationGroup getTrajAccelerationGroupRPC(const std::vector< std::int32_t > &joints) const
virtual yarp::dev::ReturnValue setPidErrorLimitRPC(const yarp::dev::PidControlTypeEnum pidtype, const std::int16_t j, const double limit)
virtual yarp::dev::ReturnValue setInteractionModesAllRPC(const std::vector< yarp::dev::InteractionModeEnum > &modes)
virtual yarp::dev::ReturnValue setMotorEncoderRPC(const std::int32_t j, const double val)
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
yarp::dev::ReturnValue setCalibrationParameters(int j, const CalibrationParameters &params) override
Start calibration, this method is very often platform specific.
yarp::dev::ReturnValue setPid(const PidControlTypeEnum &pidtype, int j, const Pid &pid) override
Set new PID value for a joint axis.
yarp::dev::ReturnValue setImpedanceOffset(int j, double offset) override
Set current force Offset for a specific joint.
yarp::dev::ReturnValue calibrateWholePart() override
calibrateWholePart: call the procedure for calibrating the whole device
yarp::dev::ReturnValue setImpedance(int j, double stiffness, double damping) override
Set current impedance gains (stiffness,damping) for a specific joint.
StateExtendedInputPort extendedIntputStatePort
yarp::dev::ReturnValue getTrajAccelerations(const int n_joint, const int *joints, double *accs) override
Get reference acceleration for a joint.
yarp::dev::ReturnValue getPidErrorLimits(const PidControlTypeEnum &pidtype, double *limits) override
Get the error limit for all controllers.
yarp::dev::ReturnValue setRefDutyCycles(const double *v) override
Sets the reference dutycycle for all the motors.
yarp::dev::ReturnValue stop() override
Stop motion, multiple joints.
yarp::dev::ReturnValue getRemoteVariablesList(yarp::os::Bottle *listOfKeys) override
yarp::dev::ReturnValue getPidError(const PidControlTypeEnum &pidtype, int j, double *err) override
Get the current error for a joint.
yarp::dev::ReturnValue getAmpStatus(int *st) override
yarp::dev::ReturnValue setPidErrorLimit(const PidControlTypeEnum &pidtype, int j, double limit) override
Set the error limit for the controller on a specific joint.
yarp::dev::ReturnValue parkWholePart() override
parkWholePart: start the parking procedure for the whole part
yarp::dev::ReturnValue setTrajAccelerations(const int n_joint, const int *joints, const double *accs) override
Set reference acceleration on all joints.
yarp::dev::ReturnValue getEncoderAccelerations(double *accs) override
Read the instantaneous acceleration of all axes.
yarp::dev::ReturnValue getCurrent(int j, double *val) override
yarp::dev::ReturnValue setGearboxRatio(int m, const double val) override
Set the gearbox ratio for a specific motor.
yarp::dev::ReturnValue getRefTorques(double *t) override
Get the reference value of the torque for all joints.
yarp::dev::ReturnValue setTrajAcceleration(int j, double acc) override
Set reference acceleration for a joint.
yarp::dev::ReturnValue setPidFeedforward(const PidControlTypeEnum &pidtype, int j, double v) override
Set the feedforward value for the specified PID controller.
bool close() override
Close the device driver and stop the port connections.
yarp::dev::ReturnValue resetMotorEncoders() override
Reset motor encoders.
yarp::dev::ReturnValue getTorqueRanges(double *min, double *max) override
Get the full scale of the torque sensors of all joints.
yarp::dev::ReturnValue setPidErrorLimits(const PidControlTypeEnum &pidtype, const double *limits) override
Get the error limit for the controller on all joints.
yarp::dev::ReturnValue getMotorEncoderCountsPerRevolution(int m, double *cpr) override
Gets number of counts per revolution for motor encoder m.
yarp::dev::ReturnValue calibrationDone(int j) override
Check if the calibration is terminated, on a particular joint.
yarp::dev::ReturnValue getRefPositions(double *refs) override
Get the last position reference for all axes.
yarp::dev::ReturnValue checkMotionDone(int j, bool &flag) override
Check if the current trajectory is terminated.
DiagnosticThread * diagnosticThread
yarp::dev::ReturnValue setPidReferences(const PidControlTypeEnum &pidtype, const double *refs) override
Set the controller reference, multiple axes.
yarp::dev::ReturnValue getMotorEncoder(int j, double *v) override
Read the value of a motor encoder.
yarp::dev::ReturnValue setPids(const PidControlTypeEnum &pidtype, const Pid *pids) override
Set new PID value on multiple axes.
yarp::dev::JointStateData last_wholePart
yarp::dev::ReturnValue resetEncoders() override
Reset encoders.
yarp::dev::ReturnValue getControlMode(int j, yarp::dev::ControlModeEnum &mode) override
Get the current control mode.
yarp::dev::ReturnValue getTorqueRange(int j, double *min, double *max) override
Get the full scale of the torque sensor of a given joint.
yarp::dev::ReturnValue getAvailablePids(int j, std::vector< yarp::dev::PidControlTypeEnum > &avail) override
Return a list of available pid types mode for the given joint.
yarp::dev::ReturnValue getImpedanceOffset(int j, double *offset) override
Get current force Offset for a specific joint.
yarp::dev::ReturnValue getTemperatures(double *vals) override
Get temperature of all the motors.
yarp::dev::ReturnValue getTargetPosition(const int joint, double *ref) override
Get the last position reference for the specified axis.
yarp::dev::ReturnValue disablePid(const PidControlTypeEnum &pidtype, int j) override
Disable the PID computation for a joint.
yarp::dev::ReturnValue getTorques(double *t) override
Get the value of the torque for all joints (this is the feedback if you have torque sensors).
yarp::dev::ReturnValue setAutoBrakeEnabled(int j, bool enabled) override
Enables/Disables the automatic joint brake.
yarp::dev::ReturnValue getMotorEncoderSpeeds(double *spds) override
Read the instantaneous speed of all motor encoders.
yarp::dev::ReturnValue getPidFeedforward(const PidControlTypeEnum &pidtype, int j, double &v) override
Get the currently set feedforward value for the specified PID controller.
yarp::dev::ReturnValue isCalibratorDevicePresent(bool *isCalib) override
isCalibratorDevicePresent: check if a calibrator device has been set
yarp::dev::ReturnValue setPositions(const int n_joint, const int *joints, const double *refs) override
Set new reference point for all axes.
yarp::dev::ReturnValue getRefCurrent(int j, double *t) override
Get the reference value of the current for a single motor.
yarp::dev::ReturnValue getInteractionMode(int axis, yarp::dev::InteractionModeEnum &mode) override
Get the current interaction mode of the robot, values can be stiff or compliant.
yarp::dev::ReturnValue enableAmp(int j) override
Enable the amplifier on a specific joint.
yarp::dev::ReturnValue getGearboxRatio(int m, double *val) override
Get the gearbox ratio for a specific motor.
yarp::dev::ReturnValue getMotorEncoderAcceleration(int j, double *acc) override
Read the instantaneous acceleration of a motor encoder.
yarp::dev::ReturnValue getCurrentRange(int j, double *min, double *max) override
Get the full scale of the current measurement for a given motor (e.g.
yarp::dev::ReturnValue getRefPosition(const int joint, double *ref) override
Get the last position reference for the specified axis.
yarp::dev::ReturnValue getPidReference(const PidControlTypeEnum &pidtype, int j, double *ref) override
Get the current reference of the PID controller for a specific joint.
yarp::os::BufferedPort< yarp::dev::CommandMessageData > command_p
yarp::dev::ReturnValue setInteractionModes(const std::vector< int > &joints, const std::vector< yarp::dev::InteractionModeEnum > &modes) override
Set the interaction mode of the robot for a set of joints, values can be stiff or compliant.
yarp::dev::ReturnValue getControlModes(const std::vector< int > &joints, std::vector< yarp::dev::ControlModeEnum > &modes) override
Get the current control mode for a subset of axes.
yarp::dev::ReturnValue getAxes(size_t &ax) override
Get the number of controlled axes.
yarp::dev::ReturnValue setInteractionMode(int axis, yarp::dev::InteractionModeEnum mode) override
Set the interaction mode of the robot, values can be stiff or compliant.
yarp::dev::ReturnValue getDutyCycles(double *outs) override
Gets the current dutycycle of the output of the amplifier (i.e.
yarp::dev::ReturnValue getAvailableControlModes(int j, std::vector< yarp::dev::SelectableControlModeEnum > &avail) override
Return a list of available control mode for the given joint.
yarp::dev::ReturnValue getPids(const PidControlTypeEnum &pidtype, Pid *pids) override
Get current PID value for a specific joint.
yarp::dev::ReturnValue getEncoderAcceleration(int j, double *acc) override
Read the instantaneous acceleration of an axis.
yarp::dev::ReturnValue abortPark() override
yarp::dev::ReturnValue quitCalibrate() override
quitCalibrate: interrupt the calibration procedure
yarp::dev::ReturnValue disableAmp(int j) override
Disable the amplifier on a specific joint.
yarp::dev::ReturnValue getMaxCurrent(int j, double *v) override
Returns the maximum electric current allowed for a given motor.
yarp::dev::ReturnValue getDutyCycle(int j, double *out) override
Gets the current dutycycle of the output of the amplifier (i.e.
yarp::dev::ReturnValue homingWholePart() override
homingWholePart: call the homing procedure for a the whole part/device
yarp::dev::ReturnValue getRefCurrents(double *t) override
Get the reference value of the currents for all motors.
yarp::dev::ReturnValue setMaxCurrent(int j, double v) override
yarp::dev::ReturnValue positionMove(int j, double ref) override
Set new reference point for a single axis.
yarp::dev::ReturnValue setMotorEncoderCountsPerRevolution(int m, const double cpr) override
Sets number of counts per revolution for motor encoder m.
yarp::dev::ReturnValue setRefTorques(const double *t) override
Set the reference value of the torque for all joints.
yarp::dev::ReturnValue getEncoderSpeed(int j, double *sp) override
Read the istantaneous speed of an axis.
std::map< std::string, bool > m_device_has_interfaces
yarp::dev::ReturnValue getRemoteVariable(std::string key, yarp::os::Bottle &val) override
yarp::dev::ReturnValue getAutoBrakeEnabled(int j, bool &enabled) const override
checks if the automatic joint brake mode is enabled or disabled.
yarp::dev::ReturnValue setMotorTorqueParams(int j, const MotorTorqueParameters params) override
Set a subset of motor parameters (bemf, ktau etc) useful for torque control.
yarp::dev::ReturnValue setPeakCurrent(int m, const double val) override
yarp::dev::ReturnValue setPosLimits(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...
yarp::dev::ReturnValue getPWM(int m, double *val) override
yarp::dev::ReturnValue setRefDutyCycle(int j, double v) override
Sets the reference dutycycle to a single motor.
yarp::dev::ReturnValue getPidExtraInfo(const PidControlTypeEnum &pidtype, int j, PidExtraInfo &info) override
Get PID extra info and measurement units for a specific joint.
yarp::dev::ReturnValue getTemperatureLimit(int m, double *val) override
Retrieves the current temperature limit for a specific motor.
yarp::dev::ReturnValue enablePid(const PidControlTypeEnum &pidtype, int j) override
Enable the PID computation for a joint.
yarp::dev::ReturnValue setTrajSpeeds(const int n_joint, const int *joints, const double *spds) override
Set reference speed on all joints.
yarp::dev::ReturnValue velocityMove(int j, double v) override
Start motion at a given speed, single joint.
yarp::dev::ReturnValue getNumberOfMotors(int *num) override
Get the number of available motors.
yarp::dev::ReturnValue getCurrents(double *vals) override
yarp::dev::ReturnValue getPWMLimit(int m, double *val) override
yarp::dev::ReturnValue getEncoders(double *encs) override
Read the position of all axes.
yarp::dev::ReturnValue getEncoderSpeeds(double *spds) override
Read the instantaneous speed of all axes.
yarp::dev::ReturnValue getTrajSpeed(int j, double *ref) override
Get reference speed for a joint.
yarp::dev::ReturnValue getMotorTorqueParams(int j, MotorTorqueParameters *params) override
Get a subset of motor parameters (bemf, ktau etc) useful for torque control.
yarp::dev::ReturnValue getMotorEncoderTimed(int j, double *v, double *t) override
Read the instantaneous position of a motor encoder.
yarp::dev::ReturnValue getJointType(int j, yarp::dev::JointTypeEnum &type) override
yarp::dev::ReturnValue getRefDutyCycles(double *refs) override
Gets the last reference sent using the setRefDutyCycles function.
yarp::dev::ReturnValue getLastJointFault(int j, int &fault, std::string &message) override
yarp::dev::ReturnValue getPidErrorLimit(const PidControlTypeEnum &pidtype, int j, double *limit) override
Get the error limit for the controller on a specific joint.
yarp::dev::ReturnValue getTrajSpeeds(const int n_joint, const int *joints, double *spds) override
Get reference speed of all joints.
yarp::dev::ReturnValue getMotorEncoderAccelerations(double *accs) override
Read the instantaneous acceleration of all motor encoders.
yarp::dev::ReturnValue calibrateSingleJoint(int j) override
calibrateSingleJoint: call the calibration procedure for the single joint
yarp::dev::ReturnValue getPidOffset(const PidControlTypeEnum &pidtype, int j, double &v) override
Get the currently set offset value for the specified PID controller.
yarp::dev::ReturnValue setControlModes(const std::vector< int > &joints, const std::vector< yarp::dev::SelectableControlModeEnum > &modes) override
Set the current control mode for a subset of axes.
yarp::dev::ReturnValue getImpedance(int j, double *stiffness, double *damping) override
Get current impedance gains (stiffness,damping,offset) for a specific joint.
yarp::dev::ReturnValue setRefTorque(int j, double v) override
Set the reference value of the torque for a given joint.
yarp::dev::ReturnValue parkSingleJoint(int j, bool _wait=true) override
parkSingleJoint(): start the parking procedure for the single joint
yarp::dev::ReturnValue setPWMLimit(int m, const double val) override
bool open(Searchable &config) override
Open the DeviceDriver.
yarp::dev::ReturnValue getPidExtraInfos(const PidControlTypeEnum &pidtype, std::vector< PidExtraInfo > &info) override
Get PID extra info and measurement units for a specific joint.
yarp::dev::ReturnValue getPid(const PidControlTypeEnum &pidtype, int j, Pid *pid) override
Get current PID value for a specific joint.
yarp::dev::ReturnValue setNominalCurrent(int m, const double val) override
yarp::dev::ReturnValue getRefTorque(int j, double *t) override
Get the reference value of the torque for a given joint.
yarp::dev::ReturnValue setManualBrakeActive(int j, bool active) override
Enables/Disables manually the joint brake.
yarp::dev::ReturnValue getNumberOfMotorEncoders(int *num) override
Get the number of available motor encoders.
yarp::dev::ReturnValue abortCalibration() override
yarp::dev::ReturnValue homingSingleJoint(int j) override
homingSingleJoint: call the homing procedure for a single joint
yarp::dev::ReturnValue park(bool wait=true) override
yarp::dev::ReturnValue getAxisName(int j, std::string &name) override
yarp::dev::ReturnValue setPidReference(const PidControlTypeEnum &pidtype, int j, double ref) override
Set the controller reference for a given axis.
yarp::dev::ReturnValue resetEncoder(int j) override
Reset encoder, single joint.
yarp::dev::ReturnValue setControlMode(int j, yarp::dev::SelectableControlModeEnum mode) override
Set the current control mode.
yarp::dev::ReturnValue setPidOffset(const PidControlTypeEnum &pidtype, int j, double v) override
Set an offset value for a given controller.
yarp::dev::ReturnValue getPosLimits(int axis, double *min, double *max) override
Get the software limits for a particular axis.
yarp::dev::ReturnValue 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...
yarp::dev::ReturnValue resetMotorEncoder(int j) override
Reset motor encoder, single motor.
yarp::dev::ReturnValue getMotorEncoderSpeed(int j, double *sp) override
Read the instantaneous speed of a motor encoder.
yarp::dev::ReturnValue isPidEnabled(const PidControlTypeEnum &pidtype, int j, bool &enabled) override
Get the current status (enabled/disabled) of the PID.
yarp::dev::ReturnValue getCurrentRanges(double *min, double *max) override
Get the full scale of the current measurements for all motors motor (e.g.
yarp::dev::ReturnValue isJointBraked(int j, bool &braked) const override
Check is the joint brake is currently active.
yarp::dev::ReturnValue getTargetVelocity(const int joint, double *vel) override
Get the last reference speed set by velocityMove for single joint.
yarp::dev::ReturnValue setRefCurrents(const double *refs) override
Set the reference value of the currents for all motors.
yarp::dev::ReturnValue getMotorEncoders(double *encs) override
Read the position of all motor encoders.
yarp::dev::ReturnValue getRefDutyCycle(int j, double *ref) override
Gets the last reference sent using the setRefDutyCycle function.
yarp::dev::ReturnValue getInteractionModes(const std::vector< int > &joints, std::vector< yarp::dev::InteractionModeEnum > &modes) override
Get the current interaction mode of the robot for a set of joints, values can be stiff or compliant.
yarp::dev::ReturnValue setTrajSpeed(int j, double sp) override
Set reference speed for a joint, this is the speed used during the interpolation of the trajectory.
yarp::dev::ReturnValue getEncodersTimed(double *encs, double *ts) override
Read the instantaneous acceleration of all axes.
yarp::dev::ReturnValue setMotorEncoders(const double *vals) override
Set the value of all motor encoders.
yarp::dev::ReturnValue setEncoders(const double *vals) override
Set the value of all encoders.
yarp::dev::ReturnValue getVelLimits(int axis, double *min, double *max) override
Get the software speed limits for a particular axis.
yarp::dev::ReturnValue getTargetVelocities(double *vels) override
Get the last reference speed set by velocityMove for all joints.
yarp::dev::ReturnValue setRefVelocity(int jnt, double vel) override
Set the velocity of single joint.
yarp::dev::ReturnValue getPidOutputs(const PidControlTypeEnum &pidtype, double *outs) override
Get the output of the controllers (e.g.
yarp::dev::ReturnValue getRefVelocity(const int jnt, double &vel) override
Get the last reference velocity set by setRefVelocity() for a single joint.
yarp::dev::ReturnValue calibrateAxisWithParams(int j, unsigned int ui, double v1, double v2, double v3) override
Start calibration, this method is very often platform specific.
yarp::dev::ReturnValue quitPark() override
quitPark: interrupt the park procedure
yarp::dev::ReturnValue calibrateRobot() override
Calibrate robot by using an external calibrator.
yarp::dev::ReturnValue setRefCurrent(int j, double ref) override
Set the reference value of the current for a single motor.
yarp::dev::ReturnValue getEncoder(int j, double *v) override
Read the value of an encoder.
yarp::dev::ReturnValue getPeakCurrent(int m, double *val) override
yarp::dev::ReturnValue getTargetPositions(double *refs) override
Get the last position reference for all axes.
yarp::dev::JointStateData last_singleJoint
yarp::dev::ReturnValue getTrajAcceleration(int j, double *acc) override
Get reference acceleration for a joint.
yarp::dev::ReturnValue relativeMove(int j, double delta) override
Set relative position.
yarp::dev::ReturnValue 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 ...
yarp::dev::ReturnValue setMotorEncoder(int j, const double val) override
Set the value of the motor encoder for a given motor.
yarp::dev::ReturnValue getEncoderTimed(int j, double *v, double *t) override
Read the instantaneous acceleration of all axes.
yarp::dev::ReturnValue getCurrentImpedanceLimit(int j, double *min_stiff, double *max_stiff, double *min_damp, double *max_damp) override
Get the current impedance limits for a specific joint.
yarp::dev::ReturnValue setEncoder(int j, double val) override
Set the value of the encoder for a given joint.
Stamp getLastInputStamp() override
Get the time stamp for the last read data.
yarp::dev::ReturnValue getPowerSupplyVoltage(int m, double *val) override
yarp::dev::ReturnValue getPidOutput(const PidControlTypeEnum &pidtype, int j, double *out) override
Get the output of the controller (e.g.
yarp::dev::ReturnValue 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).
yarp::dev::ReturnValue setRemoteVariable(std::string key, const yarp::os::Bottle &val) override
yarp::dev::ReturnValue setPosition(int j, double ref) override
Set new position for a single axis.
yarp::dev::ReturnValue getPidErrors(const PidControlTypeEnum &pidtype, double *errs) override
Get the error of all joints.
yarp::dev::ReturnValue setTemperatureLimit(int m, const double val) override
Set the temperature limit for a specific motor.
yarp::dev::ReturnValue getTemperature(int m, double *val) override
Get temperature of a motor.
yarp::dev::ReturnValue getMotorEncodersTimed(double *encs, double *ts) override
Read the instantaneous position of all motor encoders.
yarp::dev::ReturnValue getNominalCurrent(int m, double *val) override
yarp::dev::ReturnValue getPidReferences(const PidControlTypeEnum &pidtype, double *refs) override
Get the current reference of all PID controllers.
void run() override
Loop function.
void setOwner(StateExtendedInputPort *o)
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)
yarp::sig::VectorOf< float > pwmDutycycle
yarp::sig::VectorOf< int > controlMode
yarp::sig::VectorOf< int > interactionMode
yarp::sig::VectorOf< double > motorAcceleration
yarp::sig::VectorOf< double > jointPosition
yarp::sig::VectorOf< double > torque
yarp::sig::VectorOf< double > motorVelocity
yarp::sig::VectorOf< double > jointVelocity
yarp::sig::VectorOf< double > current
yarp::sig::VectorOf< double > jointAcceleration
yarp::sig::VectorOf< double > motorPosition
Contains the parameters for a PID.
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:64
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
Definition Bottle.cpp:247
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.
bool addOutput(const std::string &name) override
Add an output connection to the specified 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.
T & prepare()
Access the object which will be transmitted by the next call to yarp::os::BufferedPort::write.
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:1189
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 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
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:18
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 32 bit vocabulary identifier as an integer.
Definition Value.cpp:228
virtual std::int32_t asInt32() const
Get 32-bit integer value.
Definition Value.cpp:204
yarp::os::WireLink & yarp()
Get YARP state associated with this object.
Definition Wire.h:28
#define yCInfo(component,...)
#define yCError(component,...)
#define yCDebug(component,...)
std::int32_t vocab32_t
Definition numeric.h:78
For streams capable of holding different kinds of content, check what they actually have.
SelectableControlModeEnum
PidControlTypeEnum
Definition PidEnums.h:15
An interface to the operating system, including Port based communication.