Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to build a persistent hash?

I want to have a node that subscribes to some messages and builds from that a data structure (which I would think of as a hash or dictionary). I would like the available keys not to be hardwired into the message definitions.

So calling this node the notekeeper, who subscribes to notes, I would want something like this:

note "name", "robot1" note "mood", "happy" note "emotion", 12

And then subsequently I would like other nodes using the notekeeper as a service (perhaps) asking

get_note "mood" and have it return "happy"

Do you follow? What's a good ROSish way of doing this?

How to build a persistent hash?

I want to have a node that subscribes to some messages and builds from that a data structure (which I would think of as a hash or dictionary). I would like the available keys not to be hardwired into the message definitions.

So calling this node the notekeeper, who subscribes to notes, I would want something like this:

note "name", "robot1" note "mood", "happy" note "emotion", 12

And then subsequently I would like other nodes using the notekeeper as a service (perhaps) asking

get_note "mood" and have it return "happy"

Do you follow? What's a good ROSish way of doing this?

Followup

My question comes from the fact that I am not sure of the process model that is involved and what kind of variable, object instance, global, survives while waiting for a subscription callback. If you store it in a dict as you recommend, where should that go, as an instance of a class created in the "main" program, in a "global" or where? Obviously it will not survive a crash of the node (or the robot).