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

From your references to size(), I get the feeling that you've been converting 'regular' roscpp based code to rosserial. You might already have realised it, but roscpp == C++, while rosserial is C only. size() is a method on a std::vector. rosserial only uses raw pointers as arrays ..

From your references to size(), I get the feeling that you've been converting 'regular' roscpp based code to rosserial. You might already have realised it, but roscpp == C++, while rosserial is C only. size() is a method on a std::vector. rosserial only uses raw pointers as arrays ..and those don't have any intrinsic size property that you could query. The sizeof(..) trick would work, if those arrays had a static size, but they don't, as you found out. The only way -- that I know of -- is to keep track of what you pass to malloc(..) to init those arrays and use that.

From your references to size(), I get the feeling that you've been converting 'regular' roscpp based code to rosserial. You might already have realised it, but roscpp == C++, while rosserial is C only. size() is a method on a std::vector. rosserial only uses raw pointers as arrays and those don't have any intrinsic size property that you could query. The sizeof(..) trick would work, if those arrays had a static size, but they don't, as you found out. The only way -- that I know of -- is to keep track of what you pass to malloc(..) to init those arrays and use that.

See wiki/rosserial/Overview - Limitations - Arrays for some more info.

According to wiki/rosserial/Overview/Messages:

Also be aware that the arrays in the messages are not defined as vector objects. Thus you have to predefine the array and then pass it as pointer to the message. To determine the end of the array each one has an auto-generated integer companion with the same name and the suffix _length.

From your references to size(), I get the feeling that you've been converting 'regular' roscpp based code to rosserial. You might already have realised it, but roscpp == C++, while rosserial is C only. size() is a method on a std::vector. rosserial only uses raw pointers as arrays and those don't have any intrinsic size property that you could query. The sizeof(..) trick would work, if those arrays had a static size, but they don't, as you found out. out.

The only way -- that I know of -- to know the size of an array for a message that you populate is to keep track of what you pass to malloc(..) to init those arrays and use that.

See wiki/rosserial/Overview - Limitations - Arrays for some more info.

According to wiki/rosserial/Overview/Messages:

Also be aware that the arrays in the messages are not defined as vector objects. Thus you have to predefine the array and then pass it as pointer to the message. To determine the end of the array each one has an auto-generated integer companion with the same name and the suffix _length.

From your references to size(), I get the feeling that you've been converting 'regular' roscpp based code to rosserial. You might already have realised it, but roscpp == C++, while rosserial is C only. size() is a method on a std::vector. rosserial only uses raw pointers as arrays and those don't have any intrinsic size property that you could query. The sizeof(..) trick would work, if those arrays had a static size, but they don't, as you found out.

The only way -- that I know of -- to know the size of an array for a message that you populate is to keep track of what you pass to malloc(..) to init those arrays and use that.

For messages that you receive things are slightly different. See wiki/rosserial/Overview - Limitations - Arrays for some more info.

According that.

And cccording to wiki/rosserial/Overview/Messages:

Also be aware that the arrays in the messages are not defined as vector objects. Thus you have to predefine the array and then pass it as pointer to the message. To determine the end of the array each one has an auto-generated integer companion with the same name and the suffix _length.