YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
Robot.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
7
11
12#include <yarp/os/LogStream.h>
13
14#include <yarp/dev/PolyDriver.h>
16
18
19#include <algorithm>
20#include <iostream>
21#include <string>
22#include <unordered_set>
23
25
26namespace {
27YARP_LOG_COMPONENT(YRI_ROBOT, "yarp.yri.Robot")
28}
29
31{
32 dbg << "(name = \"" << t.name() << "\"";
33 if (!t.params().empty()) {
34 dbg << ", params = [";
35 dbg << t.params();
36 dbg << "]";
37 }
38 if (!t.devices().empty()) {
39 dbg << ", devices = [";
40 dbg << t.devices();
41 dbg << "]";
42 }
43 dbg << ")";
44 return dbg;
45}
46
47
49{
50public:
51 Private(Robot* /*parent*/)
52 {
53 }
54
55 // return true if a device with the given name exists
56 bool hasDevice(const std::string& name) const;
57
58 // return the device with the given name or <fatal error> if not found
59 Device* findDevice(const std::string& name);
60
61 // return true if a device with the given name exists
62 // considering also the provided external devices
63 bool hasDeviceIncludingExternal(const std::string& name) const;
64
65 // return the device with the given name or nullptr if not found,
66 // considering also the provided external devices
68
69 // check if there is no external devices that has the same name of an internal device
70 // return true if there is a conflict, false otherwise
72
73 // open all the devices and return true if all the open calls were successful
74 bool openDevices();
75
76 // close all the devices and return true if all the close calls were successful
77 bool closeDevices();
78
79 // return a vector of levels that have actions in the requested phase
80 std::vector<unsigned int> getLevels(ActionPhase phase) const;
81
82 // return a vector of actions for that phase and that level
83 std::vector<std::pair<Device, Action>> getActions(ActionPhase phase, unsigned int level) const;
84
85
86 // run configure action on one device
87 bool configure(const Device& device, const ParamList& params);
88
89 // run calibrate action on one device
90 bool calibrate(const Device& device, const ParamList& params);
91
92 // run attach action on one device
93 bool attach(const Device& device, const ParamList& params);
94
95 // run abort action on one device
96 bool abort(const Device& device, const ParamList& params);
97
98 // run detach action on one device
99 bool detach(const Device& device, const ParamList& params);
100
101 // run park action on one device
102 bool park(const Device& device, const ParamList& params);
103
104 // run custom action on one device
105 bool custom(const Device& device, const ParamList& params);
106
107 std::string name;
108 unsigned int build {0};
109 std::string portprefix;
114 unsigned int currentLevel {0};
115 bool dryrun {false};
118 std::string yriDescriptionStorageName = "yriDescriptionStorage";
120
121}; // class yarp::robotinterface::Robot::Private
122
123bool yarp::robotinterface::Robot::Private::hasDevice(const std::string& name) const
124{
125 for (const auto& device : devices) {
126 if (name == device.name()) {
127 return true;
128 }
129 }
130 return false;
131}
132
134{
135 for (auto& device : devices) {
136 if (name == device.name()) {
137 return &device;
138 }
139 }
140 return nullptr;
141}
142
144{
145 if (hasDevice(name)) {
146 return true;
147 } else {
148 for (int i = 0; i < externalDevices.size(); i++) {
149 const yarp::dev::PolyDriverDescriptor* externalDevice = externalDevices[i];
150 if (name == externalDevice->key) {
151 return true;
152 }
153 }
154 }
155 return false;
156}
157
160{
162 deviceFound.poly = nullptr;
163 deviceFound.key = "";
164
165 for (auto& device : devices) {
166 if (name == device.name()) {
167 deviceFound.poly = device.driver();
168 deviceFound.key = device.name();
169 return deviceFound;
170 }
171 }
172
173 for (int i = 0; i < externalDevices.size(); i++) {
174 const yarp::dev::PolyDriverDescriptor* externalDevice = externalDevices[i];
175 if (name == externalDevice->key) {
176 deviceFound = *externalDevice;
177 }
178 }
179
180 return deviceFound;
181}
182
184{
185 std::unordered_set<std::string> externalDevicesNames;
186
187 for (int i = 0; i < externalDevicesList.size(); i++) {
188 const yarp::dev::PolyDriverDescriptor* externalDevice = externalDevicesList[i];
189 externalDevicesNames.insert(externalDevice->key);
190 }
191
192 for (auto& device : devices) {
193 if (externalDevicesNames.find(device.name()) != externalDevicesNames.end()) {
194 yCError(YRI_ROBOT) << "Device name " << device.name() << " is used for both an internal and external device.";
195 return true;
196 }
197 }
198
199 return false;
200}
201
202
204{
206 pcfg.put("device", "robotDescriptionStorage");
207 pcfg.put("name", "yriDescriptionStorage");
208 m_ddstorage.open(pcfg);
209 m_ddstorage.view(m_istorage);
210
211 bool ret = true;
212 for (auto& device : devices) {
213 yCInfo(YRI_ROBOT) << "Opening device" << device.name() << "with parameters" << device.params();
214
215 if (dryrun) {
216 continue;
217 }
218
219 if (!device.open()) {
220 yCWarning(YRI_ROBOT) << "Cannot open device" << device.name();
221 ret = false;
222 }
223 else
224 {
225 if (m_istorage)
226 {
227 std::vector<std::string> stp;
228 std::string scfg;
230 yarp::dev::IDeviceDriverParams* dparams = nullptr;
231 if (pddrv)
232 {
233 pddrv->view(dparams);
234 if (dparams)
235 {
236 stp = dparams->getListOfParams();
237 scfg = dparams->getConfiguration();
238 }
239 else
240 {
241 yCError(YRI_ROBOT) << "Device" << device.name() << "does not derive from IDeviceDriverParams.";
242 }
243 }
244 if (!pddrv || scfg.empty())
245 {
246 yCError(YRI_ROBOT) << "Unable to get device" << device.name() << "configuration";
247 }
249 devdesc.device_name = device.name();
250 devdesc.device_type = device.type();
251 devdesc.device_configuration = scfg;
252 yarp::dev::ReturnValue ret = m_istorage->registerDevice(devdesc);
253 if (!ret)
254 {
255 yCError(YRI_ROBOT) << "Unable to register device" << device.name() << "in robotDescriptionStorage";
256 }
257 }
258 }
259 }
260 if (ret)
261 {
262 if (m_istorage)
263 {
264 std::vector<yarp::dev::DeviceDescription> ll;
265 m_istorage->getAllDevices(ll);
266 std::ostringstream oss;
267 for (auto& it_device : ll)
268 {
269 oss << "- name:" << it_device.device_name << ", type:" << it_device.device_type << "\n";
270 }
271 yCInfo(YRI_ROBOT) << "List of opened devices:\n"
272 << oss.str() << "End of list";
273 ;
274 }
275 }
276 else
277 {
278 yCWarning(YRI_ROBOT) << "There was some problem opening one or more devices. Please check the log and your configuration";
279 }
280
281 return ret;
282}
283
285{
286 bool ret = true;
287 for (auto it = devices.rbegin(); it != devices.rend(); ++it) {
289
290 yCInfo(YRI_ROBOT) << "Closing device" << device.name();
291
292 if (dryrun) {
293 continue;
294 }
295
296 // yCDebug(YRI_ROBOT) << device;
297
298 if (!device.close()) {
299 yCWarning(YRI_ROBOT) << "Cannot close device" << device.name();
300 ret = false;
301 }
302 }
303 if (ret) {
304 yCInfo(YRI_ROBOT) << "All devices closed.";
305 } else {
306 yCWarning(YRI_ROBOT) << "There was some problem closing one or more devices. Please check the log and your configuration";
307 }
308
309 if (m_ddstorage.isValid())
310 {
311 m_ddstorage.close();
312 }
313
314 return ret;
315}
316
318{
319 std::vector<unsigned int> levels;
320 for (const auto& device : devices) {
321 if (device.actions().empty()) {
322 continue;
323 }
324
325 for (const auto& action : device.actions()) {
326 if (action.phase() == phase) {
327 levels.push_back(action.level());
328 }
329 }
330 }
331
332 std::sort(levels.begin(), levels.end());
333 auto it = std::unique(levels.begin(), levels.end());
334 levels.resize(it - levels.begin());
335
336 return levels;
337}
338
339
340std::vector<std::pair<yarp::robotinterface::Device, yarp::robotinterface::Action>> yarp::robotinterface::Robot::Private::getActions(yarp::robotinterface::ActionPhase phase, unsigned int level) const
341{
342 std::vector<std::pair<yarp::robotinterface::Device, yarp::robotinterface::Action>> actions;
343 for (const auto& device : devices) {
344 if (device.actions().empty()) {
345 continue;
346 }
347
348 for (const auto& action : device.actions()) {
349 if (action.phase() == phase && action.level() == level) {
350 actions.emplace_back(device, action);
351 }
352 }
353 }
354 return actions;
355}
356
357
363
366{
367 if (!yarp::robotinterface::hasParam(params, "target")) {
368 yCError(YRI_ROBOT) << "Action \"" << ActionTypeToString(ActionTypeCalibrate) << R"(" requires "target" parameter)";
369 return false;
370 }
371 std::string targetDeviceName = yarp::robotinterface::findParam(params, "target");
372
373 if (!hasDeviceIncludingExternal(targetDeviceName)) {
374 yCError(YRI_ROBOT) << "Target device" << targetDeviceName << "does not exist.";
375 return false;
376 }
377
378 if (dryrun) {
379 return true;
380 }
381
382 yarp::dev::PolyDriverDescriptor targetDevice = findDeviceIncludingExternal(targetDeviceName);
383
384 return device.calibrate(targetDevice);
385}
386
389{
390 if (device.type() == "robotDescription_nws_yarp")
391 {
392 std::string storageName = yarp::robotinterface::findParam(params, "device");
394 drv_list.push(&m_ddstorage, yriDescriptionStorageName.c_str());
395 bool b= device.attach(drv_list);
396 if (!b)
397 {
398 yCError(YRI_ROBOT) << "cannot attach robotDescription_nws_yarp to yriDescriptionStorage";
399 }
400 return true;
401 }
402
403 int check = 0;
404 if (yarp::robotinterface::hasParam(params, "network")) {
405 check++;
406 }
407 if (yarp::robotinterface::hasParam(params, "networks")) {
408 check++;
409 }
411 check++;
412 }
413
414 if (check > 1) {
415 yCError(YRI_ROBOT) << "Action \"" << ActionTypeToString(ActionTypeAttach) << R"(" : you can have only one option: "network" , "networks" or "all" )";
416 return false;
417 }
418
420
421 if (yarp::robotinterface::hasParam(params, "device")) {
422 std::string targetDeviceName = yarp::robotinterface::findParam(params, "device");
423
424 std::string targetNetwork = "...";
425 if (yarp::robotinterface::hasParam(params, "network")) {
426 targetNetwork = yarp::robotinterface::findParam(params, "network");
427 }
428
429 if (!hasDeviceIncludingExternal(targetDeviceName)) {
430 yCError(YRI_ROBOT) << "Target device" << targetDeviceName << "(network =" << targetNetwork << ") does not exist.";
431 return false;
432 }
433
434 if (!dryrun) {
435 yarp::dev::PolyDriverDescriptor targetDevice = findDeviceIncludingExternal(targetDeviceName);
436
437 // yCDebug() << "Attach device" << device.name() << "to" << targetDevice.name() << "as" << targetNetwork;
438 drivers.push(targetDevice.poly, targetNetwork.c_str());
439 }
440
441 } else if (yarp::robotinterface::hasParam(params, "all")) {
442 if (!dryrun) {
443 for (auto& device : devices) {
444 drivers.push(device.driver(), "all");
445 }
446
447 for (int i = 0; i < externalDevices.size(); i++) {
448 const yarp::dev::PolyDriverDescriptor* externalDevice = externalDevices[i];
449 drivers.push(externalDevice->poly, "all");
450 }
451 }
452 } else if (yarp::robotinterface::hasParam(params, "networks")) {
454 v.fromString(yarp::robotinterface::findParam(params, "networks").c_str());
455 yarp::os::Bottle& targetNetworks = *(v.asList());
456
457 for (size_t i = 0; i < targetNetworks.size(); ++i) {
458 std::string targetNetwork = targetNetworks.get(i).toString();
459
460 if (!yarp::robotinterface::hasParam(params, targetNetwork)) {
461 yCError(YRI_ROBOT) << "Action \"" << ActionTypeToString(ActionTypeAttach) << "\" requires one parameter per network. \"" << targetNetwork << "\" parameter is missing.";
462 return false;
463 }
464 std::string targetDeviceName = yarp::robotinterface::findParam(params, targetNetwork);
465 if (!hasDeviceIncludingExternal(targetDeviceName)) {
466 yCError(YRI_ROBOT) << "Target device" << targetDeviceName << "(network =" << targetNetwork << ") does not exist.";
467 return false;
468 }
469
470 if (!dryrun) {
471 yarp::dev::PolyDriverDescriptor targetDevice = findDeviceIncludingExternal(targetDeviceName);
472
473 // yCDebug() << "Attach device" << device.name() << "to" << targetDevice.name() << "as" << targetNetwork;
474 drivers.push(targetDevice.poly, targetNetwork.c_str());
475 }
476 }
477 } else {
478 yCError(YRI_ROBOT) << "Action \"" << ActionTypeToString(ActionTypeAttach) << R"(" requires either "network" or "networks" parameter)";
479 return false;
480 }
481
482 if (dryrun) {
483 return true;
484 }
485
486 if (!drivers.size()) {
487 yCError(YRI_ROBOT) << "Action \"" << ActionTypeToString(ActionTypeAttach) << "\" couldn't find any device.";
488 return false;
489 }
490
491 return device.attach(drivers);
492}
493
499
500
502{
503 if (!params.empty()) {
504 yCWarning(YRI_ROBOT) << "Action \"" << ActionTypeToString(ActionTypeDetach) << "\" cannot have any parameter. Ignoring them.";
505 }
506
507 if (dryrun) {
508 return true;
509 }
510
511 return device.detach();
512}
513
516{
517 if (!yarp::robotinterface::hasParam(params, "target")) {
518 yCError(YRI_ROBOT) << "Action \"" << ActionTypeToString(ActionTypePark) << R"(" requires "target" parameter)";
519 return false;
520 }
521 std::string targetDeviceName = yarp::robotinterface::findParam(params, "target");
522
523 if (!hasDeviceIncludingExternal(targetDeviceName)) {
524 yCError(YRI_ROBOT) << "Target device" << targetDeviceName << "does not exist.";
525 return false;
526 }
527
528 if (dryrun) {
529 return true;
530 }
531
532 yarp::dev::PolyDriverDescriptor targetDevice = findDeviceIncludingExternal(targetDeviceName);
533
534 return device.park(targetDevice);
535}
536
542
544 mPriv(new Private(this))
545{
546}
547
549 mPriv(new Private(this))
550{
551 mPriv->name = name;
552 mPriv->devices = devices;
553}
554
556 mPriv(new Private(this))
557{
558 mPriv->name = other.mPriv->name;
559 mPriv->build = other.mPriv->build;
560 mPriv->portprefix = other.mPriv->portprefix;
561 mPriv->currentPhase = other.mPriv->currentPhase;
562 mPriv->currentLevel = other.mPriv->currentLevel;
563 mPriv->dryrun = other.mPriv->dryrun;
565 mPriv->devices = other.mPriv->devices;
566 mPriv->params = other.mPriv->params;
567}
568
570{
571 if (&other != this) {
572 mPriv->name = other.mPriv->name;
573 mPriv->build = other.mPriv->build;
574 mPriv->portprefix = other.mPriv->portprefix;
575 mPriv->currentPhase = other.mPriv->currentPhase;
576 mPriv->currentLevel = other.mPriv->currentLevel;
577 mPriv->dryrun = other.mPriv->dryrun;
578 mPriv->reverseShutdownActionOrder = other.mPriv->reverseShutdownActionOrder;
579
580 mPriv->devices.clear();
581 mPriv->devices = other.mPriv->devices;
582
583 mPriv->params.clear();
584 mPriv->params = other.mPriv->params;
585 }
586
587 return *this;
588}
589
591{
592 delete mPriv;
593}
594
596{
597 return mPriv->name;
598}
599
601{
602 return mPriv->build;
603}
604
606{
607 return mPriv->portprefix;
608}
609
611{
612 for (auto& device : devices()) {
613 ParamList& params = device.params();
614 // Do not override "verbose" param if explicitly set in the xml
615 if (verbose && !yarp::robotinterface::hasParam(params, "verbose")) {
616 device.params().push_back(Param("verbose", "1"));
617 }
618 }
619}
620
622{
623 for (auto& device : devices()) {
624 ParamList& params = device.params();
625 // Do not override "allow-deprecated-devices" param if explicitly set in the xml
626 if (allowDeprecatedDevices && !yarp::robotinterface::hasParam(params, "allow-deprecated-devices")) {
627 device.params().push_back(Param("allow-deprecated-devices", "1"));
628 }
629 }
630}
631
633{
634 mPriv->dryrun = dryrun;
635}
636
638{
639 mPriv->reverseShutdownActionOrder = reverseShutdownActionOrder;
640}
641
646
651
653{
654 return *mPriv->findDevice(name);
655}
656
657const std::string& yarp::robotinterface::Robot::name() const
658{
659 return mPriv->name;
660}
661
662const unsigned int& yarp::robotinterface::Robot::build() const
663{
664 return mPriv->build;
665}
666
668{
669 return mPriv->portprefix;
670}
671
673{
674 return mPriv->params;
675}
676
678{
679 return mPriv->devices;
680}
681
682bool yarp::robotinterface::Robot::hasDevice(const std::string& name) const
683{
684 return mPriv->hasDevice(name);
685}
686
688{
689 return *mPriv->findDevice(name);
690}
691
693{
694 yCInfo(YRI_ROBOT) << "Interrupt received. Stopping all running threads.";
695
696 // If we received an interrupt we send a stop signal to all threads
697 // from previous phases
698 for (auto& device : devices()) {
699 device.stopThreads();
700 }
701}
702
704{
705 bool nameConflict = mPriv->checkForNamingConflictsInExternalDevices(list);
706 if (nameConflict) {
707 return false;
708 }
709
710 mPriv->externalDevices = list;
711 return true;
712}
713
715{
716 yCInfo(YRI_ROBOT) << ActionPhaseToString(phase) << "phase starting...";
717
718 mPriv->currentPhase = phase;
719 mPriv->currentLevel = 0;
720
721 // Open all devices
722 if (phase == ActionPhaseStartup) {
723 if (!mPriv->openDevices()) {
724 yCError(YRI_ROBOT) << "One or more devices failed opening... see previous log messages for more info";
725 if (!mPriv->closeDevices()) {
726 yCError(YRI_ROBOT) << "One or more devices failed closing";
727 }
728 return false;
729 }
730 }
731
732 // run phase does not accept actions
733 if (phase == ActionPhaseRun) {
734 if (mPriv->getLevels(phase).size() != 0) {
735 yCWarning(YRI_ROBOT) << "Phase" << ActionPhaseToString(phase) << "does not accept actions. Skipping all actions for this phase";
736 }
737 return true;
738 }
739
740 // Before starting any action we ensure that there are no other
741 // threads running from previous phases.
742 // In interrupt 2 and 3 and this is called by the interrupt callback,
743 // and therefore main thread will be blocked and join will never
744 // return. Therefore, since we want to start the abort actions we
745 // skip this check.
746 if (phase != ActionPhaseInterrupt2 && phase != ActionPhaseInterrupt3) {
747 for (auto& device : devices()) {
748 device.joinThreads();
749 }
750 }
751
752 std::vector<unsigned int> levels = mPriv->getLevels(phase);
753 if (mPriv->reverseShutdownActionOrder && (phase == ActionPhaseShutdown ||
754 phase == ActionPhaseInterrupt1 ||
755 phase == ActionPhaseInterrupt2 ||
756 phase == ActionPhaseInterrupt3)) {
757 std::reverse(levels.begin(), levels.end());
758 }
759
760 bool ret = true;
761 for (unsigned int level : levels) {
762 // for each level
763 yCInfo(YRI_ROBOT) << "Entering action level" << level << "of phase" << ActionPhaseToString(phase);
764 mPriv->currentLevel = level;
765
766 // If current phase was changed by some other thread, we should
767 // exit the loop and avoid starting further actions.
768 if (mPriv->currentPhase != phase) {
769 ret = false;
770 break;
771 }
772
773 std::vector<std::pair<Device, Action>> actions = mPriv->getActions(phase, level);
774
775 for (auto& ait : actions) {
776 // for each action in that level
777 Device& device = ait.first;
778 Action& action = ait.second;
779
780 // If current phase was changed by some other thread, we should
781 // exit the loop and avoid starting further actions.
782 if (mPriv->currentPhase != phase) {
783 ret = false;
784 break;
785 }
786
787 yCInfo(YRI_ROBOT) << "Executing" << ActionTypeToString(action.type()) << "action, level" << action.level() << "on device" << device.name() << "with parameters" << action.params();
788
789 switch (action.type()) {
791 if (!mPriv->configure(device, action.params())) {
792 yCError(YRI_ROBOT) << "Cannot run configure action on device" << device.name();
793 ret = false;
794 }
795 break;
797 if (!mPriv->calibrate(device, action.params())) {
798 yCError(YRI_ROBOT) << "Cannot run calibrate action on device" << device.name();
799 ret = false;
800 }
801 break;
802 case ActionTypeAttach:
803 if (!mPriv->attach(device, action.params())) {
804 yCError(YRI_ROBOT) << "Cannot run attach action on device" << device.name();
805 ret = false;
806 }
807 break;
808 case ActionTypeAbort:
809 if (!mPriv->abort(device, action.params())) {
810 yCError(YRI_ROBOT) << "Cannot run abort action on device" << device.name();
811 ret = false;
812 }
813 break;
814 case ActionTypeDetach:
815 if (!mPriv->detach(device, action.params())) {
816 yCError(YRI_ROBOT) << "Cannot run detach action on device" << device.name();
817 ret = false;
818 }
819 break;
820 case ActionTypePark:
821 if (!mPriv->park(device, action.params())) {
822 yCError(YRI_ROBOT) << "Cannot run park action on device" << device.name();
823 ret = false;
824 }
825 break;
826 case ActionTypeCustom:
827 if (!mPriv->custom(device, action.params())) {
828 yCError(YRI_ROBOT) << "Cannot run custom action on device" << device.name();
829 ret = false;
830 }
831 break;
832 default:
833 yCWarning(YRI_ROBOT) << "Unhandled action" << ActionTypeToString(action.type());
834 ret = false;
835 break;
836 }
837 }
838
839 yCInfo(YRI_ROBOT) << "All actions for action level" << level << "of" << ActionPhaseToString(phase) << "phase started. Waiting for unfinished actions.";
840
841 // Join parallel threads
842 for (auto& device : devices()) {
843 device.joinThreads();
844 // yCDebug() << "All actions for device" << device.name() << "at level()" << level << "finished";
845 }
846
847 yCInfo(YRI_ROBOT) << "All actions for action level" << level << "of" << ActionPhaseToString(phase) << "phase finished.";
848 }
849
850 if (!ret) {
851 yCWarning(YRI_ROBOT) << "There was some problem running actions for" << ActionPhaseToString(phase) << "phase . Please check the log and your configuration";
852 }
853
854 if (phase == ActionPhaseShutdown) {
855 if (!mPriv->closeDevices()) {
856 yCError(YRI_ROBOT) << "One or more devices failed closing";
857 return false;
858 }
859 }
860
861 yCInfo(YRI_ROBOT) << ActionPhaseToString(phase) << "phase finished.";
862
863 return ret;
864}
865
867{
868 return mPriv->currentPhase;
869}
870
872{
873 return mPriv->currentLevel;
874}
875
876bool yarp::robotinterface::Robot::hasParam(const std::string& name) const
877{
878 return yarp::robotinterface::hasParam(mPriv->params, name);
879}
880
881std::string yarp::robotinterface::Robot::findParam(const std::string& name) const
882{
883 return yarp::robotinterface::findParam(mPriv->params, name);
884}
bool ret
#define YARP_FIXME_NOTIMPLEMENTED(what)
Definition Log.h:411
yarp::os::LogStream operator<<(yarp::os::LogStream dbg, const yarp::robotinterface::Robot &t)
Definition Robot.cpp:30
std::string device_configuration
configuration parameters of the device
std::string device_type
type of the device
std::string device_name
name of the device
bool view(T *&x)
Get an interface to the device driver.
An interface for the management of the parameters of a DeviceDriver.
virtual std::vector< std::string > getListOfParams() const =0
Return a list of all params used by the device.
virtual std::string getConfiguration() const =0
Return the configuration of the device.
This interface allows users to retrieve a list which contains the names and the types of the currentl...
void push(PolyDriver *p, const char *k)
A container for a device driver.
Definition PolyDriver.h:23
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:64
size_type size() const
Gets the number of elements in the bottle.
Definition Bottle.cpp:251
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
Definition Bottle.cpp:246
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
A class for storing options and configuration information.
Definition Property.h:33
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
Definition Property.cpp:987
A single value (typically within a Bottle).
Definition Value.h:43
virtual Bottle * asList() const
Get list value.
Definition Value.cpp:240
std::string toString() const override
Return a standard text representation of the content of the object.
Definition Value.cpp:356
void fromString(const char *str)
Set value to correspond to a textual representation.
Definition Value.cpp:351
unsigned int & level()
Definition Action.cpp:105
bool attach(const yarp::dev::PolyDriverList &drivers) const
Definition Device.cpp:419
bool park(const yarp::dev::PolyDriverDescriptor &target) const
Definition Device.cpp:493
yarp::dev::PolyDriver * driver() const
Definition Device.cpp:339
bool calibrate(const yarp::dev::PolyDriverDescriptor &target) const
Definition Device.cpp:359
bool detach(const Device &device, const ParamList &params)
Definition Robot.cpp:501
std::vector< unsigned int > getLevels(ActionPhase phase) const
Definition Robot.cpp:317
yarp::dev::IRobotDescription * m_istorage
Definition Robot.cpp:119
Device * findDevice(const std::string &name)
Definition Robot.cpp:133
bool park(const Device &device, const ParamList &params)
Definition Robot.cpp:514
bool custom(const Device &device, const ParamList &params)
Definition Robot.cpp:537
bool hasDevice(const std::string &name) const
Definition Robot.cpp:123
bool calibrate(const Device &device, const ParamList &params)
Definition Robot.cpp:364
bool hasDeviceIncludingExternal(const std::string &name) const
Definition Robot.cpp:143
bool attach(const Device &device, const ParamList &params)
Definition Robot.cpp:387
bool checkForNamingConflictsInExternalDevices(const yarp::dev::PolyDriverList &newExternalDevicesList)
Definition Robot.cpp:183
yarp::dev::PolyDriver m_ddstorage
Definition Robot.cpp:117
yarp::robotinterface::ActionPhase currentPhase
Definition Robot.cpp:113
yarp::dev::PolyDriverDescriptor findDeviceIncludingExternal(const std::string &name)
Definition Robot.cpp:159
bool configure(const Device &device, const ParamList &params)
Definition Robot.cpp:358
std::vector< std::pair< Device, Action > > getActions(ActionPhase phase, unsigned int level) const
Definition Robot.cpp:340
yarp::dev::PolyDriverList externalDevices
Definition Robot.cpp:112
bool abort(const Device &device, const ParamList &params)
Definition Robot.cpp:494
bool hasParam(const std::string &name) const
Definition Robot.cpp:876
void setAllowDeprecatedDevices(bool allowDeprecatedDevices)
Definition Robot.cpp:621
bool hasDevice(const std::string &name) const
Definition Robot.cpp:682
yarp::robotinterface::ActionPhase currentPhase() const
Definition Robot.cpp:866
std::string & portprefix()
Definition Robot.cpp:605
DeviceList & devices()
Definition Robot.cpp:647
void setVerbose(bool verbose)
Definition Robot.cpp:610
bool enterPhase(yarp::robotinterface::ActionPhase phase)
Definition Robot.cpp:714
bool setExternalDevices(const yarp::dev::PolyDriverList &list)
Definition Robot.cpp:703
void setReverseShutdownActionOrder(bool reverseShutdownActionOrder)
Definition Robot.cpp:637
std::string & name()
Definition Robot.cpp:595
Robot & operator=(const Robot &other)
Definition Robot.cpp:569
unsigned int & build()
Definition Robot.cpp:600
std::string findParam(const std::string &name) const
Definition Robot.cpp:881
Device & device(const std::string &name)
Definition Robot.cpp:652
void setDryRun(bool dryrun)
Definition Robot.cpp:632
#define yCInfo(component,...)
#define yCError(component,...)
#define yCWarning(component,...)
#define YARP_LOG_COMPONENT(name,...)
std::string ActionTypeToString(robotinterface::ActionType actiontype)
Definition Types.cpp:151
bool hasParam(const robotinterface::ParamList &list, const std::string &name)
Definition Types.cpp:20
std::vector< robotinterface::Param > ParamList
Definition Types.h:30
std::string findParam(const robotinterface::ParamList &list, const std::string &name)
Definition Types.cpp:30
std::vector< robotinterface::Device > DeviceList
Definition Types.h:32
std::string ActionPhaseToString(robotinterface::ActionPhase actionphase)
Definition Types.cpp:103