449 if (!rf.check(
"robot") || !rf.check(
"part"))
451 printf(
"Missing either --robot or --part options. Quitting!\n");
455 std::string dumpername;
457 if (rf.check(
"name"))
459 dumpername = rf.find(
"name").asString();
464 dumpername =
"/controlBoardDumper/";
467 Value& robot = rf.find(
"robot");
468 Value& part = rf.find(
"part");
469 configFileRobotPart =
"config_";
470 configFileRobotPart = configFileRobotPart + robot.asString();
471 configFileRobotPart = configFileRobotPart +
"_";
472 configFileRobotPart = configFileRobotPart + part.asString();
473 configFileRobotPart = configFileRobotPart +
".ini";
481 thetaMap =
new int[nJoints];
489 dataToDump =
new std::string[nData];
490 if (
getDataToDump(rf, dataToDump, nData, &useDebugClient) == 0)
494 yInfo(
"Running with the following configuration:\n");
495 yInfo(
"Selected rate is: %d\n", rate);
496 yInfo(
"Data selected to be dumped are:\n");
497 for (
int i = 0; i < nData; i++)
498 yInfo(
"\t%s \n", dataToDump[i].c_str());
501 ddBoardOptions.put(
"device",
"remote_controlboard");
502 ddDebugOptions.put(
"device",
"debugInterfaceClient");
504 std::string localPortName = name;
505 std::string localDebugPortName = name;
506 localPortName = localPortName + dumpername;
507 localDebugPortName = localPortName +
"debug/";
509 localPortName = localPortName + part.asString();
510 localDebugPortName = localDebugPortName + part.asString();
511 ddBoardOptions.put(
"local", localPortName);
512 ddDebugOptions.put(
"local", localDebugPortName);
514 std::string remotePortName =
"/";
515 std::string remoteDebugPortName;
516 remotePortName = remotePortName + robot.asString();
517 remotePortName = remotePortName +
"/";
518 remotePortName = remotePortName + part.asString();
519 ddBoardOptions.put(
"remote", remotePortName);
521 remoteDebugPortName = remotePortName +
"/debug";
522 ddDebugOptions.put(
"remote", remoteDebugPortName);
525 ddBoard.open(ddBoardOptions);
526 if (!ddBoard.isValid()) {
527 printf(
"Device not available.\n");
533 ddDebug.open(ddDebugOptions);
534 if (!ddDebug.isValid())
536 yError(
"\n-----------------------------------------\n");
537 yError(
"Debug Interface is mandatory to run this module with the '--dataToDumpAll' option or to dump any of the getRotorxxx data.\n");
538 yError(
"Please Verify the following 2 conditions are satisfied:\n\n");
539 yError(
"1) Check 'debugInterfaceClient' is available using 'yarpdev --list' command\n");
542 std::string deviceList, myDev;
544 deviceList.append(Drivers::factory().toString());
545 myDev =
"debugInterfaceClient";
546 if(deviceList.find(myDev) != std::string::npos)
547 yError(
"\t--> Seems OK\n");
549 yError(
"\t--> Seems NOT OK. The device was not found, please activate the compilation using the corrisponding CMake flag.\n");
551 yError(
"\n2) Check if the robot has the 'debugInterfaceWrapper' device up and running. \n You should see from 'yarp name list' output, a port called\n");
552 yError(
"\t/robotName/part_name/debug/rpc:i\n If not, fix the robot configuration files to instantiate the 'debugInterfaceWrapper' device.\n");
553 yError(
"\nQuickFix: If you set the --dataToDumpAll and do not need the advanced debug feature (getRotorxxx) just remove this option. See help for more information.\n");
554 yError(
"------------- END ERROR MESSAGE ---------------\n\n");
559 bool logToFile =
false;
560 if (rf.check(
"logToFile")) logToFile =
true;
562 portPrefix= dumpername + part.asString() +
"/";
568 for (
int i = 0; i < nData; i++)
570 if (dataToDump[i] ==
"getEncoders" )
572 if (ddBoard.view(ienc))
574 yInfo(
"Initializing a getEncs thread\n");
575 myDumper[i].
setDevice(&ddBoard, &ddDebug, rate, portPrefix, dataToDump[i], logToFile);
578 if (ddBoard.view(istmp))
580 yInfo(
"getEncoders::The time stamp initalization interfaces was successfull! \n");
584 yError(
"Problems getting the time stamp interfaces \n");
588 else if (dataToDump[i] ==
"getEncoderSpeeds")
590 if (ddBoard.view(ienc))
592 yInfo(
"Initializing a getSpeeds thread\n");
593 myDumper[i].
setDevice(&ddBoard, &ddDebug, rate, portPrefix, dataToDump[i], logToFile);
596 if (ddBoard.view(istmp))
598 yInfo(
"getEncodersSpeed::The time stamp initalization interfaces was successfull! \n");
602 yError(
"Problems getting the time stamp interfaces \n");
606 else if (dataToDump[i] ==
"getEncoderAccelerations")
608 if (ddBoard.view(ienc))
610 yInfo(
"Initializing a getAccs thread\n");
611 myDumper[i].
setDevice(&ddBoard, &ddDebug, rate, portPrefix, dataToDump[i], logToFile);
614 if (ddBoard.view(istmp))
616 yInfo(
"getEncoderAccelerations::The time stamp initalization interfaces was successfull! \n");
620 yError(
"Problems getting the time stamp interfaces \n");
624 else if (dataToDump[i] ==
"getPosPidReferences")
626 if (ddBoard.view(ipid))
628 yInfo(
"Initializing a getErrs thread\n");
629 myDumper[i].
setDevice(&ddBoard, &ddDebug, rate, portPrefix, dataToDump[i], logToFile);
632 if (ddBoard.view(istmp))
634 yInfo(
"getPosPidReferences::The time stamp initalization interfaces was successfull! \n");
638 yError(
"Problems getting the time stamp interfaces \n");
642 else if (dataToDump[i] ==
"getTrqPidReferences")
644 if (ddBoard.view(itrq))
646 yInfo(
"Initializing a getErrs thread\n");
647 myDumper[i].
setDevice(&ddBoard, &ddDebug, rate, portPrefix, dataToDump[i], logToFile);
650 if (ddBoard.view(istmp))
652 yInfo(
"getTrqPidReferences::The time stamp initalization interfaces was successfull! \n");
656 yError(
"Problems getting the time stamp interfaces \n");
660 else if (dataToDump[i] ==
"getControlModes")
662 if (ddBoard.view(icmod))
664 yInfo(
"Initializing a getErrs thread\n");
665 myDumper[i].
setDevice(&ddBoard, &ddDebug, rate, portPrefix, dataToDump[i], logToFile);
668 if (ddBoard.view(istmp))
670 yInfo(
"getControlModes::The time stamp initalization interfaces was successfull! \n");
674 yError(
"Problems getting the time stamp interfaces \n");
675 myDumper[i].
setGetter(&myGetControlModes);
678 else if (dataToDump[i] ==
"getInteractionModes")
680 if (ddBoard.view(iimod))
682 yInfo(
"Initializing a getErrs thread\n");
683 myDumper[i].
setDevice(&ddBoard, &ddDebug, rate, portPrefix, dataToDump[i], logToFile);
686 if (ddBoard.view(istmp))
688 yInfo(
"getInteractionModes::The time stamp initalization interfaces was successfull! \n");
689 myGetInteractionModes.
setStamp(istmp);
692 yError(
"Problems getting the time stamp interfaces \n");
693 myDumper[i].
setGetter(&myGetInteractionModes);
696 else if (dataToDump[i] ==
"getPositionErrors")
698 if (ddBoard.view(ipid))
700 yInfo(
"Initializing a getErrs thread\n");
701 myDumper[i].
setDevice(&ddBoard, &ddDebug, rate, portPrefix, dataToDump[i], logToFile);
704 if (ddBoard.view(istmp))
706 yInfo(
"getPositionErrors::The time stamp initalization interfaces was successfull! \n");
710 yError(
"Problems getting the time stamp interfaces \n");
714 else if (dataToDump[i] ==
"getOutputs")
716 if (ddBoard.view(ipid))
718 yInfo(
"Initializing a getOuts thread\n");
719 myDumper[i].
setDevice(&ddBoard, &ddDebug, rate, portPrefix, dataToDump[i], logToFile);
722 if (ddBoard.view(istmp))
724 yInfo(
"getOutputs::The time stamp initalization interfaces was successfull! \n");
728 yError(
"Problems getting the time stamp interfaces \n");
732 else if (dataToDump[i] ==
"getCurrents")
734 if (ddBoard.view(iamp))
736 yInfo(
"Initializing a getCurrs thread\n");
737 myDumper[i].
setDevice(&ddBoard, &ddDebug, rate, portPrefix, dataToDump[i], logToFile);
740 if (ddBoard.view(istmp))
742 yInfo(
"getCurrents::The time stamp initalization interfaces was successfull! \n");
746 yError(
"Problems getting the time stamp interfaces \n");
751 else if (dataToDump[i] ==
"getTorques")
753 if (ddBoard.view(itrq))
755 yInfo(
"Initializing a getTorques thread\n");
756 myDumper[i].
setDevice(&ddBoard, &ddDebug, rate, portPrefix, dataToDump[i], logToFile);
759 if (ddBoard.view(istmp))
761 yInfo(
"getTorques::The time stamp initalization interfaces was successfull! \n");
765 yError(
"Problems getting the time stamp interfaces \n");
770 else if (dataToDump[i] ==
"getTorqueErrors")
772 if (ddBoard.view(ipid))
774 yInfo(
"Initializing a getTorqueErrors thread\n");
775 myDumper[i].
setDevice(&ddBoard, &ddDebug, rate, portPrefix, dataToDump[i], logToFile);
778 if (ddBoard.view(istmp))
780 yInfo(
"getTorqueErrors::The time stamp initalization interfaces was successfull! \n");
784 yError(
"Problems getting the time stamp interfaces \n");
789 else if (dataToDump[i] ==
"getTemperatures")
791 if (ddBoard.view(imotenc))
793 yInfo(
"Initializing a getTemps thread\n");
794 myDumper[i].
setDevice(&ddBoard, &ddDebug, rate, portPrefix, dataToDump[i], logToFile);
797 if (ddBoard.view(istmp))
799 yInfo(
"getEncoders::The time stamp initalization interfaces was successfull! \n");
803 yError(
"Problems getting the time stamp interfaces \n");
807 else if (dataToDump[i] ==
"getMotorEncoders")
809 if (ddBoard.view(imotenc))
811 yInfo(
"Initializing a getEncs thread\n");
812 myDumper[i].
setDevice(&ddBoard, &ddDebug, rate, portPrefix, dataToDump[i], logToFile);
815 if (ddBoard.view(istmp))
817 yInfo(
"getEncoders::The time stamp initalization interfaces was successfull! \n");
821 yError(
"Problems getting the time stamp interfaces \n");
825 else if (dataToDump[i] ==
"getMotorEncoderSpeeds")
827 if (ddBoard.view(imotenc))
829 yInfo(
"Initializing a getSpeeds thread\n");
830 myDumper[i].
setDevice(&ddBoard, &ddDebug, rate, portPrefix, dataToDump[i], logToFile);
833 if (ddBoard.view(istmp))
835 yInfo(
"getEncodersSpeed::The time stamp initalization interfaces was successfull! \n");
839 yError(
"Problems getting the time stamp interfaces \n");
840 myDumper[i].
setGetter(&myGetMotorSpeeds);
843 else if (dataToDump[i] ==
"getMotorEncoderAccelerations")
845 if (ddBoard.view(imotenc))
847 yInfo(
"Initializing a getAccs thread\n");
848 myDumper[i].
setDevice(&ddBoard, &ddDebug, rate, portPrefix, dataToDump[i], logToFile);
851 if (ddBoard.view(istmp))
853 yInfo(
"getEncoderAccelerations::The time stamp initalization interfaces was successfull! \n");
857 yError(
"Problems getting the time stamp interfaces \n");
861 else if (dataToDump[i] ==
"getMotorsPwm")
863 if (ddBoard.view(iamp))
865 yInfo(
"Initializing a getMotPwm thread\n");
866 myDumper[i].
setDevice(&ddBoard, &ddDebug, rate, portPrefix, dataToDump[i], logToFile);
871 if(!ddBoard.view(ienc))
875 if (ddBoard.view(istmp))
877 yInfo(
"getMotorsPwm::The time stamp initalization interfaces was successfull! \n");
881 yError(
"Problems getting the time stamp interfaces \n");
887 for (
int i = 0; i < nData; i++)