Skip to content

Commit

Permalink
fixed documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
pattacini committed Jan 7, 2020
1 parent 3f68e39 commit d6f4d4d
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions doc/image_processing.dox
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,10 @@ Now we can read from this port (just to test) with yarp read:

Now let's write a separate program that takes the target location computed in find_location.cpp and drives the real of simulated camera to look towards that location. First, we need to read our vector:
\code
#include <stdio.h>
#include <cstdio>
#include <yarp/os/all.h>
#include <yarp/sig/all.h>
using namespace std;
using namespace yarp::os;
using namespace yarp::sig;
int main() {
Expand Down Expand Up @@ -272,13 +273,15 @@ We connect to the simulator head:
printf("Cannot connect to robot head\n");
return 1;
}
IControlMode *mod;
IPositionControl *pos;
IVelocityControl *vel;
IEncoders *enc;
robotHead.view(mod);
robotHead.view(pos);
robotHead.view(vel);
robotHead.view(enc);
if (pos==NULL || vel==NULL || enc==NULL) {
if (mode==NULL || pos==NULL || vel==NULL || enc==NULL) {
printf("Cannot get interface to robot head\n");
robotHead.close();
return 1;
Expand All @@ -287,6 +290,10 @@ We connect to the simulator head:
pos->getAxes(&jnts);
Vector setpoints;
setpoints.resize(jnts);

// enable velocity control mode
vector<int> modes(jnts,VOCAB_CM_VELOCITY);
mod->setControlModes(modes.data());
\endcode

Finally let's send a dumb command just to test:
Expand Down Expand Up @@ -402,10 +409,11 @@ Complete code for finding the blue ball:
Complete look_at_location.cpp:

\code
#include <stdio.h>
#include <cstdio>
#include <yarp/os/all.h>
#include <yarp/sig/all.h>
#include <yarp/dev/all.h>
using namespace std;
using namespace yarp::os;
using namespace yarp::sig;
using namespace yarp::dev;
Expand All @@ -424,9 +432,11 @@ Complete look_at_location.cpp:
printf("Cannot connect to robot head\n");
return 1;
}
IControlMode *mod;
IPositionControl *pos;
IVelocityControl *vel;
IEncoders *enc;
robotHead.view(mod);
robotHead.view(pos);
robotHead.view(vel);
robotHead.view(enc);
Expand All @@ -439,6 +449,10 @@ Complete look_at_location.cpp:
pos->getAxes(&jnts);
Vector setpoints;
setpoints.resize(jnts);

// enable velocity control mode
vector<int> modes(jnts,VOCAB_CM_VELOCITY);
mod->setControlModes(modes.data());

while (1) { // repeat forever
Vector *target = targetPort.read(); // read a target
Expand Down

0 comments on commit d6f4d4d

Please sign in to comment.