Ask Your Question

Maximum Limit of String in ROS2

asked 2018-08-01 07:32:13 -0600

aks gravatar image

I am currently interfacing ROS2 with native RTI DDS Connext through RTI Connector for python.

In my ROS2 node, I have a custom message type which uses header messages from std_msgs. Now the header has a member string frame_id_. When the idl is generated for this msg, the size of the string is allocated as 2147483647 bytes. I can see this in the RTI Admin console. Now to match the Types in native DDS and ROS2, I need to give the same string size in RTI Connext through a QoS.xml file. But the problem is, this is too big a size for RTI to handle and the program crashes.

As a workaround, I modified the header_.idl in ROS2 lying in ROS2_base_ws/install/std_msgs/dds_connext/Header_.idl as string<255> frame_id_ i.e. I limited the max size of this string.

I recompiled it and ran the same node, but it always has the previous size i.e. 2147483647 bytes

Any other workaround ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-08-01 10:41:08 -0600

marguedas gravatar image

Follow up of answer given at

The way unbounded string are generated for connext is by using the -unboundedSupport flag of the connext generator: .

By not passing this flag when generating the connext code it should default to 255 as per their help message

-unboundedSupport Generates code that supports unbounded sequences and 
        This option is not supported in ADA.
        When the option is used the command-line options sequenceSize and
        stringSize are ignored.
        This option also affects the way unbounded sequences are deserialized. 
        When a sequence is being received into a sample from the DataReader's
        cache, the old memory for the sequence will be deallocated and memory
        of sufficient size to hold the deserialized data will be allocated.
        When initially constructed, sequences will not preallocate any 
        elements having a maximum of zero elements.
-stringSize <Unbounded strings size>: Size assigned to unbounded strings
        The default value is 255

Note that based on the help message the size of the string allocated should be 0 and reallocated when needed so you should never reach the point where you allocate 2147483647 bytes.

A maybe easier way to fix your issue is to use the same -unboundedSupport flag when generating code for your native DDS application, this way you don't need to modify either the msg files or the Connext code generation within ROS 2.

edit flag offensive delete link more


@marguedas : Is this file placed in src/ros2/rosidl_typesupport/rosidl_typesupport_cpp/rosidl_typesupport_cpp/ ? If yes, then I dont have the same file as the link you posted.

aks gravatar image aks  ( 2018-08-01 10:58:43 -0600 )edit

Based on the URL it is located at ros2/rosidl_typesupport_connext/rosidl_typesupport_connext_cpp/rosidl_typesupport_connext_cpp/ The exact location can be different based on what version of ROS 2 you are using, my answers assume you are using ROS Bouncy

marguedas gravatar image marguedas  ( 2018-08-01 11:10:01 -0600 )edit

I am using ROS2 Ardent and I dont have any folder as rosidl_typesupport_connext located in ROS2.

aks gravatar image aks  ( 2018-08-01 11:12:26 -0600 )edit

@marguedas : I also posted a continuation to this here. This describes the strange behaviour also in the default examples.

aks gravatar image aks  ( 2018-08-01 11:37:32 -0600 )edit

Yes in ardent this package was located in the rmw_connext repository: ros2/rmw_connext/rosidl_typesupport_connext_cpp/rosidl_typesupport_connext_cpp/

marguedas gravatar image marguedas  ( 2018-08-01 12:04:44 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2018-08-01 07:32:13 -0600

Seen: 331 times

Last updated: Aug 01 '18