What is the best practice for housing common class in ROS2 workspace?
Hi all,
I have a python script that has class A
that needs to be accessed by more than two different nodes in two different packages. The functionality of this python class A
does clearly not belong to those two packages. Other than that I wish to import that class just like a normal python library, like this from python_library import A
.
I know that one solution is to create a ros2 python package using --build-type ament_python
in my src
and house that python script without spinning it so that other nodes can import that class A
like this from package_name.package_name.python_script import A
.
My questions are: 1) Are there any solutions or best practices in ROS2 industry for housing a commonly used python script that can be accessible by other nodes? 2) Is the solution that I mentioned above, is a correct way to do it? Because I heard some saying that a package is equivalent to a node, so a package should not house anything other than a node.
Not an answer, but:
this is patently false.
Packages != nodes.
Packages are collections of source files and other resources that happen to exhibit some sort of cohesion when put together. That's all.