I am interfacing `ROS2` with native `RTI DDS Connector` for python where I am publishing messages in RTI connector and subscribing in ROS2.
I have the following message structure for the message named `DetectedObjectList` :
int16 id
//an array of objects of another message type
DetectedObject[ ] objects
This is interpreted as unbounded sequences in IDL.
another message named `DetectedObject` :
int16 id
string name
int16 x
int16 y
Lets say the topic the are communicating is called **`objects`** and the message type is **DetectedObjectList**
Since the subscriber in ROS2 is subscribing to **id of type int16 and objects of type DetectedObject[ ]** .
How can I publish an object from RTI connector ?
A usual flow in RTI Connector is :
get an instance of the output :
output = connector.getOutput("MyPublisher::MyDataWriter")
and the post an instance :
output.instance.setNumber("id", 5)
output.write()
Now how can I write an object of type `DetectedObject` instead of `setNumber` ?
I don't have experience with ROS, but I'll try to help with the DDS/Connector part.
As far as I know in DDS you cannot specify an unbounded array. You can have unbounded Sequences, but not arrays. So, if you are using a type that looks like this:
or you have an unbounded sequence instead:
Then your connector code will be something like this:
Maybe somebody else can contribute more about the ROS <--> DDS mapping when it comes to unbounded arrays.
I hope this help, Gianpiero
This definitely cleared out the conceptual problem. However I have a question :
Hi Aakash,
Yes, the objects[1] represents the first element of the sequence of your type.
In this code you are filling the elements of an instance, where the type is MyMessage, which elements are a short id and a sequences of DetectedObjects (called objects).
So when you are giving values to objects[1].id, objects[1].name, and so on, you are filling the first element of the sequence.
Is you set objects[2].id you will be giving values to the second element of the sequence of your type.
Does it make sense?
I hope it clarifies you question.
Regards,
Isabel
Thank you for the clarification. I understood it now :)