Output your target

From Wiki for iCub and Friends
Jump to: navigation, search

We ask that when you have code that picks a visual target, you create an output port that transmits the position of that target.

The output format

The port can output an os::Bottle or sig::Vector, with the following contents (all "double" floating point values)

 confidence level - from 0.0 (no target) to 1.0 (good target)
 x coordinate - in pixels
 y coordinate - in pixels
 target width - in pixels - estimate of horizontal scale of target
 target height - in pixels - estimate of vertical scale of target
 image width - in pixels - total width of image
 image height - in pixels - total height of image

For example, you could send such an output with:

 BufferedPort<Bottle> outPos;
 Bottle& bot = outPos.prepare();
 bot.clear(); // port may recycle objects we sent previously, important to clear them


 BufferedPort<Vector> outPos;
 Vector v(7,0.0);
 v[0] = confidence;
 v[1] = x;
 v[2] = y;
 v[3] = dx;
 v[4] = dy;
 v[5] = image.width();
 v[6] = image.height();
 Vector& out = outPos.prepare();
 out = v;

Both these choices produce the same output on the network, and you can see that by connecting them to a "yarp read" process.

Where to send your output

Please call your output:


(the name isn't actually important, just be different to anyone else to avoid conflict).

You can test your output by doing:

 yarp read ... /USERNAME/target

(the "..." asks YARP to assign a random name to your reading port).

When you're happy with that, wait for your turn to control the robot. Please ask an assistant to look at your messages and see if everything looks ok.

Then connect to the control port, at /icub/target.

 yarp connect /USERNAME/target /icub/target

You should then see the robot head move.