ros / common_msgs

Commonly used messages in ROS. Includes messages for actions (actionlib_msgs), diagnostics (diagnostic_msgs), geometric primitives (geometry_msgs), robot navigation (nav_msgs), and common sensors (sensor_msgs), such as laser range finders, cameras, point clouds.
http://wiki.ros.org/common_msgs
179 stars 191 forks source link

Array Length in Image, CameraInfo, CompressedImage etc. #134

Closed vpenades closed 5 years ago

vpenades commented 5 years ago

I am trying to read some ROS Bag messages (using my own parser), and I am having trouble understanding how arrays are interpreted:

In CameraInfowe have:

float64[] D
float64[9] K
float64[9] R

It appears to me that when an array has undefined size, it means the data in the file is preceded by an uint32 length, as it happens with D, and when a fixed size is specified, like K and R, the values are stored directly.

Then, Imagehas a uint8[] data; field, which states in the comment that it doesn't have a preceding length.

Does this also apply to the uint8[] data; of CompressedImage?

What is the general rule to handle arrays when length is not defined in the msg? Is there a way to tell which ones need to read the length beforehand and which don't?

tfoote commented 5 years ago

Your question seems to be about the serialized form. That would be more relevant for roscpp_serialization and the serialization overview: http://wiki.ros.org/roscpp/Overview/MessagesSerializationAndAdaptingTypes

If you have more questions please ask them on https://answers.ros.org