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).
Followup - I usually use a python class like in https://github.com/lucasw/simple_sim_... , the dict would be created in the __init__ and the subscribe and service callbacks would be class methods. It's not more 'rosish' than any other approach but it works.
If you want to save and reload the data the easiest way is probably putting it into a yaml file https://stackoverflow.com/questions/1...