[ros-users] [Discourse.ros.org] [General] ROS 2 Ardent Apalone released
ros.discourse at gmail.com
Tue Jan 2 21:33:00 UTC 2018
[quote="nathan.jackson, post:4, topic:3371"]
Can someone please explain or link to an example explaining this part of the release notes?
Different initialization options for message data structures in C++
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: http://design.ros2.org/articles/generated_interfaces_cpp.html#constructors).
Let me know if you need more information.
[Visit Topic](https://discourse.ros.org/t/ros-2-ardent-apalone-released/3371/5) or reply to this email to respond.
More information about the ros-users