ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Uncommenting generate_messages(...) breaks import of (non-ROS) Python module

asked 2018-02-22 19:23:10 -0500

mightimaus gravatar image

Yesterday I created the first custom message for my ROS package, and it broke a Python import that I was using:

from oars_gb.libraries.dynamixels.dynamixel_controller import DynamixelController

Yields:

Traceback (most recent call last):
  File "/home/kyle/oars/catkin_ws/src/trans-atlantic-sailboat/oars_gb/nodes/acting/motor_controller.py", line 4, in <module>
    from oars_gb.libraries.dynamixels.dynamixel_motor import DynamixelMotor
ImportError: No module named libraries.dynamixels.dynamixel_motor

To me, it seems as though it's finding the oars_gb module (my ROS package), but not the submodules...

I traced it down to uncommenting generate_messages(...) in CMakeLists.txt:

## UNCOMMENTING THIS (LIKE IT IS NOW) BREAKS THE IMPORT
generate_messages(
  DEPENDENCIES
  std_msgs
#  geometry_msgs
#  sensor_msgs
)

I can still import the module by running from oars_gb.libraries.dynamixels.dynamixel_motor import DynamixelMotor in a Python interpreter (with PYTHONPATH set accordingly, as it should be for ROS).

Also, I don't know if this helps to provide any clues, but commenting out generate_messages(...) after I've broken it and rerunning catkin_make isn't enough to fix the problem. I have to delete catkin_ws/devel and then run catkin_make again.

The full repo is available here.

Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-02-23 17:55:58 -0500

mightimaus gravatar image

I determined the problem was that the Python module name (oars_gb, the name of the folder in my repo) was conflicting with the ROS package name. When I uncommented generate_messages(...), it generated a Python module in devel/oars_gb with my custom message, which is where it then started looking for the libraries folder as well.

To fix it, I renamed the folder in my repo to oars_gb_pkg.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2018-02-22 19:23:10 -0500

Seen: 61 times

Last updated: Feb 22 '18