0
$\begingroup$

Rosanswers logo

I'm using:

ROS Melodic

ubuntu 18.04

Python 3.6.9

My 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/howto/format2/installing_python.html#modules and https://docs.ros.org/api/catkin/html/user_guide/setup_dot_py.html I've done what's required.

Is this a known issue or need I do something more?


Originally posted by billmania on ROS Answers with karma: 266 on 2020-05-01

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Thanks to a nudge and some suggestions from Jarvis Schultz I found the problem with my setup. In my definition of the package_dir argument in setup.py, I incorrectly put 'src'. Since my nodes and their supporting Python modules are in "nodes" and not in "src", an update to that argument solved the problem.

After the correction, I verified that I can import moos_ros.py and uuv_moos.py in both the devel and the install environments.


Originally posted by billmania with karma: 266 on 2020-05-04

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.