ROS callbacks' scope and objects' lifecycles
I am quite new to C++. I know that callbacks with return type of ConstPtr&
are of boost::shared_ptr<const MsgType>
type.
Now, when dealing with callbacks, does one copy or initialize objects by reference? For example, I have a ROS msg with fields int x
and int y[]
. Within the callback, would I copy x and y or initialize references for both of them?
Another thing, how can I know which objects are being copied and which ones are being referenced? Let's say msg->x
and msg->y
are they copied or referenced?
I am not familiar with object lifecycle and RAII at this point, could someone please explain to me in Layman's terms what's going on within ROS callbacks when ConstPtr&
is used?