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

Maximum samples and unbounded type length in ROS2 DDS entity

asked 2018-08-01 11:33:32 -0600

aks gravatar image

updated 2018-08-01 11:34:04 -0600

This is an extension to this question.

I ran a ROS2 demo_py taker and observed the RTI admin console to know more about the data types and QoS.

As you can see in the attached image, it has only one member of type String but the max size of the string here is : 2147483647 bytes which looks a bit strange to me. Also, if you look at the Max Samples, they are also quite big.

Questions :

  1. Is this the normal memory allocation of a data type ?
  2. How are the maximum samples calculated ? Are these based on the size of the datatype ? RTI_AdminConsole

ps : i know it is not ok to post a picture but i think it gives a much clearer view of the problem.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2018-08-01 12:32:51 -0600

marguedas gravatar image

RTI is using RTI_INT32_MAX as the maximal size for string when support for unbounded string is enabled. As mentioned in answer from https://answers.ros.org/question/2992... the memory is allocated for 0 elements by default and then reallocated as messages come in. So if you look at your memory usage it should not allocate 2GB of RAM to store the string. Similarly, if you look at the packets sent on wireshark or similar tool you will see that only the characters present in the string will be serialized and sent.

The max sample size is provided by the <TYPE>_Plugin_get_serialized_sample_max_size_ex Connext generated function. In this case it always returns: RTI_CDR_MAX_SERIALIZED_SIZE.

You can find the connext generated code in your build folder under <PACKAGE_NAME>/rosidl_typesupport_connext_cpp

For the std_msgs/String message it will be the files: rosidl_typesupport_connext_cpp/std_msgs/msg/dds_connext/String_Plugin.cxx rosidl_typesupport_connext_cpp/std_msgs/msg/dds_connext/String_.cxx

edit flag offensive delete link more

Comments

@marguedas : thanks for the explanation.But I still dont get why it allocates such a huge memory for a string ?

aks gravatar image aks  ( 2018-08-01 13:00:56 -0600 )edit

It does not allocate that memory for a string.

RTI's definition of an unbounded string is a string that can be "up to" RTI_INT32_MAX characters. But the allocated memory is relative to the size of the string that is sent

marguedas gravatar image marguedas  ( 2018-08-01 13:37:26 -0600 )edit

Then what is this memory for and from where is it coming ? I have no clue

aks gravatar image aks  ( 2018-08-01 13:38:52 -0600 )edit

Can you please provide an example of 2GB of memory being allocated?

marguedas gravatar image marguedas  ( 2018-08-01 13:40:40 -0600 )edit

To interface ROS2 and native RTI Connext, the type should be similar, since ROS2 gives me a 2GB string, I need to have the same on the RTI native side as well which creates a problem. That is why in first place my quesion, where does this size come from ? @marguedas

aks gravatar image aks  ( 2018-08-01 13:43:36 -0600 )edit

then maybe I understood wrong, what does 2147483647 represent here ? Isnt it the size of the string ?

aks gravatar image aks  ( 2018-08-01 13:45:06 -0600 )edit

ahh..ok...so 2147483647 is the max size of int32 and this is what it represents since RTI interprets unbounded string as max value of Int32 ? Am I right ?

aks gravatar image aks  ( 2018-08-01 13:55:50 -0600 )edit

Yes. RTI interprets an unbounded sting as a string that can have a size between 0 and RTI_INT32_MAX (2147483647)

marguedas gravatar image marguedas  ( 2018-08-01 13:58:56 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-08-01 11:33:32 -0600

Seen: 751 times

Last updated: Aug 01 '18