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

Create publishers/subscribers dynamically

asked 2014-05-31 08:40:31 -0500

McMurdo gravatar image

How can I create subscribers dynamically?

Please see comment on the answer to this question: programatically create subscribers

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-05-31 11:44:10 -0500

tfoote gravatar image

If you know the datatype(s) ahead of time you can make it happen without too much problem.

In Python if you do not know the datatypes you can attempt to import the modules at run time. There have also been demonstrations of dynamic code generation based on the message definition passed during the connection negotiation. The latter approach is more generic but you will have to dig deep inside the modules away from the supported API. The former has the limitation of only working if the messages are already generated on the receiving machine.

I would not recommend attempting this in c++

edit flag offensive delete link more

Comments

Thank you for your reply. I have been trying to think how a truly dynamic subscription/publication can happen. I am not going to try this in C++. I think it might end quite disastrously. I am using python and I am trying a simple workaround for now (I can describe this in detail if needed).

McMurdo gravatar image McMurdo  ( 2014-05-31 11:51:06 -0500 )edit

I was also looking at rosbridge_library, which is exactly what I need: Send the topic name, topic type as strings and establish a sub/pub. The main aim of what I am trying to do is create a highly easy to use, plug and play multi-master ROS using PEIS. I am sure it is an astronomical task

McMurdo gravatar image McMurdo  ( 2014-05-31 11:58:04 -0500 )edit
1

@McMurdo, did you manage to implement something resembling "dynamic subscription/publication"? Can you give some details? I'm trying to do something similar.

pedrocaldeira gravatar image pedrocaldeira  ( 2016-10-17 11:58:03 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-05-31 08:40:31 -0500

Seen: 1,800 times

Last updated: May 31 '14