opendr-eu / opendr

A modular, open and non-proprietary toolkit for core robotic functionalities by harnessing deep learning
Apache License 2.0
619 stars 95 forks source link

ROS2 Node for Object Detection 2D Gem gives Error #415

Closed aselimc closed 1 year ago

aselimc commented 1 year ago

Hello,

I was trying to write ROS2 nodes for the new algorithm that I am implementing "CL-Slam". Here we use message_filters similar to projects/opendr_ws_2/opendr_percteption/opendr_perception/object_detection_2d_gem_node.py. Here in the lines 190-191:

msg_rgb = message_filters.Subscriber(self, ROS_Image, input_rgb_image_topic, 1)
msg_ir = message_filters.Subscriber(self, ROS_Image, input_infra_image_topic, 1)

This gives the following error:

gem_node = ObjectDetectionGemNode(
  File "/home/canakcia/opendr/projects/opendr_ws_2/install/opendr_perception/lib/python3.8/site-packages/opendr_perception/object_detection_2d_gem_node.py", line 190, in __init__
    msg_rgb = message_filters.Subscriber(self, ROS_Image, input_rgb_image_topic, 1)
  File "/opt/ros/foxy/lib/python3.8/site-packages/message_filters/__init__.py", line 80, in __init__
    self.sub = self.node.create_subscription(*args[1:], self.callback, **kwargs)
TypeError: create_subscription() got multiple values for argument 'qos_profile'

I currently don't have a suggestion to fix this and I am investigating it for CL-SLAM and I can provide a solution if I find one. I simply tried deleting the 'qos_profile' size defined as 1 in the code. But for CL-SLAM case, this leads to another issue where the callback function is never called.

Edit: Actually, not sending the 'qos_profile' solves the problem. I suggest changing the lines 190-191 in the projects/opendr_ws_2/opendr_percteption/opendr_perception/object_detection_2d_gem_node.py to:

msg_rgb = message_filters.Subscriber(self, ROS_Image, input_rgb_image_topic)
msg_ir = message_filters.Subscriber(self, ROS_Image, input_infra_image_topic)
jelledouwe commented 1 year ago

Hi @aselimc,

Thanks for opening the issue and for proposing the fix! For me it solves the issue indeed. I created a PR: #420.