Instance of class is garbage in callback

asked 2015-03-05 09:03:48 -0500

Robocop87 gravatar image

Hey everyone,

I have run into a peculiar error. I have two C++ classes, one which serves as the main class and lasts for the duration of the node, and one which is a utility class and is created and deleted multiple times during the life cycle of the node. Both of these classes create publishers and subscribers.

In the constructor of the utility class a new nodehandle is created and a few publishers and subscribers are created. In the destructor of the utility class shutdown() is called on each of the publishers and subscribers as well as the nodehandle. (i.e. myPublisher.shutdown(); myNodeHandle.shutdown();)

On the first instantiation of the utility class everything works as expected. When the class is destroyed and re-allocated in the main class, something funny happens. In the callbacks of the utility class, every member variable is garbage. Integers return nonsensical values, other data types are null, and trying to use a publisher results in an invalid publisher error.

Can anyone tell me what's going on here?

I can provide code if there is something specific you need to see, but it is mostly standard publisher/subsciber code and theres not much to show.

edit retag flag offensive close merge delete