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

Auto-generating ROS nodes from another node?

asked 2021-09-09 02:39:16 -0500

Hello,

I am trying to create a program that, when given parameters (such as topic name, msg type, subscriber/publisher specification, publishing freq, etc.) will be able to read the parameters and generate nodes.

http://wiki.ros.org/ROSNodeTutorialC%... Looking at this tutorial, it seems that it is possible to define a ROS Node template. So my question is, is it possible within a single process (in main) to autogenerate multiple nodes from the same template? Say, I create an array of "node_examples" as in the tutorial and just substitute different names and parameters to each of them and then run them simultaneously?

Thank you in advance!

edit retag flag offensive close merge delete

Comments

1

While anything is possible (as long as you put sufficient effort and time into it), could you provide some context, describe your motivation?

Many of the "parameters" you mention sound like actual parameters (ie: ROS parameters), so they would not need to be part of a template, as any node can read them at runtime, during initialisation. It is even possible to create subscribers which can accept any message type. But whether that would be a smart thing to do in your case is unclear.

If you could clarify what you're trying to achieve (to avoid an xy-problem), perhaps we can offer a simpler solution than having to resort to code-generation.

gvdhoorn gravatar image gvdhoorn  ( 2021-09-09 02:56:29 -0500 )edit

@gvdhorn So, I am trying to create a "factory" to try and measure the performance of a ROS system, by measuring various parameters (such as latency, memory consumption) of the system as a whole (system is defined via a topology, which my program would then read and substitute the necessary parameters into the "factory"). I am inspired by this work https://github.com/irobot-ros/ros2-pe...

And would love to try and make something similar but for original ROS.

sejego gravatar image sejego  ( 2021-09-09 03:22:29 -0500 )edit
1

system is defined via a topology

for this you could probably get away with remapping, which wouldn't need any code changes. Or specify the topology using actual ROS parameters (in a dict or list).

So, I am trying to create a "factory" to try and measure the performance of a ROS system, by measuring various parameters (such as latency, memory consumption)

if you're not interested in measuring (de)serialisation performance (which would be independent of topology I believe), then generic subscribers would probably work. Or you could even just standardise on a standard message type, much like the repository you linked does. It just shuffles around an array of bytes in a ROS message. The message type doesn't change, only the size of the array.

Things like publication frequency, number of subscribers, etc would also not necessarily need code changes -- although remapping would probably become harder with ...(more)

gvdhoorn gravatar image gvdhoorn  ( 2021-09-09 03:35:56 -0500 )edit
1

Note: I'm not saying you shouldn't use code-generation.

But it will require more infrastructure and custom work than implementing a single, parameterisable node which reads its configuration from the ROS parameter server.

Perhaps you could ask iRobot why they decided to use code-generation in their case.

Btw: have you looked around for existing implementations of this idea in ROS 1? Seeing as ROS 1 has been around for more than 10 years now, I'd be surprised if this hasn't been done before.

gvdhoorn gravatar image gvdhoorn  ( 2021-09-09 03:36:42 -0500 )edit

I think you are right here, I should ask iRobot some of these questions. And I believe your idea of creating a parametrisable node makes also sense, I think it is simpler and for sure will do me well in the beginning. However, I would ask you - is it possible then to, say, create several ROS nodes in a code (say, an array of them with different parameters) and then launch them at once in a single process?

Answering your question about similar implementations - turns out not really! I have done extensive research and managed to found only this article along with the repo of the evaluation for ROS1, however, nothing as extensive as the mentioned repo. I believe there was never a drive to compare ROS1 to anything, but with emerging of ROS2 that utilizes completely new architectural choices this became a popular topic in academia and development?

sejego gravatar image sejego  ( 2021-09-10 04:38:48 -0500 )edit
1

I would probably not start nodes from other nodes, but generate a .launch file (using Python or something).

Then starting the .launch file would be a standard affair.

.launch files support setting parameters, configuring remappings, starting nodes in namespaces, etc, etc.

gvdhoorn gravatar image gvdhoorn  ( 2021-09-10 07:32:23 -0500 )edit

Thank you very much for the answers @gvdhoorn. All the best to you :)

sejego gravatar image sejego  ( 2021-09-10 10:43:59 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-09-10 10:45:28 -0500

According to @gvdhoorn , probably it is better to begin with a .launch file in order to achieve my goal, which I will do.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2021-09-09 02:39:16 -0500

Seen: 277 times

Last updated: Sep 10 '21