<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="gmail_quote"><div>Yes, exactly. i.e. sharing a large object between publisher and subscriber(s) and you want to avoid any copying or recreation of the object. The publisher is continually updating the large object and the subscribers don't want to get caught by an update in the middle of reading. Is there perhaps a better approach to this? How do the guys in the image pipeline handle the sending of big objects - they simply recreate a new object every time they want to send one?</div>


<div> </div></div></blockquote><div><br></div><div>If you actually want the subscribers reading from a shared store, I'd say pub/sub is not really the way to go.  If you want each message to be able to be processed by part of your pipeline (like with images, point clouds, etc.), you need to allocate a new message for each set of new data.</div>

<div><br></div><div>That said, if you really wanted to do it that way, it's possible you could write a templated wrapper class that you adapted as a ROS message, something like:</div><div>template<typename M></div>

<div>class MutexedMessage</div><div>{</div><div>  boost::mutex mutex;</div><div>  boost::shared_ptr<M const> msg;</div><div>};</div><div><br></div><div>If this was adapted as a roscpp message (<a href="http://www.ros.org/wiki/roscpp/Overview/MessagesSerializationAndAdaptingTypes">http://www.ros.org/wiki/roscpp/Overview/MessagesSerializationAndAdaptingTypes</a>), and you published/subscribed with shared_ptrs to it you'd get essentially what you're asking.  I don't recommend it as a solution though.</div>

<meta http-equiv="content-type" content="text/html; charset=utf-8"><div><br></div><div>Josh</div></div>