ROS2 Cannot find other python file dependancies
Hi, I'm encountering an error when running my Ros2 node. This is the error message I get.
ModuleNotFoundError: No module named 'models'
I find this odd, because I can run the python script from within the terminal and also from within VS and the code runs perfectly as expected.
I believe that ROS2 cannot find the other file dependencies in sub-folders, and I'm not sure how to point it in the right direction or if there is a way around it. All relevant info is below.
Im using ROS2 Foxy and Python3, detector.py is my python node file.
Here is the section of code in question:
#!/usr/bin/env python3
import rclpy
from rclpy.node import Node
from std_msgs.msg import String
import sys
import numpy as np
import argparse
import torch
import cv2
import pyzed.sl as sl
import torch.backends.cudnn as cudnn
from models.experimental import attempt_load
from utils.general import check_img_size, non_max_suppression, scale_coords, xyx
from utils.torch_utils import select_device
from utils.augmentations import letterbox
from threading import Lock, Thread
from time import sleep
import ogl_viewer.viewer as gl
import cv_viewer.tracking_viewer as cv_viewer
And my setup.py file: f
rom setuptools import setup
from setuptools import find_packages
package_name = 'zed_object_detect'
packages=find_packages(exclude=['test'])
setup(
name=package_name,
version='0.0.0',
packages=[package_name],
data_files=[
('share/ament_index/resource_index/packages',
['resource/' + package_name]),
('share/' + package_name, ['package.xml']),
],
install_requires=['setuptools'],
zip_safe=True,
maintainer='ubuntu1',
maintainer_email='ubuntu1@todo.todo',
description='TODO: Package description',
license='TODO: License declaration',
tests_require=['pytest'],
entry_points={
'console_scripts': [
'detector = zed_object_detect.detector:main'
],
},
)
Here is the node tree:
├── package.xml
├── resource
│ └── zed_object_detect
├── setup.cfg
├── setup.py
├── test
│ ├── test_copyright.py
│ ├── test_flake8.py
│ └── test_pep257.py
└── zed_object_detect
├── benchmarks.py
├── classify
│ ├── predict.py
│ ├── train.py
│ └── val.py
├── CONTRIBUTING.md
├── cv_viewer
│ ├── __pycache__
│ │ ├── tracking_viewer.cpython-38.pyc
│ │ └── utils.cpython-38.pyc
│ ├── tracking_viewer.py
│ └── utils.py
├── data
│ ├── Argoverse.yaml
│ ├── coco128-seg.yaml
│ ├── coco128.yaml
│ ├── coco.yaml
│ ├── GlobalWheat2020.yaml
│ ├── hyps
│ │ ├── hyp.Objects365.yaml
│ │ ├── hyp.scratch-high.yaml
│ │ ├── hyp.scratch-low.yaml
│ │ ├── hyp.scratch-med.yaml
│ │ └── hyp.VOC.yaml
│ ├── ImageNet.yaml
│ ├── images
│ │ ├── bus.jpg
│ │ └── zidane.jpg
│ ├── Objects365.yaml
│ ├── scripts
│ │ ├── download_weights.sh
│ │ ├── get_coco128.sh
│ │ ├── get_coco.sh
│ │ └── get_imagenet.sh
│ ├── SKU-110K.yaml
│ ├── VisDrone.yaml
│ ├── VOC.yaml
│ └── xView.yaml
├── detector.py
├── detect.py
├── export.py
├── hubconf.py
├── __init__.py
├── LICENSE
├── models
│ ├── common.py
│ ├── experimental.py
│ ├── hub
│ │ ├── anchors.yaml
│ │ ├── yolov3-spp.yaml
│ │ ├── yolov3-tiny.yaml
│ │ ├── yolov3.yaml
│ │ ├── yolov5-bifpn.yaml
│ │ ├── yolov5-fpn.yaml
│ │ ├── yolov5l6.yaml
│ │ ├── yolov5m6.yaml
│ │ ├── yolov5n6.yaml
│ │ ├── yolov5-p2.yaml
│ │ ├── yolov5-p34.yaml
│ │ ├── yolov5-p6.yaml
│ │ ├── yolov5-p7.yaml
│ │ ├── yolov5-panet.yaml
│ │ ├── yolov5s6.yaml
│ │ ├── yolov5s-ghost.yaml
│ │ ├── yolov5s-LeakyReLU.yaml
│ │ ├── yolov5s-transformer.yaml
│ │ └── yolov5x6.yaml
│ ├── __init__.py
│ ├── __pycache__
│ │ ├── common.cpython-38.pyc
│ │ ├── experimental.cpython-38.pyc
│ │ ├── __init__.cpython-38.pyc
│ │ └── yolo.cpython-38.pyc
│ ├── segment
│ │ ├── yolov5l-seg.yaml
│ │ ├── yolov5m-seg.yaml
│ │ ├── yolov5n-seg.yaml
│ │ ├── yolov5s-seg.yaml
│ │ └── yolov5x-seg.yaml
│ ├── tf.py
│ ├── yolo.py
│ ├── yolov5l.yaml
│ ├── yolov5m.yaml
│ ├── yolov5n.yaml
│ ├── yolov5s.yaml
│ └── yolov5x.yaml
├── ogl_viewer
│ ├── __pycache__
│ │ ├── viewer.cpython-38.pyc
│ │ └── zed_model.cpython-38.pyc
│ ├── viewer.py
│ └── zed_model.py
├── README.md
├── requirements.txt
├── segment
│ ├── predict.py
│ ├── train.py
│ ├── tutorial.ipynb
│ └── val.py
├── setup.cfg
├── train.py
├── tutorial.ipynb
├── utils
│ ├── activations.py
│ ├── augmentations.py
│ ├── autoanchor.py
│ ├── autobatch.py
│ ├── aws
│ │ ├── __init__.py
│ │ ├── mime.sh
│ │ ├── resume.py
│ │ └── userdata.sh
│ ├── callbacks.py
│ ├── dataloaders ...