24 using namespace yarp::os;
26 using namespace yarp::sig;
32 statePort.setOwner(
this);
38 printf(
"Opening Fake Motor Device Client ...\n");
40 string remote=config.check(
"remote",Value(
"/fakeyServer")).asString();
41 string local=config.check(
"local",Value(
"/fakeyClient")).asString();
43 statePort.open(local+
"/state:i");
44 cmdPort.open(local+
"/cmd:o");
45 rpcPort.open(local+
"/rpc");
48 ok&=Network::connect(remote+
"/state:o",statePort.getName(),
"udp");
49 ok&=Network::connect(cmdPort.getName(),remote+
"/cmd:i",
"udp");
50 ok&=Network::connect(rpcPort.getName(),remote+
"/rpc",
"tcp");
56 printf(
"Fake Motor Device Client successfully open\n");
65 printf(
"Fake Motor Device Client failed to open\n");
73 printf(
"Closing Fake Motor Device Client ...\n");
75 statePort.interrupt();
85 printf(
"Fake Motor Device Client successfully closed\n");
92 if (!configured || (
min==NULL) || (
max==NULL))
96 cmd.addVocab32(
"lim");
97 cmd.addVocab32(
"get");
99 if (rpcPort.write(
cmd,reply))
101 *
min=reply.get(1).asFloat64();
102 *
max=reply.get(2).asFloat64();
113 if (!configured || (ax==NULL))
117 cmd.addVocab32(
"enc");
118 cmd.addVocab32(
"axes");
119 if (rpcPort.write(
cmd,reply))
121 *ax=reply.get(1).asInt32();
131 if (!configured || (
encs==NULL))
134 lock_guard<mutex> lg(mtx);
135 for (
size_t i=0; i<this->encs.length(); i++)
136 encs[i]=this->encs[i];
148 cmd.addVocab32(
"vel");
149 cmd.addVocab32(
"move");
152 if (rpcPort.write(
cmd,reply))
165 cmd.addVocab32(
"vel");
166 cmd.addVocab32(
"acc");
169 if (rpcPort.write(
cmd,reply))
182 cmd.addVocab32(
"vel");
183 cmd.addVocab32(
"stop");
185 if (rpcPort.write(
cmd,reply))
bool open(yarp::os::Searchable &config)
bool setRefAcceleration(int j, double acc)
bool getEncoders(double *encs)
bool getLimits(int axis, double *min, double *max)
bool velocityMove(int j, double sp)