16int main(
int argc,
char *argv[])
21 params.fromCommand(argc, argv);
23 if (!params.check(
"robot"))
25 fprintf(stderr,
"Please specify the name of the robot\n");
26 fprintf(stderr,
"--robot name (e.g. icub)\n");
29 std::string robotName=params.find(
"robot").asString();
30 std::string remotePorts=
"/";
31 remotePorts+=robotName;
32 remotePorts+=
"/right_arm";
34 std::string localPorts=
"/test/client";
37 options.put(
"device",
"remote_controlboard");
38 options.put(
"local", localPorts);
39 options.put(
"remote", remotePorts);
42 PolyDriver robotDevice(options);
43 if (!robotDevice.isValid()) {
44 printf(
"Device not available. Here are the known devices:\n");
45 printf(
"%s", Drivers::factory().toString().c_str());
49 IPositionControl *pos;
52 IInteractionMode *iint;
53 IImpedanceControl *iimp;
58 ok = robotDevice.view(pos);
59 ok =
ok && robotDevice.view(encs);
60 ok =
ok && robotDevice.view(ictrl);
61 ok =
ok && robotDevice.view(iimp);
62 ok =
ok && robotDevice.view(itrq);
63 ok =
ok && robotDevice.view(iint);
66 printf(
"Problems acquiring interfaces\n");
77 yarp::dev::InteractionModeEnum interaction_mode;
84 for (i = 0; i < nj; i++) {
87 pos->setRefAccelerations(tmp.data());
89 for (i = 0; i < nj; i++) {
91 pos->setRefSpeed(i, tmp[i]);
98 iimp->setImpedance(i, 0.111, 0.014);
111 pos->positionMove(command.data());
130 ictrl->setControlMode(3,VOCAB_CM_POSITION);
131 iint->setInteractionMode(3,VOCAB_IM_COMPLIANT);
141 ictrl->setControlMode(3,VOCAB_CM_POSITION);
142 iint->setInteractionMode(3,VOCAB_IM_STIFF);
150 pos->positionMove(command.data());
156 encs->getEncoders(encoders.data());
157 itrq->getTorques(torques.data());
158 printf(
"Encoders: %+5.1lf %+5.1lf %+5.1lf %+5.1lf ", encoders[0], encoders[1], encoders[2], encoders[3]);
159 printf(
"Torques: %+5.1lfNm %+5.1lfNm %+5.1lfNm %+5.1lfNm ", torques[0], torques[1], torques[2], torques[3]);
161 for (i = 0; i < 4; i++)
163 ictrl->getControlMode(i, &control_mode);
164 iint->getInteractionMode(i, &interaction_mode);
165 switch (control_mode)
167 case VOCAB_CM_IDLE: printf(
"IDLE ");
break;
168 case VOCAB_CM_POSITION: printf(
"POSITION ");
break;
169 case VOCAB_CM_POSITION_DIRECT: printf(
"POSITION DIRECT ");
break;
170 case VOCAB_CM_VELOCITY: printf(
"VELOCITY ");
break;
171 case VOCAB_CM_MIXED: printf(
"MIXED POS/VEL");
break;
172 case VOCAB_CM_TORQUE: printf(
"TORQUE ");
break;
174 case VOCAB_CM_UNKNOWN: printf(
"UNKNOWN ");
break;
178 printf(
"Interaction: ");
179 for (i = 0; i < 4; i++)
181 switch (interaction_mode)
183 case VOCAB_IM_COMPLIANT: printf(
"(COMPLIANT MODE)");
break;
184 case VOCAB_IM_STIFF: printf(
"(STIFF MODE)");
break;
186 case VOCAB_CM_UNKNOWN: printf(
"(UNKNOWN) ");
break;