Hey you all I have been scratching at my head for a solid day trying to figure out why this is proving to be such a problem.
So i have a python ROs2 package. Inside my package i have a node trying to reference a submodule i have included. It keeps saying there is no module in package. I have tried to look at the setup.py file and still have had no luck trying to add it as part of the path.
Project Folder
A [package] A nodeFile.py Submodule file-that-i-am-trying-to-call.py
.....
Sos. I havent added anything unique to the setup.py or the package.xml from a typical basic node setup so its pretty blank in terms of that.
Any help would be awesome thank you so much!!
Originally posted by edesta on ROS Answers with karma: 51 on 2020-12-15
Post score: 5
Original comments
Comment by nnmm on 2020-12-16:
What is the path you use for importing that submodule? Do you have an init.py?
Comment by edesta on 2020-12-16:
to import it i said
from Submodule.file_that-i-am-trying-to-call.py
and yes it has an init.py
An interesting thing that happens is when i remove the submodule folder and pull the file in by itself, i can import it like: .file-that-i-am-trying-to-call.py
Comment by nnmm on 2020-12-16:
You shouldn't use dashes in module names, and you shouldn't need the .py extension when importing. I think theoretically it should be import A.Submodule.file_that_i_am_trying_to_call (i.e. with the package name in front). If that doesn't work, please provide a minimal example to reproduce the error.
Comment by edesta on 2020-12-16:
Hi,
So this is for the example i used dashes for the actual implementation i will give you the set of steps to recreate.
I made a python ros2 package just using the customary build instructions I then made a node that includes a submodule for a dstar algorithm implementation.
so the folder (called dstar) contains dstar_algorithm.py and some of its own helper files.
I mispoke when i added a .py at the end of the include it does not have one.
So in my node class, all it does, is it prints hello -- i literally am just testing the ability to pull in different python modules into ros2.
My colcon build passes which is what i expect, but on the run of the node file, it fails on the line that is including the dstar_algorithm .
i import it like from dstar.dstar_algorithm import *
I have also tried: from dstar import dstar_algorithm from .dstar.dstar_algorithm import * import dstar_algorithm
and the list goes on. So i think i need to affect the setup.py or the package.xml not sure
Comment by veilkrand on 2021-03-04:
Have you been able to find a solution? Thanks