Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 84

Exporting Python Module With Same Name as Package, with srv/msg

$
0
0
**EDIT**: MWE can be found [here](https://github.com/tfurf/rospy-srv-module-test). Per [[1]](http://wiki.ros.org/PyStyleGuide) and [[2]](http://docs.ros.org/groovy/api/catkin/html/user_guide/setup_dot_py.html), I'm trying to export a python module that is the same name as the package: packagename CMakeLists.txt package.xml # catkin_python_setup() setup.py # generate_distutils_setup( ..., packages=['packagename'], ... ) |- src/ |- application.py # import packagename |- packagename/ |- __init__.py |- stuff.py |- ... This works as expected, no problem. However, if I introduce a service message and try to import it: packagename CMakeLists.txt package.xml setup.py |- srv/ |- MySrv.srv |- src/ |- application.py # import packagename |- packagename/ |- __init__.py |- stuff.py |- use_my_service.py # from packagename.srv import MySrv |- ... At runtime I get ImportError: No module named srv It works if I change the name of the exported module: packagename CMakeLists.txt package.xml setup.py # generate_distutils_setup( ..., packages=['notpackagename'], ... ) |- srv/ |- MySrv.srv |- src/ |- application.py # import notpackagename |- notpackagename/ |- __init__.py |- stuff.py |- use_my_service.py # from notpackagename.srv import MySrv |- ... The path in both cases is exactly the same, including $WORKSPACE_ROOT/devel/lib/python2.7/dist-packages And in both cases I can locate the appropriate `pacakgename/srv/_MySrv.py`. In the working case, the output directory structure looks like: devel/lib/python2.7/dist-packages/ |- notpackagename |- __init__.py # Non-empty, dist-utils generated |- packagename |- __init__.py # Empty. |- srv/ |- __init__.py |- _MySrv.py And in the non-working case: devel/lib/python2.7/dist-packages/ |- packagename |- __init__.py # Non-empty, dist-utils generated. |- srv/ |- __init__.py |- _MySrv.py It appears that the generated `__init__.py` for the exported module clobbers the knowledge of the existence of submodules, but I'm not sure, I'm not particularly familiar with how catkin does it's magic for this. Is my expectation for this to work misguided? If it's not supposed to/going to work, what is the preferred method? To prefix the module with `lib`, as in [[3]](https://github.com/ros-drivers/nmea_navsat_driver/tree/indigo-devel) ? * [1] http://wiki.ros.org/PyStyleGuide * [2] http://docs.ros.org/groovy/api/catkin/html/user_guide/setup_dot_py.html * [3] https://github.com/ros-drivers/nmea_navsat_driver/tree/indigo-devel

Viewing all articles
Browse latest Browse all 84

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>