ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

We had a similar discussin in-house at our company a while ago.

It is possible to adapt your own c++ types to the pub/sub mechanisms without having to use an ros msg. See here: MessageSerialisationAndAdaptingTypes. I haven't tried this yet, but we've talked about giving it a whirl on the next stage of one of our projects.

There is one further gotcha with regards to sharing large data types. So long as your subscribers don't need to modify the map structure, you can create all your packages as nodelets and pass around your adapted c++ type via pub/sub without doing any copying. However, if your subscribers need to modify the map, then you need to find another solution as subscribers will only ever get a pointer to a const version of the object.

There was a discussion on the mailing list about that, where it was pointed out that this was to help maintain a contract between publisher/subscriber, to make sure that other parts of your program (which, being very modularised, may be very unknown) do not cause problems by modifying your underlying data.

The best way we figured we might avoid copies on a low perf cpu with a map that we wanted modifiable among several modules might be to create them all as libraries, or ros libplugins, tied together by a single manager which stores the map. The manager would then pass a reference to the map to each module at init() time.