icub-client
subSystem_babbling.cpp
Go to the documentation of this file.
1 #include <yarp/os/all.h>
3 
5  if(yarp::os::Network::isConnected(portRPC.getName(), "/babbling/rpc")) {
6  return true;
7  } else {
8  return yarp::os::Network::connect(portRPC.getName(), "/babbling/rpc");
9  }
10 }
11 
12 icubclient::SubSystem_babbling::SubSystem_babbling(const std::string &masterName) : SubSystem(masterName) {
13  portRPC.open(("/" + m_masterName + "/babbling:rpc").c_str());
15 }
16 
18  portRPC.interrupt();
19  portRPC.close();
20 }
21 
22 bool icubclient::SubSystem_babbling::babblingArm(const std::string &babblingLimb, double duration) { // need to be extended for several agents
23  yarp::os::Bottle bReq, bResp;
24  bReq.addString("babbling");
25  bReq.addString(babblingLimb);
26  //changethe train_duration if specified
27  if(duration >= 0.0){
28  yInfo() << "Babbling with specific train_duration: " << duration;
29  bReq.addDouble(duration);
30  }
31  portRPC.write(bReq, bResp);
32 
33  return bResp.get(0).asBool();
34 }
35 
36 bool icubclient::SubSystem_babbling::babbling(int jointNumber, const std::string& babblingLimb, double duration) { // need to be extended for several agents
37  yarp::os::Bottle bReq, bResp;
38  bReq.addString("babbling");
39  bReq.addString("joint");
40  bReq.addInt(jointNumber);
41  bReq.addString(babblingLimb);
42  if(duration >= 0.0){
43  yInfo() << "Babbling with specific duration: " << duration;
44  bReq.addDouble(duration);
45  }
46  portRPC.write(bReq, bResp);
47 
48  return bResp.get(0).asBool();
49 }
std::string m_type
Definition: subSystem.h:47
yarp::os::RpcClient portRPC
Definition: subSystem.h:48
virtual void Close()
Clean up resources.
bool babblingArm(const std::string &babblingLimb, double duration=-1.0)
Whole arm babbling.
bool babbling(int jointNumber, const std::string &babblingLimb, double duration=-1.0)
Single joint babbling.
Abstract class to handle sub-systems of the icub-client.
Definition: subSystem.h:43
#define SUBSYSTEM_BABBLING
std::string m_masterName
Definition: subSystem.h:46
SubSystem_babbling(const std::string &masterName)
Default constructor.