ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Follow up of answer given at https://answers.ros.org/question/299305/how-is-the-size-of-a-string-allocated-in-ros2-idl/?answer=299311#post-id-299311

The way unbounded string are generated for connext is by using the -unboundedSupport flag of the connext generator: https://github.com/ros2/rosidl_typesupport_connext/blob/d3fd38825c4e460e156718c360886b43b20cc0c8/rosidl_typesupport_connext_cpp/rosidl_typesupport_connext_cpp/__init__.py#L79.

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 
        strings.
        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.