[Discourse.ros.org] [Next Generation ROS] Using ClassLoader with nodes and non-default constructors

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Discourse.ros.org] [Next Generation ROS] Using ClassLoader with nodes and non-default constructors

Florian Friesdorf via ros-users


I'm playing with the composition API in ROS2 (beta1) and ClassLoader::createInstance function takes only a string as a parameter (the name of the class being created). I need to pass a couple of other parameters to the constructor of my class - is there a way to do that?





---
[Visit Topic](https://discourse.ros.org/t/using-classloader-with-nodes-and-non-default-constructors/2018/1) or reply to this email to respond.


If you do not want to receive messages from ros-users please use the unsubscribe link below. If you use the one above, you will stop all of ros-users from receiving updates.
______________________________________________________________________________
ros-users mailing list
[hidden email]
http://lists.ros.org/mailman/listinfo/ros-users
Unsubscribe: <http://lists.ros.org/mailman//options/ros-users>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Discourse.ros.org] [Next Generation ROS] Using ClassLoader with nodes and non-default constructors

Florian Friesdorf via ros-users


The best way to do so currently is have your object read parameters from the rosparam server, and before you instantiate your object, set those params.





---
[Visit Topic](https://discourse.ros.org/t/using-classloader-with-nodes-and-non-default-constructors/2018/2) or reply to this email to respond.


If you do not want to receive messages from ros-users please use the unsubscribe link below. If you use the one above, you will stop all of ros-users from receiving updates.
______________________________________________________________________________
ros-users mailing list
[hidden email]
http://lists.ros.org/mailman/listinfo/ros-users
Unsubscribe: <http://lists.ros.org/mailman//options/ros-users>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Discourse.ros.org] [Next Generation ROS] Using ClassLoader with nodes and non-default constructors

Florian Friesdorf via ros-users
In reply to this post by Florian Friesdorf via ros-users


I think the typical pattern is to create a default constructor for your plugin, but use a separate initialize(...) method to feed arguments.

See plugin definition packages such as nav_core in the navigation stack, and controller_interface in ros_control.





---
[Visit Topic](https://discourse.ros.org/t/using-classloader-with-nodes-and-non-default-constructors/2018/3) or reply to this email to respond.


If you do not want to receive messages from ros-users please use the unsubscribe link below. If you use the one above, you will stop all of ros-users from receiving updates.
______________________________________________________________________________
ros-users mailing list
[hidden email]
http://lists.ros.org/mailman/listinfo/ros-users
Unsubscribe: <http://lists.ros.org/mailman//options/ros-users>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Discourse.ros.org] [Next Generation ROS] Using ClassLoader with nodes and non-default constructors

Florian Friesdorf via ros-users
In reply to this post by Florian Friesdorf via ros-users


In general as mentioned by @TheDash and @Paul_Bovbel you must defer your initialization until later in the cycle.

To support loading components not known about at compile time we must require a standard uniform API of all components for the loader to interact with. Almost all plugin systems work with a minimum common API (often implemented in C++ as a base class) and a registration/discovery mechanism for the loader to find available plugins. Sometimes the registration/discovery also includes descriptions etc.

Using parameters is the recommended way to configure nodes as this is the way that configuration can be made at run time by users.

With respect to ROS 2. I'd suggest making sure you're familiar with our [overview of composition](https://github.com/ros2/ros2/wiki/Composition) as well as our vision of a [managed node](http://design.ros2.org/articles/node_lifecycle.html) which adds a standard lifecycle on top which we can provide standardized tooling for managing ROS systems. This also gives a standard way to do initialization, configuration, and other transitions.

For comparison you can also explore the [nodelet API](http://wiki.ros.org/nodelet) in ROS1.





---
[Visit Topic](https://discourse.ros.org/t/using-classloader-with-nodes-and-non-default-constructors/2018/4) or reply to this email to respond.


If you do not want to receive messages from ros-users please use the unsubscribe link below. If you use the one above, you will stop all of ros-users from receiving updates.
______________________________________________________________________________
ros-users mailing list
[hidden email]
http://lists.ros.org/mailman/listinfo/ros-users
Unsubscribe: <http://lists.ros.org/mailman//options/ros-users>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Discourse.ros.org] [Next Generation ROS] Using ClassLoader with nodes and non-default constructors

Florian Friesdorf via ros-users
In reply to this post by Florian Friesdorf via ros-users


Thanks everyone. Still wondering how could I possibly configure things such as node name or whether I should use intra-process communication. These values are required at the construction time, so initialization function is out of the question. Not sure if I can use parameters for those ...





---
[Visit Topic](https://discourse.ros.org/t/using-classloader-with-nodes-and-non-default-constructors/2018/5) or reply to this email to respond.


If you do not want to receive messages from ros-users please use the unsubscribe link below. If you use the one above, you will stop all of ros-users from receiving updates.
______________________________________________________________________________
ros-users mailing list
[hidden email]
http://lists.ros.org/mailman/listinfo/ros-users
Unsubscribe: <http://lists.ros.org/mailman//options/ros-users>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Discourse.ros.org] [Next Generation ROS] Using ClassLoader with nodes and non-default constructors

Florian Friesdorf via ros-users
In reply to this post by Florian Friesdorf via ros-users


Node name can be configured via rosparam strictly. e.g

ros.init_node(ros.get_param("my_node/prefix") + "mynode");

I can't remember the exact API calls off the top of my head, but that's the general approach. Above syntax wont work directly FYI, is what I'm trying to say.





---
[Visit Topic](https://discourse.ros.org/t/using-classloader-with-nodes-and-non-default-constructors/2018/6) or reply to this email to respond.


If you do not want to receive messages from ros-users please use the unsubscribe link below. If you use the one above, you will stop all of ros-users from receiving updates.
______________________________________________________________________________
ros-users mailing list
[hidden email]
http://lists.ros.org/mailman/listinfo/ros-users
Unsubscribe: <http://lists.ros.org/mailman//options/ros-users>
Loading...