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 yCWarning(YRI_ROBOT) << "Device" << device.name() << "does not derive from IDeviceDriverParams.";
242 }
243 }
244 if (!pddrv || scfg.empty())
245 {
246 yCWarning(YRI_ROBOT) << "Unable to get device" << device.name() << "configuration. yarprobotinterface will continue, but some features for inspecting the device parameters will be disabled.";
247 yCDebug(YRI_ROBOT) << "It is recommended that devices used by yarprobinterface implement the `yarp::dev::IDeviceDriverParams` interface.";
248 yCDebug(YRI_ROBOT) << "See yarprobotinterface documentation page.";
249 }
251 devdesc.device_name = device.name();
252 devdesc.device_type = device.type();
253 devdesc.device_configuration = scfg;
254 yarp::dev::ReturnValue ret = m_istorage->registerDevice(devdesc);
255 if (!ret)
256 {
257 yCError(YRI_ROBOT) << "Unable to register device" << device.name() << "in robotDescriptionStorage";
258 }
259 }
260 }
261 }
262 if (ret)
263 {
264 if (m_istorage)
265 {
266 std::vector<yarp::dev::DeviceDescription> ll;
267 m_istorage->getAllDevices(ll);
268 std::ostringstream oss;
269 for (auto& it_device : ll)
270 {
271 oss << "- name:" << it_device.device_name << ", type:" << it_device.device_type << "\n";
272 }
273 yCInfo(YRI_ROBOT) << "List of opened devices:\n"
274 << oss.str() << "End of list";
275 ;
276 }
277 }
278 else
279 {
280 yCWarning(YRI_ROBOT) << "There was some problem opening one or more devices. Please check the log and your configuration";
281 }
282
283 return ret;
284}
285
287{
288 bool ret = true;
289 for (auto it = devices.rbegin(); it != devices.rend(); ++it) {
291
292 yCInfo(YRI_ROBOT) << "Closing device" << device.name();
293
294 if (dryrun) {
295 continue;
296 }
297
298 // yCDebug(YRI_ROBOT) << device;
299
300 if (!device.close()) {
301 yCWarning(YRI_ROBOT) << "Cannot close device" << device.name();
302 ret = false;
303 }
304 }
305 if (ret) {
306 yCInfo(YRI_ROBOT) << "All devices closed.";
307 } else {
308 yCWarning(YRI_ROBOT) << "There was some problem closing one or more devices. Please check the log and your configuration";
309 }
310
311 if (m_ddstorage.isValid())
312 {
313 m_ddstorage.close();
314 }
315
316 return ret;
317}
318
320{
321 std::vector<unsigned int> levels;
322 for (const auto& device : devices) {
323 if (device.actions().empty()) {
324 continue;
325 }
326
327 for (const auto& action : device.actions()) {
328 if (action.phase() == phase) {
329 levels.push_back(action.level());
330 }
331 }
332 }
333
334 std::sort(levels.begin(), levels.end());
335 auto it = std::unique(levels.begin(), levels.end());
336 levels.resize(it - levels.begin());
337
338 return levels;
339}
340
341
342std::vector<std::pair<yarp::robotinterface::Device, yarp::robotinterface::Action>> yarp::robotinterface::Robot::Private::getActions(yarp::robotinterface::ActionPhase phase, unsigned int level) const
343{
344 std::vector<std::pair<yarp::robotinterface::Device, yarp::robotinterface::Action>> actions;
345 for (const auto& device : devices) {
346 if (device.actions().empty()) {
347 continue;
348 }
349
350 for (const auto& action : device.actions()) {
351 if (action.phase() == phase && action.level() == level) {
352 actions.emplace_back(device, action);
353 }
354 }
355 }
356 return actions;
357}
358
359
365
368{
369 if (!yarp::robotinterface::hasParam(params, "target")) {
370 yCError(YRI_ROBOT) << "Action \"" << ActionTypeToString(ActionTypeCalibrate) << R"(" requires "target" parameter)";
371 return false;
372 }
373 std::string targetDeviceName = yarp::robotinterface::findParam(params, "target");
374
375 if (!hasDeviceIncludingExternal(targetDeviceName)) {
376 yCError(YRI_ROBOT) << "Target device" << targetDeviceName << "does not exist.";
377 return false;
378 }
379
380 if (dryrun) {
381 return true;
382 }
383
384 yarp::dev::PolyDriverDescriptor targetDevice = findDeviceIncludingExternal(targetDeviceName);
385
386 return device.calibrate(targetDevice);
387}
388
391{
392 if (device.type() == "robotDescription_nws_yarp")
393 {
394 std::string storageName = yarp::robotinterface::findParam(params, "device");
396 drv_list.push(&m_ddstorage, yriDescriptionStorageName.c_str());
397 bool b= device.attach(drv_list);
398 if (!b)
399 {
400 yCError(YRI_ROBOT) << "cannot attach robotDescription_nws_yarp to yriDescriptionStorage";
401 }
402 return true;
403 }
404
405 int check = 0;
406 if (yarp::robotinterface::hasParam(params, "network")) {
407 check++;
408 }
409 if (yarp::robotinterface::hasParam(params, "networks")) {
410 check++;
411 }
413 check++;
414 }
415
416 if (check > 1) {
417 yCError(YRI_ROBOT) << "Action \"" << ActionTypeToString(ActionTypeAttach) << R"(" : you can have only one option: "network" , "networks" or "all" )";
418 return false;
419 }
420
422
423 if (yarp::robotinterface::hasParam(params, "device")) {
424 std::string targetDeviceName = yarp::robotinterface::findParam(params, "device");
425
426 std::string targetNetwork = "...";
427 if (yarp::robotinterface::hasParam(params, "network")) {
428 targetNetwork = yarp::robotinterface::findParam(params, "network");
429 }
430
431 if (!hasDeviceIncludingExternal(targetDeviceName)) {
432 yCError(YRI_ROBOT) << "Target device" << targetDeviceName << "(network =" << targetNetwork << ") does not exist.";
433 return false;
434 }
435
436 if (!dryrun) {
437 yarp::dev::PolyDriverDescriptor targetDevice = findDeviceIncludingExternal(targetDeviceName);
438
439 // yCDebug() << "Attach device" << device.name() << "to" << targetDevice.name() << "as" << targetNetwork;
440 drivers.push(targetDevice.poly, targetNetwork.c_str());
441 }
442
443 } else if (yarp::robotinterface::hasParam(params, "all")) {
444 if (!dryrun) {
445 for (auto& device : devices) {
446 drivers.push(device.driver(), "all");
447 }
448
449 for (int i = 0; i < externalDevices.size(); i++) {
450 const yarp::dev::PolyDriverDescriptor* externalDevice = externalDevices[i];
451 drivers.push(externalDevice->poly, "all");
452 }
453 }
454 } else if (yarp::robotinterface::hasParam(params, "networks")) {
456 v.fromString(yarp::robotinterface::findParam(params, "networks").c_str());
457 yarp::os::Bottle& targetNetworks = *(v.asList());
458
459 for (size_t i = 0; i < targetNetworks.size(); ++i) {
460 std::string targetNetwork = targetNetworks.get(i).toString();
461
462 if (!yarp::robotinterface::hasParam(params, targetNetwork)) {
463 yCError(YRI_ROBOT) << "Action \"" << ActionTypeToString(ActionTypeAttach) << "\" requires one parameter per network. \"" << targetNetwork << "\" parameter is missing.";
464 return false;
465 }
466 std::string targetDeviceName = yarp::robotinterface::findParam(params, targetNetwork);
467 if (!hasDeviceIncludingExternal(targetDeviceName)) {
468 yCError(YRI_ROBOT) << "Target device" << targetDeviceName << "(network =" << targetNetwork << ") does not exist.";
469 return false;
470 }
471
472 if (!dryrun) {
473 yarp::dev::PolyDriverDescriptor targetDevice = findDeviceIncludingExternal(targetDeviceName);
474
475 // yCDebug() << "Attach device" << device.name() << "to" << targetDevice.name() << "as" << targetNetwork;
476 drivers.push(targetDevice.poly, targetNetwork.c_str());
477 }
478 }
479 } else {
480 yCError(YRI_ROBOT) << "Action \"" << ActionTypeToString(ActionTypeAttach) << R"(" requires either "network" or "networks" parameter)";
481 return false;
482 }
483
484 if (dryrun) {
485 return true;
486 }
487
488 if (!drivers.size()) {
489 yCError(YRI_ROBOT) << "Action \"" << ActionTypeToString(ActionTypeAttach) << "\" couldn't find any device.";
490 return false;
491 }
492
493 return device.attach(drivers);
494}
495
501
502
504{
505 if (!params.empty()) {
506 yCWarning(YRI_ROBOT) << "Action \"" << ActionTypeToString(ActionTypeDetach) << "\" cannot have any parameter. Ignoring them.";
507 }
508
509 if (dryrun) {
510 return true;
511 }
512
513 return device.detach();
514}
515
518{
519 if (!yarp::robotinterface::hasParam(params, "target")) {
520 yCError(YRI_ROBOT) << "Action \"" << ActionTypeToString(ActionTypePark) << R"(" requires "target" parameter)";
521 return false;
522 }
523 std::string targetDeviceName = yarp::robotinterface::findParam(params, "target");
524
525 if (!hasDeviceIncludingExternal(targetDeviceName)) {
526 yCError(YRI_ROBOT) << "Target device" << targetDeviceName << "does not exist.";
527 return false;
528 }
529
530 if (dryrun) {
531 return true;
532 }
533
534 yarp::dev::PolyDriverDescriptor targetDevice = findDeviceIncludingExternal(targetDeviceName);
535
536 return device.park(targetDevice);
537}
538
544
546 mPriv(new Private(this))
547{
548}
549
551 mPriv(new Private(this))
552{
553 mPriv->name = name;
554 mPriv->devices = devices;
555}
556
558 mPriv(new Private(this))
559{
560 mPriv->name = other.mPriv->name;
561 mPriv->build = other.mPriv->build;
562 mPriv->portprefix = other.mPriv->portprefix;
563 mPriv->currentPhase = other.mPriv->currentPhase;
564 mPriv->currentLevel = other.mPriv->currentLevel;
565 mPriv->dryrun = other.mPriv->dryrun;
567 mPriv->devices = other.mPriv->devices;
568 mPriv->params = other.mPriv->params;
569}
570
572{
573 if (&other != this) {
574 mPriv->name = other.mPriv->name;
575 mPriv->build = other.mPriv->build;
576 mPriv->portprefix = other.mPriv->portprefix;
577 mPriv->currentPhase = other.mPriv->currentPhase;
578 mPriv->currentLevel = other.mPriv->currentLevel;
579 mPriv->dryrun = other.mPriv->dryrun;
580 mPriv->reverseShutdownActionOrder = other.mPriv->reverseShutdownActionOrder;
581
582 mPriv->devices.clear();
583 mPriv->devices = other.mPriv->devices;
584
585 mPriv->params.clear();
586 mPriv->params = other.mPriv->params;
587 }
588
589 return *this;
590}
591
593{
594 delete mPriv;
595}
596
598{
599 return mPriv->name;
600}
601
603{
604 return mPriv->build;
605}
606
608{
609 return mPriv->portprefix;
610}
611
613{
614 for (auto& device : devices()) {
615 ParamList& params = device.params();
616 // Do not override "verbose" param if explicitly set in the xml
617 if (verbose && !yarp::robotinterface::hasParam(params, "verbose")) {
618 device.params().push_back(Param("verbose", "1"));
619 }
620 }
621}
622
624{
625 for (auto& device : devices()) {
626 ParamList& params = device.params();
627 // Do not override "allow-deprecated-devices" param if explicitly set in the xml
628 if (allowDeprecatedDevices && !yarp::robotinterface::hasParam(params, "allow-deprecated-devices")) {
629 device.params().push_back(Param("allow-deprecated-devices", "1"));
630 }
631 }
632}
633
635{
636 mPriv->dryrun = dryrun;
637}
638
640{
641 mPriv->reverseShutdownActionOrder = reverseShutdownActionOrder;
642}
643
648
653
655{
656 return *mPriv->findDevice(name);
657}
658
659const std::string& yarp::robotinterface::Robot::name() const
660{
661 return mPriv->name;
662}
663
664const unsigned int& yarp::robotinterface::Robot::build() const
665{
666 return mPriv->build;
667}
668
670{
671 return mPriv->portprefix;
672}
673
675{
676 return mPriv->params;
677}
678
680{
681 return mPriv->devices;
682}
683
684bool yarp::robotinterface::Robot::hasDevice(const std::string& name) const
685{
686 return mPriv->hasDevice(name);
687}
688
690{
691 return *mPriv->findDevice(name);
692}
693
695{
696 yCInfo(YRI_ROBOT) << "Interrupt received. Stopping all running threads.";
697
698 // If we received an interrupt we send a stop signal to all threads
699 // from previous phases
700 for (auto& device : devices()) {
701 device.stopThreads();
702 }
703}
704
706{
707 bool nameConflict = mPriv->checkForNamingConflictsInExternalDevices(list);
708 if (nameConflict) {
709 return false;
710 }
711
712 mPriv->externalDevices = list;
713 return true;
714}
715
717{
718 yCInfo(YRI_ROBOT) << ActionPhaseToString(phase) << "phase starting...";
719
720 mPriv->currentPhase = phase;
721 mPriv->currentLevel = 0;
722
723 // Open all devices
724 if (phase == ActionPhaseStartup) {
725 if (!mPriv->openDevices()) {
726 yCError(YRI_ROBOT) << "One or more devices failed opening... see previous log messages for more info";
727 if (!mPriv->closeDevices()) {
728 yCError(YRI_ROBOT) << "One or more devices failed closing";
729 }
730 return false;
731 }
732 }
733
734 // run phase does not accept actions
735 if (phase == ActionPhaseRun) {
736 if (mPriv->getLevels(phase).size() != 0) {
737 yCWarning(YRI_ROBOT) << "Phase" << ActionPhaseToString(phase) << "does not accept actions. Skipping all actions for this phase";
738 }
739 return true;
740 }
741
742 // Before starting any action we ensure that there are no other
743 // threads running from previous phases.
744 // In interrupt 2 and 3 and this is called by the interrupt callback,
745 // and therefore main thread will be blocked and join will never
746 // return. Therefore, since we want to start the abort actions we
747 // skip this check.
748 if (phase != ActionPhaseInterrupt2 && phase != ActionPhaseInterrupt3) {
749 for (auto& device : devices()) {
750 device.joinThreads();
751 }
752 }
753
754 std::vector<unsigned int> levels = mPriv->getLevels(phase);
755 if (mPriv->reverseShutdownActionOrder && (phase == ActionPhaseShutdown ||
756 phase == ActionPhaseInterrupt1 ||
757 phase == ActionPhaseInterrupt2 ||
758 phase == ActionPhaseInterrupt3)) {
759 std::reverse(levels.begin(), levels.end());
760 }
761
762 bool ret = true;
763 for (unsigned int level : levels) {
764 // for each level
765 yCInfo(YRI_ROBOT) << "Entering action level" << level << "of phase" << ActionPhaseToString(phase);
766 mPriv->currentLevel = level;
767
768 // If current phase was changed by some other thread, we should
769 // exit the loop and avoid starting further actions.
770 if (mPriv->currentPhase != phase) {
771 ret = false;
772 break;
773 }
774
775 std::vector<std::pair<Device, Action>> actions = mPriv->getActions(phase, level);
776
777 for (auto& ait : actions) {
778 // for each action in that level
779 Device& device = ait.first;
780 Action& action = ait.second;
781
782 // If current phase was changed by some other thread, we should
783 // exit the loop and avoid starting further actions.
784 if (mPriv->currentPhase != phase) {
785 ret = false;
786 break;
787 }
788
789 yCInfo(YRI_ROBOT) << "Executing" << ActionTypeToString(action.type()) << "action, level" << action.level() << "on device" << device.name() << "with parameters" << action.params();
790
791 switch (action.type()) {
793 if (!mPriv->configure(device, action.params())) {
794 yCError(YRI_ROBOT) << "Cannot run configure action on device" << device.name();
795 ret = false;
796 }
797 break;
799 if (!mPriv->calibrate(device, action.params())) {
800 yCError(YRI_ROBOT) << "Cannot run calibrate action on device" << device.name();
801 ret = false;
802 }
803 break;
804 case ActionTypeAttach:
805 if (!mPriv->attach(device, action.params())) {
806 yCError(YRI_ROBOT) << "Cannot run attach action on device" << device.name();
807 ret = false;
808 }
809 break;
810 case ActionTypeAbort:
811 if (!mPriv->abort(device, action.params())) {
812 yCError(YRI_ROBOT) << "Cannot run abort action on device" << device.name();
813 ret = false;
814 }
815 break;
816 case ActionTypeDetach:
817 if (!mPriv->detach(device, action.params())) {
818 yCError(YRI_ROBOT) << "Cannot run detach action on device" << device.name();
819 ret = false;
820 }
821 break;
822 case ActionTypePark:
823 if (!mPriv->park(device, action.params())) {
824 yCError(YRI_ROBOT) << "Cannot run park action on device" << device.name();
825 ret = false;
826 }
827 break;
828 case ActionTypeCustom:
829 if (!mPriv->custom(device, action.params())) {
830 yCError(YRI_ROBOT) << "Cannot run custom action on device" << device.name();
831 ret = false;
832 }
833 break;
834 default:
835 yCWarning(YRI_ROBOT) << "Unhandled action" << ActionTypeToString(action.type());
836 ret = false;
837 break;
838 }
839 }
840
841 yCInfo(YRI_ROBOT) << "All actions for action level" << level << "of" << ActionPhaseToString(phase) << "phase started. Waiting for unfinished actions.";
842
843 // Join parallel threads
844 for (auto& device : devices()) {
845 device.joinThreads();
846 // yCDebug() << "All actions for device" << device.name() << "at level()" << level << "finished";
847 }
848
849 yCInfo(YRI_ROBOT) << "All actions for action level" << level << "of" << ActionPhaseToString(phase) << "phase finished.";
850 }
851
852 if (!ret) {
853 yCWarning(YRI_ROBOT) << "There was some problem running actions for" << ActionPhaseToString(phase) << "phase . Please check the log and your configuration";
854 }
855
856 if (phase == ActionPhaseShutdown) {
857 if (!mPriv->closeDevices()) {
858 yCError(YRI_ROBOT) << "One or more devices failed closing";
859 return false;
860 }
861 }
862
863 yCInfo(YRI_ROBOT) << ActionPhaseToString(phase) << "phase finished.";
864
865 return ret;
866}
867
869{
870 return mPriv->currentPhase;
871}
872
874{
875 return mPriv->currentLevel;
876}
877
878bool yarp::robotinterface::Robot::hasParam(const std::string& name) const
879{
880 return yarp::robotinterface::hasParam(mPriv->params, name);
881}
882
883std::string yarp::robotinterface::Robot::findParam(const std::string& name) const
884{
885 return yarp::robotinterface::findParam(mPriv->params, name);
886}
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:503
std::vector< unsigned int > getLevels(ActionPhase phase) const
Definition Robot.cpp:319
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:516
bool custom(const Device &device, const ParamList &params)
Definition Robot.cpp:539
bool hasDevice(const std::string &name) const
Definition Robot.cpp:123
bool calibrate(const Device &device, const ParamList &params)
Definition Robot.cpp:366
bool hasDeviceIncludingExternal(const std::string &name) const
Definition Robot.cpp:143
bool attach(const Device &device, const ParamList &params)
Definition Robot.cpp:389
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:360
std::vector< std::pair< Device, Action > > getActions(ActionPhase phase, unsigned int level) const
Definition Robot.cpp:342
yarp::dev::PolyDriverList externalDevices
Definition Robot.cpp:112
bool abort(const Device &device, const ParamList &params)
Definition Robot.cpp:496
bool hasParam(const std::string &name) const
Definition Robot.cpp:878
void setAllowDeprecatedDevices(bool allowDeprecatedDevices)
Definition Robot.cpp:623
bool hasDevice(const std::string &name) const
Definition Robot.cpp:684
yarp::robotinterface::ActionPhase currentPhase() const
Definition Robot.cpp:868
std::string & portprefix()
Definition Robot.cpp:607
DeviceList & devices()
Definition Robot.cpp:649
void setVerbose(bool verbose)
Definition Robot.cpp:612
bool enterPhase(yarp::robotinterface::ActionPhase phase)
Definition Robot.cpp:716
bool setExternalDevices(const yarp::dev::PolyDriverList &list)
Definition Robot.cpp:705
void setReverseShutdownActionOrder(bool reverseShutdownActionOrder)
Definition Robot.cpp:639
std::string & name()
Definition Robot.cpp:597
Robot & operator=(const Robot &other)
Definition Robot.cpp:571
unsigned int & build()
Definition Robot.cpp:602
std::string findParam(const std::string &name) const
Definition Robot.cpp:883
Device & device(const std::string &name)
Definition Robot.cpp:654
void setDryRun(bool dryrun)
Definition Robot.cpp:634
#define yCInfo(component,...)
#define yCError(component,...)
#define yCWarning(component,...)
#define yCDebug(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