Send message with dictionary of lists Python

2 posts / 0 new
Last post
Offline
Last seen: 5 years 2 months ago
Joined: 08/06/2019
Posts: 1
Send message with dictionary of lists Python

I am using RTI to convert my ROS2 action messages into DDS messages. I receive a dictionary of lists like the following:

path = {
    "length": 0.0,
    "x": np.array([]),
    "y": np.array([]),
    "theta": np.array([]),
    "kappa": np.array([]),
    "x_truck": np.array([]),
    "y_truck": np.array([]),
    "theta_truck": np.array([]),
    "alpha": np.array([]),
    "direction": np.array([]),
    "direction_change_arc_lengths": np.array([]),
    "success": False
}

I know how to create simple message types using the xml format like:

<struct name="GoalLocation" extensibility="extensible">
    <member name="x" type="long"/>
    <member name="y" type="long"/>
    <member name="yaw" type="long"/>
</struct>

But I have not being able to find how to create my message where several attributes are lists of undefined size in Python. I found https://community.rti.com/static/documentation/connext-dds/5.2.3/doc/manuals/connext_dds/html_files/RTI_ConnextDDS_CoreLibraries_UsersManual/Content/UsersManual/Creating_User_Data_Types_with_Extensible.htm but does not include the case where I do not know the size in advanceas this one can change between different executions

Organization:
Offline
Last seen: 1 week 1 day ago
Joined: 04/02/2013
Posts: 196

Sequences are variable-size. The attribute "sequenceMaxLength" specifies the maximum length, not the actual length. You can set a maximum length of 1000 and set only a few elements in each data sample.

Unbounded sequences are also supported, but that requires some additional configuration, and the internal memory management is not as efficient. Let me know if you need unbounded sequence and I can help you with the configuration.