What is the recommended way to publish name-value pairs in ROS using existing message types?

asked 2021-04-05 14:08:44 -0500

cybodroid gravatar image

I am interested in publishing messages of following kind:

OPTION 1:

{{'robot1', 2.0}, {'robot2', 2.1}, {'robot3', 2.2}, ...}

OPTION 2:

{ {'robot1', 'robot2', 'robot3', ... }, {2.0, 2.1, 2.2, ... }}

I may not know how many robots I have in the beginning.

Is there an already standard ROS message that I can use to encode the above messages?

I know that another feasible option can be custom ROS messages but currently I am looking already available ROS message types.

edit retag flag offensive close merge delete

Comments

1

I'm not aware of a generic key-value message.

To avoid an xy-problem, could you describe what it is you're trying to communicate?

Publishing dictionaries (to use the Python terminology) of strings and numbers does not really align well with the "always use messages with appropriate semantics" best-practice we try to adhere to in ROS.

gvdhoorn gravatar image gvdhoorn  ( 2021-04-06 02:14:18 -0500 )edit

Ah, I provided an example but it seems it is not clear. I am trying to publish robot speed information for all vehicles. In my case, I produce new vehicles randomly after every n seconds, and some robots disappear after every m seconds. Note that in my case robots are not actual robots but they are just algorithms, I am not spawning in a real sense in Gazebo. So if you ask why not associate a model plugin, I don't have a model, so no plugin, my robot is just a class described via kinematic equations. After every n time step, I instantiate a new object, assign, initial pos, their state evolves for a given duration and then they disappear after m seconds. so if I want to publish the speed of dynamically created kinematic robots, I thought the best choice name-value pairs. The name represents robot id, value is speed.

cybodroid gravatar image cybodroid  ( 2021-04-20 16:08:01 -0500 )edit