How to import Python modules to my node?
I am using ROS Kinetic with Ubuntu 16.04 LTS.
I am trying to connect two ROS nodes (publisher/subscriber, both of them). In one Python node, I am trying to use some modules I had already programmed, which are embedded in pyib2c module.
import pyib2c
This module also imports some Python modules. When I try to run my node, I receive the following error:
ImportError: cannot import name XXXXX , where XXXXX are the modules imported by my pyib2c module.
I have already uncommented the * catkin_python_setup() * in the CMakeList of my package. The setup.py is:
from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup
# fetch values from package.xml
setup_args = generate_distutils_setup(
packages=['pyib2c'],
package_dir={'': 'src'})
setup(**setup_args)
I have also created a __init.py__ file which is:
from . import tabulate
from . import pyib2c
My Python node, the module pyib2c, the __init.py__ and the setup.py are them all at the same level in my_package/src. However, it turns out to display the same mistake if I keep the pyib2c in a src folder.
How can I make my node import the modules I need?
Have you compiled your package? In order for you to use the module in your package
catkin
needs to run yoursetup.py
.Yes, I have run catkin_make at my catkin_ws and it works perfectly. The trouble comes at the point of rosrun my node.