ROS 2 Ardent Apalone released

In ROS1, the structs/class members that were generated for messages were always value-initialized. While this is convenient, and prevents users from accessing uninitialized memory by accident, it can also be a waste of time. For example, a camera driver may construct an Image message with a large number of zeros in it, and then immediately overwrite the zeros with the actual image data. There was no need to spend the time to set the zeros, since it was going to be immediately overwritten.

In ROS2, we now have the option to control that behavior. The default behavior is like ROS1; all struct members are value-initialized. However, during message class construction, it is possible to pass an initializer to the class to control how members are initialized (see the documentation here: Generated C++ interfaces).

Let me know if you need more information.