This website uses browsing/session and functional cookies to ensure you get the best experience. Learn More

Timestamps in YARP

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

Due to popular demand :-), YARP messages can now have timestamps.

Contents

Programmatic interface

The Port and BufferedPort classes have two new methods

  • setEnvelope(object)
  • getEnvelope(object)

The setEnvelope() method gives the port an object which will be transmitted along with the next message on the next call to write(). Any port that receives that message using read() can recover that object by calling getEnvelope().

The envelope object can be of any type that implements the Portable interface correctly. There is a new class that you may find useful:

  • yarp::os::Stamp

which stores a time (in fractional seconds) and a sequence number. This class works fine as an envelope object. So does Bottle.

YARP takes no responsibility

In general, the YARP library takes no responsibility for the content of envelope objects. It only concerns itself with propagating them. The "yarpdev" program will attach timestamps if requested -- see next section.

The grabber device

The grabber device (corresponding to ServerFrameGrabber) has been extended to offer timestamps using the yarp::os::Stamp class. This is for your convenience -- of course you can use any kind of envelope you like if you find that you need something more complicated.

Timestamps are turned on with the "--stamp" option, for example:

  yarpdev --device test_grabber --width 2 --height 2 --name /grabber --period 0.5 --stamp

This creates a fake image source producing tiny 2x2 images every half second on a port called "/grabber", with timestamps attached. The "zero" time is arbitrary. See next section for an example of how to view these timestamps.

yarp read

The "yarp read" command has been extended to make it easier to view envelopes. Just add the "envelope" tag as follows:

 yarp read /read envelope

To read the output of the fake image source created earlier with:

 yarpdev --device test_grabber --width 2 --height 2 --name /grabber --period 0.5 --stamp

we can just do:

 yarp read /read envelope /grabber

The output should be something like:

 Port /read listening at tcp://5.255.112.226:10022
 yarp: Receiving input from /grabber to /read using tcp
 10 4.986223 [mat] [rgb] (3 16 8 2 2) {255 0 0 255 0 0 0 0 0 0 0 0 0 0 0 0}
 11 5.48615 [mat] [rgb] (3 16 8 2 2) {0 0 0 0 0 0 0 0 255 0 0 255 0 0 0 0}
 12 5.98607 [mat] [rgb] (3 16 8 2 2) {255 0 0 255 0 0 0 0 0 0 0 0 0 0 0 0}
 13 6.485993 [mat] [rgb] (3 16 8 2 2) {0 0 0 0 0 0 0 0 255 0 0 255 0 0 0 0}
 ...

The first number is the sequence number, the second is time in seconds.

Personal tools
Namespaces

Variants
Actions
Navigation
Print/export
Toolbox