What is the correct way to use ROS2 composition and the class_loader for node classes which take arguments in the constructor?
Referring to the demos in the composition package in ROS2:
https://github.com/ros2/ros2/wiki/Composition
https://github.com/ros2/demos/tree/master/composition/
I believe that the examples all assume nodes which pass no arguments to the constructor. (This appears to be hard-coded in the classloader code in ${ROSWS}/install/include/classloader/metaobject.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.
Asked by edw on 2017-05-14 05:31:29 UTC
Answers
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.
Asked by emersonknapp on 2021-04-19 12:48:06 UTC
Comments
You are correct that there is an explicit hardcoded assumption
should that be implicit?
Asked by gvdhoorn on 2021-04-19 12:55:00 UTC
Comments