Calling a local python script from a python launch file
Using Foxy on Ubuntu 20.04:
I have a bringup package with multiple launch files and I am trying to put some common functionality (a few methods) in a utils.py python script.
launch directory: launch_file_1.py launch_file_2.py utils.py __init__.py # added because some answers to similar questions on the net suggested it could help. It didn't...
I haven't find any way to import my utils.py methods in the launch files but Python3 makes it very difficult to import relative modules and added a lot of rules.
I tried multiple syntaxes:
from utils import method1
# fails with: ModuleNotFoundError: No module named 'utils'
# Probably fails because this is not an installed module
from .utils import method1
# fails with: ImportError: attempted relative import with no known parent package
from .utils.py import method1
# fails with: ImportError: attempted relative import with no known parent package
It would be bizarre not to allow for such basic functionality. As a workaround, I am copying all my helper methods to every single launch file...
Have the same exact question. Someone please respond.