rticommunity / connextdds-py

Connext DDS Python API
Other
26 stars 12 forks source link

connextpy flat data array writer #44

Open goksanisil23 opened 2 years ago

goksanisil23 commented 2 years ago

hi,

I'm currently using connextpy, and trying to publish a topic that contains both FLAT_DATA language binding and SHMEM_REF transfer mode. Through RTI Admin Console, I can see that I can write into basic fields of this message ("id" field below), however for some reason, the data I write in the arrays ("attribute.distance" field below) are not showing up.

The IDL file looks like below:

@final
@language_binding(FLAT_DATA)
@transfer_mode(SHMEM_REF)
struct attribute
{
float distance[100]; // [m]
};

@final
@language_binding(FLAT_DATA)
@transfer_mode(SHMEM_REF)
struct myData
{
unsigned short id;
attribute my_attribute;
};

And here's the code snippet where I do the assignment:

out_sample["id"] = 23
out_sample["my_attribute.distance"][0:100] = np.ones((100)),dtype=np.float32)
writer.write(out_sample)

Additionally, making the sample assignment the following way works,

out_sample["my_attribute.distance[0]"] = 1.0