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);
576 myDumper[i].setThetaMap(thetaMap, nJoints);
577 myGetEncs.setInterface(ienc);
578 if (ddBoard.view(istmp))
580 yInfo(
"getEncoders::The time stamp initalization interfaces was successfull! \n");
581 myGetEncs.setStamp(istmp);
584 yError(
"Problems getting the time stamp interfaces \n");
585 myDumper[i].setGetter(&myGetEncs);
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);
594 myDumper[i].setThetaMap(thetaMap, nJoints);
595 myGetSpeeds.setInterface(ienc);
596 if (ddBoard.view(istmp))
598 yInfo(
"getEncodersSpeed::The time stamp initalization interfaces was successfull! \n");
599 myGetSpeeds.setStamp(istmp);
602 yError(
"Problems getting the time stamp interfaces \n");
603 myDumper[i].setGetter(&myGetSpeeds);
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);
612 myDumper[i].setThetaMap(thetaMap, nJoints);
613 myGetAccs.setInterface(ienc);
614 if (ddBoard.view(istmp))
616 yInfo(
"getEncoderAccelerations::The time stamp initalization interfaces was successfull! \n");
617 myGetAccs.setStamp(istmp);
620 yError(
"Problems getting the time stamp interfaces \n");
621 myDumper[i].setGetter(&myGetAccs);
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);
630 myDumper[i].setThetaMap(thetaMap, nJoints);
631 myGetPidRefs.setInterface(ipid);
632 if (ddBoard.view(istmp))
634 yInfo(
"getPosPidReferences::The time stamp initalization interfaces was successfull! \n");
635 myGetPidRefs.setStamp(istmp);
638 yError(
"Problems getting the time stamp interfaces \n");
639 myDumper[i].setGetter(&myGetPidRefs);
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);
648 myDumper[i].setThetaMap(thetaMap, nJoints);
649 myGetTrqRefs.setInterface(itrq);
650 if (ddBoard.view(istmp))
652 yInfo(
"getTrqPidReferences::The time stamp initalization interfaces was successfull! \n");
653 myGetTrqRefs.setStamp(istmp);
656 yError(
"Problems getting the time stamp interfaces \n");
657 myDumper[i].setGetter(&myGetTrqRefs);
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);
666 myDumper[i].setThetaMap(thetaMap, nJoints);
667 myGetControlModes.setInterface(icmod, nJoints);
668 if (ddBoard.view(istmp))
670 yInfo(
"getControlModes::The time stamp initalization interfaces was successfull! \n");
671 myGetControlModes.setStamp(istmp);
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);
684 myDumper[i].setThetaMap(thetaMap, nJoints);
685 myGetInteractionModes.setInterface(iimod, nJoints);
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);
702 myDumper[i].setThetaMap(thetaMap, nJoints);
703 myGetPosErrs.setInterface(ipid);
704 if (ddBoard.view(istmp))
706 yInfo(
"getPositionErrors::The time stamp initalization interfaces was successfull! \n");
707 myGetPosErrs.setStamp(istmp);
710 yError(
"Problems getting the time stamp interfaces \n");
711 myDumper[i].setGetter(&myGetPosErrs);
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);
720 myDumper[i].setThetaMap(thetaMap, nJoints);
721 myGetOuts.setInterface(ipid);
722 if (ddBoard.view(istmp))
724 yInfo(
"getOutputs::The time stamp initalization interfaces was successfull! \n");
725 myGetOuts.setStamp(istmp);
728 yError(
"Problems getting the time stamp interfaces \n");
729 myDumper[i].setGetter(&myGetOuts);
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);
738 myDumper[i].setThetaMap(thetaMap, nJoints);
739 myGetCurrs.setInterface(iamp);
740 if (ddBoard.view(istmp))
742 yInfo(
"getCurrents::The time stamp initalization interfaces was successfull! \n");
743 myGetCurrs.setStamp(istmp);
746 yError(
"Problems getting the time stamp interfaces \n");
748 myDumper[i].setGetter(&myGetCurrs);
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);
757 myDumper[i].setThetaMap(thetaMap, nJoints);
758 myGetTrqs.setInterface(itrq);
759 if (ddBoard.view(istmp))
761 yInfo(
"getTorques::The time stamp initalization interfaces was successfull! \n");
762 myGetTrqs.setStamp(istmp);
765 yError(
"Problems getting the time stamp interfaces \n");
767 myDumper[i].setGetter(&myGetTrqs);
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);
776 myDumper[i].setThetaMap(thetaMap, nJoints);
777 myGetTrqErrs.setInterface(ipid);
778 if (ddBoard.view(istmp))
780 yInfo(
"getTorqueErrors::The time stamp initalization interfaces was successfull! \n");
781 myGetTrqErrs.setStamp(istmp);
784 yError(
"Problems getting the time stamp interfaces \n");
786 myDumper[i].setGetter(&myGetTrqErrs);
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);
795 myDumper[i].setThetaMap(thetaMap, nJoints);
796 myGetTemps.setInterface(imot);
797 if (ddBoard.view(istmp))
799 yInfo(
"getEncoders::The time stamp initalization interfaces was successfull! \n");
800 myGetTemps.setStamp(istmp);
803 yError(
"Problems getting the time stamp interfaces \n");
804 myDumper[i].setGetter(&myGetTemps);
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);
813 myDumper[i].setThetaMap(thetaMap, nJoints);
814 myGetMotorEncs.setInterface(imotenc);
815 if (ddBoard.view(istmp))
817 yInfo(
"getEncoders::The time stamp initalization interfaces was successfull! \n");
818 myGetMotorEncs.setStamp(istmp);
821 yError(
"Problems getting the time stamp interfaces \n");
822 myDumper[i].setGetter(&myGetMotorEncs);
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);
831 myDumper[i].setThetaMap(thetaMap, nJoints);
832 myGetMotorSpeeds.setInterface(imotenc);
833 if (ddBoard.view(istmp))
835 yInfo(
"getEncodersSpeed::The time stamp initalization interfaces was successfull! \n");
836 myGetMotorSpeeds.setStamp(istmp);
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);
849 myDumper[i].setThetaMap(thetaMap, nJoints);
850 myGetMotorAccs.setInterface(imotenc);
851 if (ddBoard.view(istmp))
853 yInfo(
"getEncoderAccelerations::The time stamp initalization interfaces was successfull! \n");
854 myGetMotorAccs.setStamp(istmp);
857 yError(
"Problems getting the time stamp interfaces \n");
858 myDumper[i].setGetter(&myGetMotorAccs);
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);
867 myDumper[i].setThetaMap(thetaMap, nJoints);
868 myGetMotPwm.setInterface(iamp);
871 if(!ddBoard.view(ienc))
874 ienc->getAxes(&myGetMotPwm.n_joint_part);
875 if (ddBoard.view(istmp))
877 yInfo(
"getMotorsPwm::The time stamp initalization interfaces was successfull! \n");
878 myGetMotPwm.setStamp(istmp);
881 yError(
"Problems getting the time stamp interfaces \n");
882 myDumper[i].setGetter(&myGetMotPwm);
887 for (
int i = 0; i < nData; i++)