Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabling debug node #49

Open
godcapable opened this issue Aug 30, 2024 · 3 comments
Open

Disabling debug node #49

godcapable opened this issue Aug 30, 2024 · 3 comments

Comments

@godcapable
Copy link

godcapable commented Aug 30, 2024

Hi, I have problem where detection and tracking node is sending message, but debug node is making an error.

I guess it is error comping from cv2_bridge extension.

So, I want to activate detection node and tracking node only, and deactivate debug node.

Would you let me know in which part of the python code might be modified to disable only the debug node?

C:\Users\skyun.oh\Desktop>ros2 launch yolov8_bringup yolov8.launch.py image_reliability:=1
[INFO] [launch]: All log files can be found below C:\Users\skyun.oh.ros\log\2024-08-30-13-27-44-599362-KORCO087849-40472
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [yolov8_node.EXE-1]: process started with pid [46528]
[INFO] [tracking_node.EXE-2]: process started with pid [46280]
[INFO] [debug_node.EXE-3]: process started with pid [46828]
[ERROR] [yolov8_node.EXE-1]: process has died [pid 46528, exit code 1, cmd 'c:\ros2_workspace\install\yolov8_ros\lib\yolov8_ros\yolov8_node.EXE --ros-args -r __node:=yolov8_node -r __ns:=/yolo --params-file C:\Users\skyun.oh\AppData\Local\Temp\launch_params_2hbnfeej -r image_raw:=/camera/rgb/image_raw'].
[yolov8_node.EXE-1] [INFO] [1724992080.844718600] [yolo.yolov8_node]: [yolov8_node] Configuring...

@mgonzs13
Copy link
Owner

Hey @godcapable, you can modify the launch files and comment the debug node. Do you have more logs about the error (this line, the error/exception,...)?

@godcapable
Copy link
Author

godcapable commented Sep 2, 2024

Okay, here is the detailed log during debug_node execution:

C:\Users\skyun.oh\Desktop>c:\ros2_workspace\install\yolov8_ros\lib\yolov8_ros\debug_node.EXE --ros-args -r __node:=debug_node -r __ns:=/yolo --params-file C:\Users\skyun.oh\AppData\Local\Temp\launch_params_h616yxn1 -r image_raw:=/camera/rgb/image_raw -r detections:=tracking
OMP: Info #268: KMP_ALL_THREADS variable deprecated, please use KMP_DEVICE_THREAD_LIMIT instead.
[INFO] [1725281046.320399100] [yolo.debug_node]: Debug node created
[INFO] [1725281046.326683800] [yolo.debug_node]: Configuring debug_node
[INFO] [1725281046.682858800] [yolo.debug_node]: Activating debug_node
Traceback (most recent call last):
  File "c:\ros2_workspace\install\yolov8_ros\lib\yolov8_ros\debug_node-script.py", line 33, in <module>
    sys.exit(load_entry_point('yolov8-ros==0.0.0', 'console_scripts', 'debug_node')())
  File "c:\ros2_workspace\install\yolov8_ros\Lib\site-packages\yolov8_ros\debug_node.py", line 306, in main
    rclpy.spin(node)
  File "c:\opt\ros\humble\x64\Lib\site-packages\rclpy\__init__.py", line 222, in spin
    executor.spin_once()
  File "c:\opt\ros\humble\x64\Lib\site-packages\rclpy\executors.py", line 712, in spin_once
    raise handler.exception()
  File "c:\opt\ros\humble\x64\Lib\site-packages\rclpy\task.py", line 239, in __call__
    self._handler.send(None)
  File "c:\opt\ros\humble\x64\Lib\site-packages\rclpy\executors.py", line 418, in handler
    await call_coroutine(entity, arg)
  File "c:\opt\ros\humble\x64\Lib\site-packages\rclpy\executors.py", line 343, in _execute_subscription
    await await_or_execute(sub.callback, msg)
  File "c:\opt\ros\humble\x64\Lib\site-packages\rclpy\executors.py", line 107, in await_or_execute
    return callback(*args)
  File "c:\opt\ros\humble\x64\Lib\site-packages\message_filters\__init__.py", line 83, in callback
    self.signalMessage(msg)
  File "c:\opt\ros\humble\x64\Lib\site-packages\message_filters\__init__.py", line 64, in signalMessage
    cb(*(msg + args))
  File "c:\opt\ros\humble\x64\Lib\site-packages\message_filters\__init__.py", line 313, in add
    self.signalMessage(*msgs)
  File "c:\opt\ros\humble\x64\Lib\site-packages\message_filters\__init__.py", line 64, in signalMessage
    cb(*(msg + args))
  File "c:\ros2_workspace\install\yolov8_ros\Lib\site-packages\yolov8_ros\debug_node.py", line 295, in detections_cb
    self._dbg_pub.publish(self.cv_bridge.cv2_to_imgmsg(cv_image,encoding=img_msg.encoding))
  File "c:\ros2_workspace\install\cv_bridge\Lib\site-packages\cv_bridge\core.py", line 276, in cv2_to_imgmsg
    if self.cvtype_to_name[self.encoding_to_cvtype2(encoding)] != cv_type:
  File "c:\ros2_workspace\install\cv_bridge\Lib\site-packages\cv_bridge\core.py", line 96, in encoding_to_cvtype2
    from cv_bridge.boost.cv_bridge_boost import getCvType
**ImportError: DLL load failed while importing cv_bridge_boost: no such procedure**


The error is due to usage of the usage of cv_bridge: My computer doens't allow cv_bridge usage
As such, I need to use numpy instead of cv2.

I successfully modified yolov8_node.py and tracking_node.py :

    def image_cb(self, msg: Image) -> None:

        if self.enable:

            # convert image + predict
            # cv_image = self.cv_bridge.imgmsg_to_cv2(msg)
            im = np.frombuffer(msg.data, dtype=np.uint8).reshape(msg.height, msg.width, -1)

Also,


    def detections_cb(self, img_msg: Image, detection_msg: DetectionArray) -> None:

        # cv_image = self.cv_bridge.imgmsg_to_cv2(img_msg)
        cv_image = np.frombuffer(img_msg.data, dtype=np.uint8).reshape(img_msg.height, img_msg.width, -1)

This way, I could directly use numpy instead of cv2 and safely get message from detection node and tracking node (they actually detect object through yolov8 algorithm. I could only see it in terminla)

But [debug_node.EXE-3] generate error, because I don't know how to re-convert numpy to image message in publishing code section in debug_node.py :

        # publish dbg image
        self._dbg_pub.publish(self.cv_bridge.cv2_to_imgmsg(cv_image,encoding=img_msg.encoding))
                    

I believe if I know how to modify this code, my problem will be resolved easily.
Could you help me change the code "cv2 to image massage conversion" to "numpy to image massage conversion"?

Your help will be greatly appreciated.

@mgonzs13
Copy link
Owner

mgonzs13 commented Sep 3, 2024

Hey @godcapable, you can check the code of CvBridge to get how to do it. So you can do the following:

new_img_msg = sensor_msgs.msg.Image()
new_img_msg.height = cv_image.shape[0]
new_img_msg.width = cv_image.shape[1]
new_img_msg.encoding = img_msg.encoding
new_img_msg.data.frombytes(cv_image.tobytes())
new_img_msg.step = len(new_img_msg.data) 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants