12 BufferedPort<Vector> targetPort;
13 targetPort.open(
"/tutorial/target/in");
14 Network::connect(
"/tutorial/target/out",
"/tutorial/target/in");
17 options.put(
"device",
"remote_controlboard");
18 options.put(
"local",
"/tutorial/motor/client");
19 options.put(
"remote",
"/icubSim/head");
20 PolyDriver robotHead(options);
21 if (!robotHead.isValid()) {
22 printf(
"Cannot connect to robot head\n");
26 IPositionControl *pos;
27 IVelocityControl *vel;
33 if (mod==NULL || pos==NULL || vel==NULL || enc==NULL) {
34 printf(
"Cannot get interface to robot head\n");
41 setpoints.resize(
jnts);
44 vector<int> modes(
jnts,VOCAB_CM_VELOCITY);
45 mod->setControlModes(modes.data());
48 Vector *target = targetPort.read();
50 printf(
"We got a vector containing");
51 for (
size_t i=0; i<target->size(); i++) {
52 printf(
" %g", (*target)[i]);
56 double x = (*target)[0];
57 double y = (*target)[1];
58 double conf = (*target)[2];
67 for (
int i=0; i<
jnts; i++) {
78 vel->velocityMove(setpoints.data());