11 #include <yarp/dev/GenericVocabs.h>
13 using namespace yarp::os;
18 static const std::vector<std::string>
partsVec {
"head",
"torso",
"left_arm",
"right_arm",
"left_leg",
"right_leg"};
26 for (
auto& rep : m_replayerVec){
28 yError()<<
"wholeBodyPlayer: the port"<<rep.m_replayPort->getName()<<
"is closed because something went wrong.. closing";
34 ok &= m_rpcPort.write(reqPause, response);
35 if (!
ok || response.get(0).asVocab32() != VOCAB_OK) {
36 yError()<<
"wholeBodyPlayer: the port"<<rep.m_replayPort->getName()<<
"is closed because the pause request failed.. closing";
41 ok &= rep.m_replayPort->positionMoveFallback();
43 yError()<<
"wholeBodyPlayer: the port"<<rep.m_replayPort->getName()<<
"is closed because the fallback failed.. closing";
49 ok &= m_rpcPort.write(reqPlay, response);
50 if (!
ok || response.get(0).asVocab32() != VOCAB_OK) {
51 yError()<<
"wholeBodyPlayer: the port"<<rep.m_replayPort->getName()<<
"is closed because the start request failed.. closing";
62 auto robot = rf.check(
"robot",Value(
"icub")).asString();
63 auto name = rf.check(
"name",Value(
"wholeBodyPlayerModule")).asString();
65 auto partsBot = rf.find(
"parts").asList();
66 if (!partsBot || partsBot->isNull())
68 yError()<<
"wholeBodyPlayerModule: missing parts parameter, please specify as list";
72 m_replayerVec.resize(partsBot->size());
74 for (
size_t i = 0; i<partsBot->size(); i++) {
75 auto partStr = partsBot->get(i).asString();
78 yError()<<
"wholeBodyPlayerModule: the part"<<partStr<<
"is not available";
81 if (!m_replayerVec[i].open(robot, partStr, name))
83 yError()<<
"wholeBodyPlayerModule: failed to open one replayer.. closing.";
88 if (!m_rpcPort.open(
"/"+name+
"/rpc:o")) {
89 yError()<<
"wholeBodyPlayerModule: failed to open"<<m_rpcPort.getName();
93 if (!Network::connect(m_rpcPort.getName(),
"/yarpdataplayer/rpc:i")) {
94 yError()<<
"wholeBodyPlayerModule: failed to connect to the yarpdataplayer, is it running?";
106 for (
auto& rep : m_replayerVec){
107 rep.m_replayPort->interrupt();
109 m_rpcPort.interrupt();
114 for (
auto& rep : m_replayerVec){
static const std::vector< std::string > partsVec
bool updateModule() override
bool configure(yarp::os::ResourceFinder &rf) override
bool respond(const yarp::os::Bottle &command, yarp::os::Bottle &reply) override
double getPeriod() override
bool interruptModule() override