rockchip-linux / rknn-toolkit2

BSD 3-Clause "New" or "Revised" License
859 stars 154 forks source link

ROS init_node issue #270

Open WWX-alpha opened 8 months ago

WWX-alpha commented 8 months ago

If rospy and RKNNLite are imported at same time, follow error occurs:

orangepi@orangepi5plus:~/spt_ws/src$ /bin/python /home/orangepi/spt_ws/src/serialTest/scripts/yoloRosTest.py
Traceback (most recent call last):
  File "/home/orangepi/spt_ws/src/serialTest/scripts/yoloRosTest.py", line 236, in <module>
    rospy.init_node('detect_node') #定义节点
  File "/opt/ros/noetic/lib/python3/dist-packages/rospy/client.py", line 309, in init_node
    rospy.core.configure_logging(resolved_node_name)
  File "/opt/ros/noetic/lib/python3/dist-packages/rospy/core.py", line 405, in configure_logging
    _log_filename = rosgraph.roslogging.configure_logging('rospy', level, filename=filename)
  File "/opt/ros/noetic/lib/python3/dist-packages/rosgraph/roslogging.py", line 192, in configure_logging
    logging.config.fileConfig(config_file, disable_existing_loggers=False)
  File "/usr/lib/python3.8/logging/config.py", line 79, in fileConfig
    handlers = _install_handlers(cp, formatters)
  File "/usr/lib/python3.8/logging/config.py", line 148, in _install_handlers
    h.setLevel(level)
  File "/usr/lib/python3.8/logging/__init__.py", line 916, in setLevel
    self.level = _checkLevel(level)
  File "/usr/lib/python3.8/logging/__init__.py", line 198, in _checkLevel
    raise ValueError("Unknown level: %r" % level)
ValueError: Unknown level: 'DEBUG'

my code:

#!/usr/bin/env python3
#coding = utf-8

import rospy
import numpy as np
import cv2
from rknnlite.api import RKNNLite

if __name__ == '__main__':
    rospy.init_node('detect_node') 
fronos commented 5 months ago

It looks like RKNN overrides ros logging. Try to launch detection in a separate process may help you.

knifecutter commented 5 months ago

same issue , import RKNNLite after init_node

yueluweiming commented 1 month ago

same issue , import RKNNLite after init_node

hi bro ,could you show some details ,how to import RKNNLite after that ,thank you

WWX-alpha commented 1 month ago

same issue , import RKNNLite after init_node

hi bro ,could you show some details ,how to import RKNNLite after that ,thank you

maybe just init_node first and then import RKNNLite. but I used multiprossing to seprate them in two threads, one for ROS and another for RKNN, then use pipe to communicate.