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

How safe is it to directly modify message member vectors in c++?

asked 2012-10-24 06:50:01 -0500

SuperElectric gravatar image

updated 2014-01-28 17:14:03 -0500

ngrennan gravatar image

I have a custom message class A that contains vectors (of other message classes, but I think that's immaterial).

Is it safe to mess around with the vectors directly, by resizing them, inserting things into them, etc?

My concern is that A's header might contain some metadata about A's vector, which becomes out-of-date when I modify A's vector.

-- Matt

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2012-10-24 07:14:52 -0500

Lorenz gravatar image

There is nothing like a message header that contains hidden meta-information in ROS. Modifying message members is save and is even necessary to fill messages before publishing them.

But do not const-cast and modify messages you received in message callbacks.

edit flag offensive delete link more

Question Tools


Asked: 2012-10-24 06:50:01 -0500

Seen: 278 times

Last updated: Oct 24 '12