Ask Your Question
1

What is the correct way to use ROS2 composition and the class_loader for node classes which take arguments in the constructor?

asked 2017-05-14 05:31:29 -0500

edw gravatar image

updated 2017-05-14 09:09:36 -0500

Referring to the demos in the composition package in ROS2:

https://github.com/ros2/ros2/wiki/Com...

https://github.com/ros2/demos/tree/ma...

I believe that the examples all assume nodes which pass no arguments to the constructor. (This appears to be hard-coded in the class_loader code in ${ROS_WS}/install/include/class_loader/meta_object.h for example.)

As a simple example, if I want to extend the demo to use a single publisher and two subscribers, each with two different names, what is the preferred way to do this? Can the node name(and other variables) be set after construction? Can the class_loader be extended to take arguments?

In practice, I will have two or more nodes that are initialized using two different config files at runtime. The code for those nodes is identical and the node_name, initialization filenames etc. are set at runtime and create two unique nodes doing different things to the data that is subscribed to depending on the models that are read in at initialization.

Thanks.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-04-19 12:48:06 -0500

emersonknapp gravatar image

You are correct that there is an explicit hardcoded assumption that Components must be default-constructible. The intention is that you do not use arguments for configuration, and instead use ROS parameters for this purpose, rather than constructor or command-line arguments.

edit flag offensive delete link more

Comments

You are correct that there is an explicit hardcoded assumption

should that be implicit?

gvdhoorn gravatar image gvdhoorn  ( 2021-04-19 12:55:00 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

3 followers

Stats

Asked: 2017-05-14 05:31:29 -0500

Seen: 504 times

Last updated: Apr 19