Hello
I've searched across to find a good example that explains how to pass the data generated by another application to the publisher. I went over the examples provided in rti-workspace/5.2.3/examples/connext_dds but i'm not sure how to do this.
Basically, I have one application that continuously genrates the coordinates (say x,y,z) and I would like to pass this data as it being generated to the publisher. I can generate IDL file with the struct that contains the coordinates, but then I'm not sure how should I refer this data in write() ?
Any example would be appreciated, thank you!
Hi Stan,
Let's assume that you are using C++ (we could port this to other languages), that you have a
Coordinatesclass like the following, and that the value of x, y, an z is constantly being updated.class Coordinates { public: Coordinates(int x, int y, int z) : x_(x), y_(y), z_(z) { } int x() { return x_; } int y() { return y_; } int z() { return z_; } // Omitting setters private: int x_; int y_; int z_; };If you want to pass the value of x, y, and z to the write() method you will have to do the following:
// coordinates.idl struct Coordinates { long x; long y; long z; };... // Main loop for (count=0; (sample_count == 0) || (count < sample_count); ++count) { printf("Writing coordinates, count %d\n", count); // Modify the data to be sent here instance->x = coordinates.x(); instance->y = coordinates.y(); instance->z = coordinates.z(); retcode = waitsets_writer->write(*instance, instance_handle); if (retcode != DDS_RETCODE_OK) { printf("write error %d\n", retcode); } NDDSUtility::sleep(send_period); }Please, let me know if this helps.
Thanks,
Fernando,