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

Comment by billmania for From: https://docs.ros.org/api/catkin/html/...Standard ROS practice is to place Python modules under the src/your_package subdirectory, making the top-level module name the same as your package. Python requires that directory to have an __init__.py file, too.Your python library sources are in nodes/ros_moos ; you should move them to src/ros_moos

Next: Answer by ahendrix for I'm using:ROS Melodicubuntu 18.04Python 3.6.9My ROS project name is "ros_moos" and my Python package name is "ros_moos".My directory structure under ~/catkin_ws/src/ros_moos is:├── CMakeLists.txt ├── launch │   └── ros_moos.launch ├── LICENSE ├── msg │   ├── AuvMove.msg │   ├── AuvPose.msg │   ├── AuvSafety.msg │   └── AuvSystems.msg ├── nodes │   ├── ros_moos │   │   ├── auv_control.py │   │   ├── auv_status.py │   │   ├── __init__.py │   │   ├── moos_ros.py │   │   ├── moos_test.py │   │   └── uuv_moos.py │   └── tests ├── package.xml ├── params │   └── auv_params.yaml ├── README.md ├── requirements.txt └── setup.py setup.py contains:from setuptools import setup from catkin_pkg.python_setup import generate_distutils_setup setup_args = generate_distutils_setup( version="0.0.1", packages=['ros_moos'], package_dir={'': 'src'}) setup(**setup_args) In the CMakeLists.txt I have catkin_python_setup() enabled. I build the project with "catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python3" and there are no errors.roslaunch can find my ROS package and start my two Python nodes, auv_control.py and auv_status.py. rostopic and rosmsg can find the definitions for AuvPose and the other messages.The problem is the other Python modules, moos_ros.py and uuv_moos.py are NOT installed into the /devel/ environment and auv_status.py can't import those modules when started by roslaunch.According to https://docs.ros.org/api/catkin/html/... and https://docs.ros.org/api/catkin/html/... I've done what's required.Is this a known issue or need I do something more?
$
0
0
A few paragraphs earlier in that same document one can find "Standard ROS practice is to place all executable Python programs in a package subdirectory named nodes/ or scripts/." In my project, nodes/ros_moos/auv_status.py is a Python executable program used as a ROS node by roslaunch. Does it belong under nodes or src? nodes/ros_moos/uuv_moos.py is only a Python module and not a ROS node. It's imported by auv_status.py. Must it and its ilk be moved to src/ros_moos and an __init__.py added to src/ros_moos? The following still doesn't make moos_ros.py and uuv_moos.py import-able. ├── nodes │   ├── ros_moos │   │   ├── auv_control.py │   │   ├── auv_status.py │   │   ├── __init__.py │   │   └── moos_test.py │   └── tests ├── package.xml ├── params │   └── auv_params.yaml ├── README.md ├── requirements.txt ├── setup.py └── src └── ros_moos ├── __init__.py ├── moos_ros.py └── uuv_moos.py

Viewing all articles
Browse latest Browse all 4

Trending Articles



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